@SuppressWarnings("unchecked") public CollectionModel createTemplateFeatureCollection( FeatureCollection collection, BeansWrapper wrapper) { return new CollectionModel(DataUtilities.list(collection), wrapper); } }
/** * Utility to get all the features to implement the toArray methods * * @deprecated Use {@link DataUtilities#list(org.geotools.feature.FeatureCollection)} */ protected List<F> toList() { return DataUtilities.list(this); } /**
public void testAddRemoveAllAbilities() throws Exception { Collection half = randomPiece(features); Collection otherHalf = DataUtilities.list(features);
SimpleFeatureCollection fc = (SimpleFeatureCollection) node.getChildValue(FeatureCollection.class); insertElement.getFeature().addAll(DataUtilities.list(fc)); } else if (node.hasChild(SimpleFeature.class)) { insertElement.getFeature().addAll(node.getChildValues(SimpleFeature.class));
public void clear() { List toDelete = DataUtilities.list( this ); removeAll( toDelete ); }
public void testAssorted() { TreeSetFeatureCollection copy = new TreeSetFeatureCollection(); copy.addAll(features); copy.clear(); assertTrue(copy.isEmpty()); copy.addAll(features); assertTrue(!copy.isEmpty()); List<SimpleFeature> list = DataUtilities.list(features); SimpleFeature[] f1 = (SimpleFeature[]) list.toArray(new SimpleFeature[list.size()]); SimpleFeature[] f2 = (SimpleFeature[]) features.toArray(new SimpleFeature[list.size()]); assertEquals(f1.length, f2.length); for (int i = 0; i < f1.length; i++) { assertSame(f1[i], f2[i]); } SimpleFeatureIterator copyIterator = copy.features(); SimpleFeatureIterator featuresIterator = features.features(); while (copyIterator.hasNext() && featuresIterator.hasNext()) { assertEquals(copyIterator.next(), featuresIterator.next()); } }
public void dataStoreChange(TransactionEvent event) throws WFSException { events.add(event); features.addAll(DataUtilities.list(event.getAffectedFeatures())); } }
@Test public void testFeatureTypeAdapterHandlesSimilarCRSes() throws SchemaException, IOException { // create two FT - only difference is they have different (but compatible) CRS. SimpleFeatureType schema1 = createSampleType((CoordinateReferenceSystem) PROJ_EPSG4326_CRS); SimpleFeatureType schema2 = createSampleType( (CoordinateReferenceSystem) PROJ_EQUIV_EPSG4326_CRS); // make 2 features for the first schema SimpleFeature f1 = DataUtilities.template(schema1); f1.setDefaultGeometry(gf.createPoint(new Coordinate(1, 1))); SimpleFeature f2 = DataUtilities.template(schema1); f2.setDefaultGeometry(gf.createPoint(new Coordinate(2, 2))); // create a FeatureSource for these 2 features SimpleFeature[] features = new SimpleFeature[] { f1, f2 }; SimpleFeatureSource fs = DataUtilities.source(features); // this is what we are testing - adapting between the two different (but compatible) CRS. FeatureTypeAdapterFeatureSource ftafs = new FeatureTypeAdapterFeatureSource(fs, schema2); // get the resulting features List<SimpleFeature> newFeatures = DataUtilities.list(ftafs.getFeatures()); //verify correct Assert.isTrue(f1.equals(newFeatures.get(0))); Assert.isTrue(f2.equals(newFeatures.get(1))); }
public void testAssorted() { SimpleFeatureCollection copy = FeatureCollections.newCollection(); copy.addAll(features); copy.clear(); assertTrue(copy.isEmpty()); copy.addAll(features); assertTrue(!copy.isEmpty()); List<SimpleFeature> list = DataUtilities.list(features); SimpleFeature[] f1 = (SimpleFeature[]) list.toArray(new SimpleFeature[list.size()]); SimpleFeature[] f2 = (SimpleFeature[]) features.toArray(new SimpleFeature[list.size()]); assertEquals(f1.length, f2.length); for (int i = 0; i < f1.length; i++) { assertSame(f1[i], f2[i]); } SimpleFeatureIterator copyIterator = copy.features(); SimpleFeatureIterator featuresIterator = features.features(); while (copyIterator.hasNext() && featuresIterator.hasNext()) { assertEquals(copyIterator.next(), featuresIterator.next()); } SimpleFeatureCollection listen = FeatureCollections.newCollection(); ListenerProxy counter = new ListenerProxy(); listen.addListener(counter); listen.addAll(features); assertEquals(1, counter.changeEvents); listen.removeListener(counter); listen.removeAll(DataUtilities.list(features)); assertEquals(1, counter.changeEvents); }
private void verify(IndexInfo indexInfo, List<SimpleFeature> expectedFeatures) throws IOException { String typeName = indexInfo.getTreeName(); GeogigFeatureStore source = (GeogigFeatureStore) dataStore.getFeatureSource(typeName); assertEquals(expectedFeatures.size(), source.getCount(Query.ALL)); NodeRef typeRef = source.delegate.getTypeRef(); ObjectId canonicalTreeId = typeRef.getObjectId(); Optional<ObjectId> resolveIndexedTree = repo.indexDatabase().resolveIndexedTree(indexInfo, canonicalTreeId); assertTrue(resolveIndexedTree.isPresent()); ObjectId indexTreeId = resolveIndexedTree.get(); Set<String> extraAttributes = IndexInfo.getMaterializedAttributeNames(indexInfo); String[] extraAtts = new ArrayList<>(extraAttributes).toArray(new String[0]); IndexTestSupport.verifyIndex(geogig, indexTreeId, canonicalTreeId, extraAtts); List<SimpleFeature> contents = DataUtilities.list(source.getFeatures()); Map<String, SimpleFeature> expected = Maps.uniqueIndex(expectedFeatures, (f) -> f.getID()); Map<String, SimpleFeature> actual = Maps.uniqueIndex(contents, (f) -> f.getID()); assertEquals(expected.size(), actual.size()); assertEquals(expected.keySet(), actual.keySet()); for (String fid : expected.keySet()) { SimpleFeature e = expected.get(fid); SimpleFeature a = actual.get(fid); List<Object> eatts = e.getAttributes(); List<Object> aatts = a.getAttributes(); assertEquals(eatts, aatts); } }
private void verify(IndexInfo indexInfo, List<SimpleFeature> expectedFeatures) throws IOException { String typeName = indexInfo.getTreeName(); GeogigFeatureStore source = (GeogigFeatureStore) dataStore.getFeatureSource(typeName); assertEquals(expectedFeatures.size(), source.getCount(Query.ALL)); NodeRef typeRef = source.delegate.getTypeRef(); ObjectId canonicalTreeId = typeRef.getObjectId(); Optional<ObjectId> resolveIndexedTree = repo.indexDatabase().resolveIndexedTree(indexInfo, canonicalTreeId); assertTrue(resolveIndexedTree.isPresent()); ObjectId indexTreeId = resolveIndexedTree.get(); Set<String> extraAttributes = IndexInfo.getMaterializedAttributeNames(indexInfo); String[] extraAtts = new ArrayList<>(extraAttributes).toArray(new String[0]); IndexTestSupport.verifyIndex(geogig, indexTreeId, canonicalTreeId, extraAtts); List<SimpleFeature> contents = DataUtilities.list(source.getFeatures()); Map<String, SimpleFeature> expected = Maps.uniqueIndex(expectedFeatures, (f) -> f.getID()); Map<String, SimpleFeature> actual = Maps.uniqueIndex(contents, (f) -> f.getID()); assertEquals(expected.size(), actual.size()); assertEquals(expected.keySet(), actual.keySet()); for (String fid : expected.keySet()) { SimpleFeature e = expected.get(fid); SimpleFeature a = actual.get(fid); List<Object> eatts = e.getAttributes(); List<Object> aatts = a.getAttributes(); assertEquals(eatts, aatts); } }
public void testAddRemoveAllAbilities() throws Exception { Collection half = randomPiece(features); Collection otherHalf = DataUtilities.list(features); otherHalf.removeAll(half); features.removeAll(half); assertTrue(features.containsAll(otherHalf)); assertTrue(!features.containsAll(half)); features.removeAll(otherHalf); assertTrue(features.size() == 0); features.addAll(half); assertTrue(features.containsAll(half)); features.addAll(otherHalf); assertTrue(features.containsAll(otherHalf)); features.retainAll(otherHalf); assertTrue(features.containsAll(otherHalf)); assertTrue(!features.containsAll(half)); features.addAll(otherHalf); Iterator i = features.iterator(); while (i.hasNext()) { i.next(); i.remove(); } assertEquals(features.size(), 0); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName("XXX"); SimpleFeatureBuilder b = new SimpleFeatureBuilder(tb.buildFeatureType()); assertTrue(!features.remove(b.buildFeature(null))); }
SimpleFeatureCollection fc = (SimpleFeatureCollection) node.getChildValue(FeatureCollection.class); insertElement.getFeature().addAll(DataUtilities.list(fc)); } else if (node.hasChild(SimpleFeature.class)) { insertElement.getFeature().addAll(node.getChildValues(SimpleFeature.class));
@Test public void testFeatureTypeAdapterHandlesSimilarCRSes() throws SchemaException, IOException { // create two FT - only difference is they have different (but compatible) CRS. SimpleFeatureType schema1 = createSampleType((CoordinateReferenceSystem) PROJ_EPSG4326_CRS); SimpleFeatureType schema2 = createSampleType( (CoordinateReferenceSystem) PROJ_EQUIV_EPSG4326_CRS); // make 2 features for the first schema SimpleFeature f1 = DataUtilities.template(schema1); f1.setDefaultGeometry(gf.createPoint(new Coordinate(1, 1))); SimpleFeature f2 = DataUtilities.template(schema1); f2.setDefaultGeometry(gf.createPoint(new Coordinate(2, 2))); // create a FeatureSource for these 2 features SimpleFeature[] features = new SimpleFeature[] { f1, f2 }; SimpleFeatureSource fs = DataUtilities.source(features); // this is what we are testing - adapting between the two different (but compatible) CRS. FeatureTypeAdapterFeatureSource ftafs = new FeatureTypeAdapterFeatureSource(fs, schema2); // get the resulting features List<SimpleFeature> newFeatures = DataUtilities.list(ftafs.getFeatures()); //verify correct Assert.isTrue(f1.equals(newFeatures.get(0))); Assert.isTrue(f2.equals(newFeatures.get(1))); }
final int expected = total - matching; List<SimpleFeature> expectedResult = DataUtilities.list(store.getFeatures());
final int expected = total - matching; List<SimpleFeature> expectedResult = DataUtilities.list(store.getFeatures());