public void testComposeMany() { SimpleFeatureCollection roads = DataUtilities.collection(roadFeatures); SimpleFeatureCollection rivers = DataUtilities.collection(riverFeatures); SimpleFeatureCollection lakes = DataUtilities.collection(lakeFeatures); CompositeFeatureCollection fc = new CompositeFeatureCollection(Arrays.asList(roads, rivers, lakes)); // 3 roads, 2 rivers, 1 lake assertEquals(6, fc.size()); assertEquals( new ReferencedEnvelope(1, 16, 0, 10, riverType.getCoordinateReferenceSystem()), fc.getBounds()); assertEquals(roadFeatures[0], DataUtilities.first(fc)); } }
public void testComposeOne() { CompositeFeatureCollection fc = new CompositeFeatureCollection( Arrays.asList(DataUtilities.collection(riverFeatures[0]))); assertEquals(1, fc.size()); assertEquals( new ReferencedEnvelope(5, 13, 3, 7, riverType.getCoordinateReferenceSystem()), fc.getBounds()); assertEquals(riverFeatures[0], DataUtilities.first(fc)); }
sfb.set("NAME", "Old oak"); SimpleFeature feature = sfb.buildFeature(null); SimpleFeatureCollection fc = DataUtilities.collection(feature);
sfb.set("NAME", "Old oak"); SimpleFeature feature = sfb.buildFeature(null); SimpleFeatureCollection fc = DataUtilities.collection(feature);
/** */ private void buildStore() { SimpleFeatureCollection collection = DataUtilities.collection(features.toArray(new SimpleFeature[features.size()])); dataStore = DataUtilities.dataStore(collection); }
public void testSimpleCollectionList() { SimpleFeatureCollection featureCollection = DataUtilities.collection(Arrays.asList(roadFeatures)); assertEquals(roadFeatures.length, featureCollection.size()); }
public void testSimpleSource() { SimpleFeatureCollection collection = DataUtilities.collection(roadFeatures); FeatureSource<SimpleFeatureType, SimpleFeature> source = DataUtilities.source(collection); SimpleFeatureSource simple = DataUtilities.simple(source); assertSame(simple, source); }
public void testBounds() { SimpleFeatureCollection collection = DataUtilities.collection(roadFeatures); ReferencedEnvelope expected = collection.getBounds(); ReferencedEnvelope actual = DataUtilities.bounds(collection); assertEquals(expected, actual); }
public void testReprojectFeaturesCrsFromQuery() throws Exception { Query query = new Query(Query.ALL); CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3005"); query.setCoordinateSystemReproject(targetCRS); SimpleFeatureSource river = data.getFeatureSource("river"); SimpleFeatureCollection features = river.getFeatures(query); SimpleFeatureCollection expectedFeatures = DataUtilities.collection(riverFeatures); testTransformedFeatures(expectedFeatures, features, sourceCRS, null, targetCRS); }
public void testSetsFeaturesCrsFromFeatureType() throws Exception { Query query = new Query(Query.ALL); CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); SimpleFeatureSource river = data.getFeatureSource("river"); SimpleFeatureCollection features = river.getFeatures(query); SimpleFeatureCollection expectedFeatures = DataUtilities.collection(riverFeatures); testTransformedFeatures(expectedFeatures, features, sourceCRS, null, null); }
public void testSetsEnvelopeCrsFromQuery() throws Exception { Query query = new Query(Query.ALL); query.setCoordinateSystem(DefaultEngineeringCRS.CARTESIAN_2D); CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); SimpleFeatureSource river = data.getFeatureSource("river"); SimpleFeatureCollection features = river.getFeatures(query); SimpleFeatureCollection expectedFeatures = DataUtilities.collection(riverFeatures); testTransformedFeatures( expectedFeatures, features, sourceCRS, DefaultEngineeringCRS.CARTESIAN_2D, null); }
public void testAddFeature() throws Exception { SimpleFeature f1 = SimpleFeatureBuilder.build(type, new Object[] {"one", geom}, null); SimpleFeature f2 = SimpleFeatureBuilder.build(type, new Object[] {"two", geom}, null); SimpleFeatureStore store = (SimpleFeatureStore) ds.getFeatureSource("default"); store.setTransaction(new DefaultTransaction()); store.addFeatures(DataUtilities.collection(f1)); store.addFeatures(DataUtilities.collection(f2)); count(store, 3); // assertEquals("Number of known feature as obtained from getCount",3, // store.getCount(Query.ALL)); }
public void testFirst() { SimpleFeatureCollection collection = DataUtilities.collection(roadFeatures); SimpleFeature first = DataUtilities.first(collection); assertNotNull(first); assertEquals("road.rd1", first.getID()); }
public void testSimpleCollection() { FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = DataUtilities.collection(roadFeatures); SimpleFeatureCollection simple = DataUtilities.simple(featureCollection); assertSame(simple, featureCollection); // we expect a straight cast assertEquals(roadFeatures.length, featureCollection.size()); }
public void testReaderCollection() throws Exception { SimpleFeatureCollection collection = DataUtilities.collection(roadFeatures); assertEquals(roadFeatures.length, collection.size()); FeatureReader<SimpleFeatureType, SimpleFeature> reader = DataUtilities.reader(collection); assertEquals(roadFeatures.length, count(reader)); }
public void testGetFeatureStoreAddFeatures() throws IOException { FeatureReader<SimpleFeatureType, SimpleFeature> reader = DataUtilities.reader( new SimpleFeature[] { newRoad, }); SimpleFeatureStore road = (SimpleFeatureStore) data.getFeatureSource("road"); road.addFeatures(DataUtilities.collection(reader)); assertEquals(roadFeatures.length + 1, road.getFeatures().size()); }
protected void addFeature(SimpleFeatureType featureType, JDBCFeatureStore features) throws Exception { SimpleFeatureBuilder b = new SimpleFeatureBuilder(featureType); b.add("four"); b.add(new GeometryFactory().createPoint(new Coordinate(4, 4))); SimpleFeature f = b.buildFeature(null); features.addFeatures(DataUtilities.collection(f)); // pattern match to handle the multi primary key case assertTrue( ((String) f.getUserData().get("fid")) .matches(tname(featureType.getTypeName()) + ".4(\\..*)?")); }
protected void addFeature(SimpleFeatureType featureType, JDBCFeatureStore features) throws Exception { SimpleFeatureBuilder b = new SimpleFeatureBuilder(featureType); b.add("four"); b.add(new GeometryFactory().createPoint(new Coordinate(4, 4))); SimpleFeature f = b.buildFeature(null); features.addFeatures(DataUtilities.collection(f)); // pattern match to handle the multi primary key case assertTrue( ((String) f.getUserData().get("fid")) .matches(tname(featureType.getTypeName()) + ".4(\\..*)?")); }
public void testMemoryDataStoreAddFeatures() throws Exception { MemoryDataStore store = new MemoryDataStore(); assertNotNull(store); store.addFeatures(DataUtilities.collection(roadFeatures)); assertStoreHasFeatureType(store, "road"); SimpleFeatureSource featureSource = store.getFeatureSource("road"); SimpleFeatureCollection features = featureSource.getFeatures(); int size = features.size(); assertEquals(roadFeatures.length, size); } /*
public void testGetFeatureSourceRiver() throws NoSuchElementException, IOException { SimpleFeatureSource river = data.getFeatureSource("river"); assertSame(riverType, river.getSchema()); assertSame(data, river.getDataStore()); SimpleFeatureCollection all = river.getFeatures(); assertEquals(2, all.size()); assertEquals(riverBounds, all.getBounds()); assertTrue("rivers", covers(all.features(), riverFeatures)); SimpleFeatureCollection expected = DataUtilities.collection(riverFeatures); assertCovers("all", expected, all); assertEquals(riverBounds, all.getBounds()); }