All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geotools.data.SimpleFeatureCollectionBridge Maven / Gradle / Ivy

Go to download

The main module contains the GeoTools public interfaces that are used by other GeoTools modules (and GeoTools applications). Where possible we make use industry standard terms as provided by OGC and ISO standards. The formal GeoTools public api consists of gt-metadata, jts and the gt-main module. The main module contains the default implementations that are available provided to other GeoTools modules using our factory system. Factories are obtained from an appropriate FactoryFinder, giving applications a chance configure the factory used using the Factory Hints facilities. FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Expression expr = ff.add( expression1, expression2 ); If you find yourself using implementation specific classes chances are you doing it wrong: Expression expr = new AddImpl( expression1, expressiom2 );

The newest version!
/*
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 *
 *    (C) 2003-2008, Open Source Geospatial Foundation (OSGeo)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */
package org.geotools.data;

import java.io.IOException;
import java.util.Collection;
import java.util.NoSuchElementException;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.feature.FeatureVisitor;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.filter.Filter;
import org.opengis.filter.sort.SortBy;
import org.opengis.util.ProgressListener;

/**
 * This class is a bridge between a FeatureCollection and the
 * SimpleFeatureCollection interface.
 *
 * 

This class is package visbile and can only be created by DataUtilities.simple( * featureCollection ); it is under lock and key so that we can safely do an instance of check and * not get multiple wrappers piling up. * * @author Jody * @since 2.7 */ class SimpleFeatureCollectionBridge implements SimpleFeatureCollection { private FeatureCollection collection; public SimpleFeatureCollectionBridge( FeatureCollection featureCollection) { if (featureCollection == null) { throw new NullPointerException("FeatureCollection required"); } if (featureCollection instanceof SimpleFeatureCollection) { throw new IllegalArgumentException("Already a SimpleFeatureCollection"); } this.collection = featureCollection; } @SuppressWarnings("PMD.CloseResource") // closed in the wrapper public SimpleFeatureIterator features() { final FeatureIterator features = collection.features(); return new SimpleFeatureIterator() { public SimpleFeature next() throws NoSuchElementException { return features.next(); } public boolean hasNext() { return features.hasNext(); } public void close() { features.close(); } }; } public SimpleFeatureCollection sort(SortBy order) { return new SimpleFeatureCollectionBridge(collection.sort(order)); } public SimpleFeatureCollection subCollection(Filter filter) { return new SimpleFeatureCollectionBridge(collection.subCollection(filter)); } public void accepts(FeatureVisitor visitor, ProgressListener progress) throws IOException { collection.accepts(visitor, progress); } public boolean contains(Object o) { return collection.contains(o); } public boolean containsAll(Collection o) { return collection.containsAll(o); } public ReferencedEnvelope getBounds() { return collection.getBounds(); } public String getID() { return collection.getID(); } public SimpleFeatureType getSchema() { return collection.getSchema(); } public boolean isEmpty() { return collection.isEmpty(); } public int size() { return collection.size(); } public Object[] toArray() { return collection.toArray(); } public O[] toArray(O[] a) { return collection.toArray(a); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy