/** * Implement getDataStore. * * <p>Description ... * * @see org.geotools.data.FeatureSource#getDataStore() */ public DataStore getDataStore() { return (DataStore) source.getDataStore(); }
public DataAccess<SimpleFeatureType, SimpleFeature> getDataStore() { return delegate.getDataStore(); }
this.typeMap = typeMap; this.store = new RetypingDataStore((DataStore) wrapped.getDataStore()) { @Override protected String transformFeatureTypeName(String originalName) {
@Test public void testGetTypeNamesCalls() throws Exception { SimpleFeatureType orig = createNiceMock(SimpleFeatureType.class); expect(orig.getTypeName()).andReturn("orig").anyTimes(); replay(orig); SimpleFeatureType wrapped = createNiceMock(SimpleFeatureType.class); expect(wrapped.getTypeName()).andReturn("wrapped").anyTimes(); replay(wrapped); // ensure that getTypeNames() never called DataStore ds = createMock(DataStore.class); SimpleFeatureSource fs = createMock(SimpleFeatureSource.class); expect(fs.getSchema()).andReturn(orig).anyTimes(); expect(fs.getDataStore()).andReturn(ds).anyTimes(); expect(fs.getFeatures(new Query(orig.getTypeName(), Filter.INCLUDE))) .andReturn(null) .once(); replay(fs); SimpleFeatureSource rts = RetypingFeatureSource.getRetypingSource(fs, wrapped); rts.getFeatures(); } }
/** * Implement getDataStore. * * <p>Description ... * * @return @see org.geotools.data.FeatureSource#getDataStore() */ public DataStore getDataStore() { return (DataStore) source.getDataStore(); }
public DataAccess<SimpleFeatureType, SimpleFeature> getDataStore() { // this is done on purpose to avoid crippling the shapefile renderer optimizations return fsource.getDataStore(); }
public DataStore getDataStore() { return (DataStore) wrapped.getDataStore(); }
DataStore rs = (DataStore) retyped.getDataStore(); assertEquals(1, rs.getTypeNames().length); assertEquals(BRIDGES.getLocalPart(), rs.getTypeNames()[0]);
@Test public void testSimpleRename() throws IOException { SimpleFeatureSource fs = store.getFeatureSource(BUILDINGS.getLocalPart()); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.init(fs.getSchema()); tb.setName("houses"); SimpleFeatureType target = tb.buildFeatureType(); SimpleFeatureSource retyped = RetypingFeatureSource.getRetypingSource(fs, target); assertTrue(retyped instanceof SimpleFeatureLocking); assertEquals(target, retyped.getSchema()); assertEquals(target, ((DataStore) retyped.getDataStore()).getSchema("houses")); assertEquals(target, retyped.getFeatures().getSchema()); SimpleFeatureIterator it = retyped.getFeatures().features(); SimpleFeature f = it.next(); it.close(); assertEquals(target, f.getType()); }
protected void delegateVisitor(FeatureVisitor visitor, ProgressListener progress) throws IOException { Name typeName = transformer.getSource().getName(); Query txQuery = transformer.transformQuery(query); source.getDataStore() .getFeatureSource(typeName) .getFeatures(txQuery) .accepts(visitor, progress); } }
/** * Retrieve a FeatureReader<SimpleFeatureType, SimpleFeature> for this Query * * @return FeatureReader<SimpleFeatureType, SimpleFeature> for this Query * @throws IOException If results could not be obtained */ public FeatureReader<SimpleFeatureType, SimpleFeature> reader() throws IOException { FeatureReader<SimpleFeatureType, SimpleFeature> reader; reader = ((DataStore) featureSource.getDataStore()) .getFeatureReader(query, getTransaction()); int maxFeatures = query.getMaxFeatures(); if (maxFeatures != Integer.MAX_VALUE) { reader = new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures); } if (transform != null) { reader = new ReprojectFeatureReader(reader, getSchema(), transform); } return reader; }
/** * Retrieve a FeatureReader<SimpleFeatureType, SimpleFeature> for the geometry attributes only, * designed for bounds computation */ protected FeatureReader<SimpleFeatureType, SimpleFeature> boundsReader() throws IOException { List attributes = new ArrayList(); SimpleFeatureType schema = featureSource.getSchema(); for (int i = 0; i < schema.getAttributeCount(); i++) { AttributeDescriptor at = schema.getDescriptor(i); if (at instanceof GeometryDescriptorImpl) attributes.add(at.getLocalName()); } DefaultQuery q = new DefaultQuery(query); q.setPropertyNames(attributes); FeatureReader<SimpleFeatureType, SimpleFeature> reader = ((DataStore) featureSource.getDataStore()).getFeatureReader(q, getTransaction()); int maxFeatures = query.getMaxFeatures(); if (maxFeatures == Integer.MAX_VALUE) { return reader; } else { return new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures); } }
public void testMaxfeaturesHandCount() throws Exception { DefaultQuery q = new DefaultQuery("roads"); q.setMaxFeatures(1); // mock up the feature source so that it'll return a count of -1 (too // expensive) // and then will return a reader FeatureReader<SimpleFeatureType, SimpleFeature> fr = createNiceMock(FeatureReader.class); expect(fr.hasNext()).andReturn(true).times(2).andReturn(false); replay(fr); DataStore ds = createMock(DataStore.class); expect(ds.getFeatureReader(q, Transaction.AUTO_COMMIT)).andReturn(fr); replay(ds); SimpleFeatureType type = DataUtilities.createType("roads", "_=the_geom:Point,FID:String,NAME:String"); SimpleFeatureSource fs = createMock(SimpleFeatureSource.class); expect(fs.getSchema()).andReturn(type).anyTimes(); expect(fs.getCount(q)).andReturn(-1); expect(fs.getDataStore()).andReturn(ds); replay(fs); DefaultFeatureResults results = new DefaultFeatureResults(fs, q); assertEquals(1, results.size()); } }
public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader( Query query, Transaction transaction) throws IOException { SimpleFeatureSource fs = getFeatureSourceFor(query); Query newQuery = getProxyObject(query, fs); DataAccess<SimpleFeatureType, SimpleFeature> access = fs.getDataStore(); if (access instanceof DataStore) { FeatureReader<SimpleFeatureType, SimpleFeature> backendReader = ((DataStore) access).getFeatureReader(newQuery, transaction); String backendGeometryPropertyName = getBackendGeometryName(fs); Generalization di = info.getGeneralizationForDistance(getRequestedDistance(query)); if (di != null) logDistanceInfo(di); return new PreGeneralizedFeatureReader( getSchema(), indexMapping.get(di == null ? 0.0 : di.getDistance()), backendReader, info.getGeomPropertyName(), backendGeometryPropertyName); } return null; }
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()); }
public void testGetFeatureSourceRiver() throws NoSuchElementException, IOException, IllegalAttributeException { SimpleFeatureSource river = dataStore.getFeatureSource(tname("river")); assertFeatureTypesEqual(td.riverType, river.getSchema()); assertSame(dataStore, river.getDataStore()); SimpleFeatureCollection all = river.getFeatures(); assertEquals(2, all.size()); // assertEquals(td.riverBounds, all.getBounds()); assertTrue(areReferencedEnvelopesEqual(td.riverBounds, all.getBounds())); assertTrue("rivers", covers(all.features(), td.riverFeatures)); SimpleFeatureCollection expected = DataUtilities.collection(td.riverFeatures); assertCovers("all", expected, all); // assertEquals(td.riverBounds, all.getBounds()); assertTrue(areReferencedEnvelopesEqual(td.riverBounds, all.getBounds())); }
@Test public void testGetDataStore() { assertSame(dataStore, pointsSource.getDataStore()); assertSame(dataStore, linesSource.getDataStore()); }
assertSame(dataStore, road.getDataStore());
assertSame(data, road.getDataStore()); assertEquals(3, road.getCount(Query.ALL)); assertEquals(new ReferencedEnvelope(1, 5, 0, 4, null), road.getBounds(Query.ALL));
public void testGetFeatureSourceRiver() throws NoSuchElementException, IOException, IllegalAttributeException { SimpleFeatureSource river = data.getFeatureSource("RIVER"); assertEquals(riverType, river.getSchema()); assertEquals(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()); }