/** * Array of all the elements. * * @return an array containing all of the elements in this collection. */ public Object[] toArray() { // code based on AbstractFeatureCollection // TODO: base this on reader ArrayList<SimpleFeature> array = new ArrayList<SimpleFeature>(); FeatureIterator<SimpleFeature> e = null; try { e = features(); while (e.hasNext()) { array.add(e.next()); } return array.toArray(new SimpleFeature[array.size()]); } finally { if (e != null) { e.close(); } } }
@SuppressWarnings("unchecked") public <T> T[] toArray(T[] array) { int size = size(); if (array.length < size) { array = (T[]) java.lang.reflect.Array.newInstance( array.getClass().getComponentType(), size); } FeatureIterator<SimpleFeature> it = features(); try { Object[] result = array; for (int i = 0; it.hasNext() && i < size; i++) { result[i] = it.next(); } if (array.length > size) { array[size] = null; } return array; } finally { if (it != null) { it.close(); } } }
/** * Returns the feature collection if the features of the feature source which meet the specified * query criteria. */ public final ContentFeatureCollection getFeatures(Query query) throws IOException { query = joinQuery(query); return new ContentFeatureCollection(this, query); }
int count(String typeName) throws IOException { // return count(reader(typeName)); // makes use of optimization if any return dataStore.getFeatureSource(typeName).getFeatures().size(); }
public <T> T[] toArray(T[] array) { int size = size(); if (array.length < size){ array = (T[])java.lang.reflect.Array.newInstance(array.getClass().getComponentType(), size); } Iterator<SimpleFeature> it = iterator(); try { Object[] result = array; for (int i=0; it.hasNext() && i<size; i++){ result[i] = it.next(); } if (array.length > size){ array[size] = null; } return array; } finally { close( it ); } } public String getID() {
/** * Returns <tt>true</tt> if this collection contains all of the elements * in the specified collection. <p> * * @param c collection to be checked for containment in this collection. * @return <tt>true</tt> if this collection contains all of the elements * in the specified collection. * @throws NullPointerException if the specified collection is null. * * @see #contains(Object) */ public boolean containsAll(Collection<?> c) { // TODO: base this on reader Iterator<?> e = c.iterator(); try { while (e.hasNext()){ if(!contains(e.next())){ return false; } } return true; } finally { close( e ); } }
/** * Returns <tt>true</tt> if this collection contains all of the elements in the specified * collection. * * <p> * * @param c collection to be checked for containment in this collection. * @return <tt>true</tt> if this collection contains all of the elements in the specified * collection. * @throws NullPointerException if the specified collection is null. * @see #contains(Object) */ public boolean containsAll(Collection<?> c) { Iterator<?> e = c.iterator(); try { while (e.hasNext()) { if (!contains(e.next())) { return false; } } return true; } finally { if (e instanceof FeatureIterator) { ((FeatureIterator<?>) e).close(); } } }
public boolean isEmpty() { return size() == 0; }
e = this.features(); if (o == null) { while (e.hasNext()) {
void doTestSimpleJoin(boolean exposePrimaryKeys) throws Exception { dataStore.setExposePrimaryKeyColumns(exposePrimaryKeys); try (SimpleFeatureIterator ita = dataStore.getFeatureSource(tname("ft1")).getFeatures().features()) { try (SimpleFeatureIterator itb = dataStore.getFeatureSource(tname("ftjoin")).getFeatures().features()) { dataStore.getFeatureSource(tname("ft1")).getFeatures(q); assertEquals( dataStore.getFeatureSource(tname("ft1")).getFeatures(q).size(), features.size());
.id(Collections.singleton(ids.get(0))); ContentFeatureCollection features = featureStore.getFeatures(filter); assertEquals(1, features.size()); SimpleFeature found = DataUtilities.first(features); assertEquals(theValue, found.getAttribute(theProperty));
/** Returns the feature collection of all the features of the feature source. */ public final ContentFeatureCollection getFeatures() throws IOException { Query query = joinQuery(Query.ALL); return new ContentFeatureCollection(this, query); }
@Override public Geometry loadFootprint(String pathNoExtension) throws Exception { File file = new File(pathNoExtension + ".shp"); if (file.exists()) { ShapefileDataStore ds = new ShapefileDataStore(URLs.fileToUrl(file)); SimpleFeatureIterator fi = null; try { fi = ds.getFeatureSource().getFeatures().features(); if (!fi.hasNext()) { return null; } else { SimpleFeature sf = fi.next(); Geometry result = (Geometry) sf.getDefaultGeometry(); if (fi.hasNext()) { throw new IOException( "Found more than one footprint record in the shapefile " + file.getCanonicalPath()); } return result; } } finally { if (fi != null) { fi.close(); } ds.dispose(); } } return null; }
void doTestSimpleJoinInvertedAliases(boolean exposePrimaryKeys) throws Exception { dataStore.setExposePrimaryKeyColumns(exposePrimaryKeys); try (SimpleFeatureIterator ita = dataStore.getFeatureSource(tname("ft1")).getFeatures().features(); SimpleFeatureIterator itb = dataStore.getFeatureSource(tname("ftjoin")).getFeatures().features()) { FilterFactory ff = dataStore.getFilterFactory(); Query q = new Query(tname("ft1")); dataStore.getFeatureSource(tname("ft1")).getFeatures(q); assertEquals( dataStore.getFeatureSource(tname("ft1")).getFeatures(q).size(), features.size());
assertEquals(4, featureStore.getFeatures().size()); assertEquals(3, featureStore2.getFeatures().size()); assertEquals(4, featureStore.getFeatures().size()); assertEquals(3, featureStore2.getFeatures().size()); assertEquals(4, featureStore.getFeatures().size()); assertEquals(4, featureStore2.getFeatures().size());
public SimpleFeatureCollection sort(org.opengis.filter.sort.SortBy sort) { Query query = new Query(); query.setSortBy(new org.opengis.filter.sort.SortBy[] {sort}); query = DataUtilities.mixQueries(this.query, query, null); return new ContentFeatureCollection(featureSource, query); }