new MemoryDataStore(new ForceCoordinateSystemFeatureReader(ilReader, crs)); featureSource = reTypedDS.getFeatureSource(typeName); } else { DataStore inlineFeatureDatastore = ul.getInlineFeatureDatastore();
FeatureSource[] sources(String... names) throws Exception { List<FeatureSource> sources = new ArrayList(); for (String name : names) { sources.add(mem.getFeatureSource(name)); } return sources.toArray(new FeatureSource[sources.size()]); }
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 testSetsEnvelopeCrsFromFeatureType() throws Exception { Query query = new Query(Query.ALL); CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); ReferencedEnvelope envelope = data.getFeatureSource("river").getBounds(query); assertEquals(sourceCRS, envelope.getCoordinateReferenceSystem()); }
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 testReprojectEnvelopeCrsFromQuery() throws Exception { Query query = new Query(Query.ALL); CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3005"); query.setCoordinateSystemReproject(targetCRS); ReferencedEnvelope envelope = data.getFeatureSource("river").getBounds(query); assertEquals(targetCRS, envelope.getCoordinateReferenceSystem()); assertEquals( new ReferencedEnvelope(riverBounds, sourceCRS).transform(targetCRS, true), envelope); }
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 testEmpty() throws Exception { SimpleFeatureType type = DataUtilities.createType( "namespace.typename", "name:String,id:0,geom:MultiLineString"); MemoryDataStore memory = new MemoryDataStore(type); FeatureSource<SimpleFeatureType, SimpleFeature> source = memory.getFeatureSource("typename"); assertEquals(0, source.getCount(Query.ALL)); }
public void testNoCrs() throws Exception { Query query = new Query(Query.ALL); ReferencedEnvelope envelope = data.getFeatureSource("road").getBounds(query); assertNull(envelope.getCoordinateReferenceSystem()); }
public void testGetFeatureStoreSetFeatures() throws IOException { FeatureReader<SimpleFeatureType, SimpleFeature> reader = DataUtilities.reader( new SimpleFeature[] { newRoad, }); SimpleFeatureStore road = (SimpleFeatureStore) data.getFeatureSource("road"); road.setFeatures(reader); assertEquals(1, road.getFeatures().size()); }
private SimpleFeatureCollection createTightUTurnLineCollection() throws Exception { GeometryFactory geomFac = new GeometryFactory(); CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84; MemoryDataStore data = new MemoryDataStore(); data.addFeature( createLineFeature( "TheUTurnLabel", crs, geomFac, 1, 2, 8.7, 2, 9, 2.1, 8.7, 2.2, 1, 2.2)); return data.getFeatureSource(Rendering2DTest.LINE).getFeatures(); }
public void testSetReprojectEnvelopeCrsFromQuery() throws Exception { Query query = new Query(Query.ALL); query.setCoordinateSystem(DefaultEngineeringCRS.GENERIC_2D); query.setCoordinateSystemReproject(DefaultEngineeringCRS.CARTESIAN_2D); ReferencedEnvelope envelope = data.getFeatureSource("river").getBounds(query); assertEquals(DefaultEngineeringCRS.CARTESIAN_2D, envelope.getCoordinateReferenceSystem()); assertEquals( new ReferencedEnvelope(riverBounds, DefaultEngineeringCRS.GENERIC_2D) .transform(DefaultEngineeringCRS.CARTESIAN_2D, true), envelope); }
public void testLockFeatures() throws IOException { FeatureLock lock = new FeatureLock("test", 3600); SimpleFeatureLocking road = (SimpleFeatureLocking) data.getFeatureSource("road"); road.setFeatureLock(lock); assertFalse(isLocked("road", "road.rd1")); road.lockFeatures(); assertTrue(isLocked("road", "road.rd1")); }
public void testGetBoundsSupportsFeaturesWithoutGeometry() throws Exception { SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(data.getSchema("road")); featureBuilder.init(roadFeatures[0]); featureBuilder.set("geom", null); SimpleFeature feature = featureBuilder.buildFeature("road.rd0"); data.addFeature(feature); SimpleFeatureSource road = data.getFeatureSource("road"); assertEquals(roadBounds, road.getBounds(Query.ALL)); }
public void testGetFeatureStoreModifyFeatures1() throws IOException { SimpleFeatureStore road = (SimpleFeatureStore) data.getFeatureSource("road"); AttributeDescriptor descriptor = roadType.getDescriptor("name"); road.modifyFeatures(descriptor.getName(), "changed", rd1Filter); SimpleFeatureCollection results = road.getFeatures(rd1Filter); assertEquals("changed", results.features().next().getAttribute("name")); }
public void testGetFeatureStoreModifyFeatures2() throws IOException { SimpleFeatureStore road = (SimpleFeatureStore) data.getFeatureSource("road"); AttributeDescriptor descriptor = roadType.getDescriptor("name"); road.modifyFeatures( new Name[] {descriptor.getName()}, new Object[] { "changed", }, rd1Filter); SimpleFeatureCollection results = road.getFeatures(rd1Filter); assertEquals("changed", results.features().next().getAttribute("name")); }
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)); }
private SimpleFeatureCollection createPointFeatureCollection() throws Exception { AttributeDescriptor[] types = new AttributeDescriptor[2]; GeometryFactory geomFac = new GeometryFactory(); CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84; MemoryDataStore data = new MemoryDataStore(); data.addFeature(createPointFeature(2, 2, "LongLabel1", crs, geomFac, types)); data.addFeature(createPointFeature(4, 4, "LongLabel2", crs, geomFac, types)); data.addFeature(createPointFeature(0, 4, "LongLabel3", crs, geomFac, types)); // data.addFeature(createPointFeature(2,0,"Label4",crs, geomFac, types)); data.addFeature(createPointFeature(2, 6, "LongLabel6", crs, geomFac, types)); return data.getFeatureSource(Rendering2DTest.POINT).getFeatures(); }
private SimpleFeatureCollection createPointFeatureCollection() throws Exception { AttributeDescriptor[] types = new AttributeDescriptor[2]; GeometryFactory geomFac = new GeometryFactory(); CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84; MemoryDataStore data = new MemoryDataStore(); data.addFeature(createPointFeature(2, 2, "LongLabel1", crs, geomFac, types)); data.addFeature(createPointFeature(4, 4, "LongLabel2", crs, geomFac, types)); data.addFeature(createPointFeature(0, 4, "LongLabel3", crs, geomFac, types)); // data.addFeature(createPointFeature(2,0,"Label4",crs, geomFac, types)); data.addFeature(createPointFeature(2, 6, "LongLabel6", crs, geomFac, types)); return data.getFeatureSource(Rendering2DTest.POINT).getFeatures(); }
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()); }