/** * Returns the same name than the feature type (ie, {@code getSchema().getName()} to honor the * simple feature land common practice of calling the same both the Features produces and their * types * * @since 2.5 * @see FeatureSource#getName() */ public Name getName() { return getSchema().getName(); }
/** * This method changes the query object so that all propertyName references are resolved to * simple attribute names against the schema of the feature source. * * <p>For example, this method ensures that propertyName's such as "gml:name" are rewritten as * simply "name". */ protected Query resolvePropertyNames(Query query) { return DataUtilities.resolvePropertyNames(query, getSchema()); }
/** Transform provided filter; resolving property names */ protected Filter resolvePropertyNames(Filter filter) { return DataUtilities.resolvePropertyNames(filter, getSchema()); } /**
/** * Returns the feature type or schema matching the specified name. * * <p>This method calls through to <code>getFeatureSource(typeName).getSchema()</code> * * @see DataStore#getSchema(String) */ public final SimpleFeatureType getSchema(String typeName) throws IOException { ContentFeatureSource featureSource = getFeatureSource(typeName); return featureSource.getSchema(); }
public CoordinateReferenceSystem getCRS() { return ContentFeatureSource.this.getSchema().getCoordinateReferenceSystem(); }
public String getName() { return ContentFeatureSource.this.getSchema().getTypeName(); }
public URI getSchema() { Name name = ContentFeatureSource.this.getSchema().getName(); URI namespace; try { namespace = new URI(name.getNamespaceURI()); return namespace; } catch (URISyntaxException e) { return null; } }
public String getTitle() { Name name = ContentFeatureSource.this.getSchema().getName(); return name.getLocalPart(); } };
public boolean supportsSorting(SortBy[] sortAttributes) { if (queryCapabilities.supportsSorting(sortAttributes)) { // natively supported return true; } else { // check if we can use the merge-sort support return SortedFeatureReader.canSort(getSchema(), sortAttributes); } }
/** * Returns a reader for features specified by a particular filter. * * <p>This method calls through to {@link #getReader(Query)}. */ public final FeatureReader<SimpleFeatureType, SimpleFeature> getReader(Filter filter) throws IOException { return getReader(new Query(getSchema().getTypeName(), filter)); }
/** * Returns the feature collection for the features which match the specified filter. * * <p>This method calls through to {@link #getFeatures(Query)}. */ public final ContentFeatureCollection getFeatures(Filter filter) throws IOException { return getFeatures(new Query(getSchema().getTypeName(), filter)); }
public final ContentFeatureSource getView(Filter filter) throws IOException { return getView(new Query(getSchema().getTypeName(), filter)); }
public void testNaturalSortingAsc() throws Exception { Query q = new Query(featureSource.getSchema().getTypeName()); q.setSortBy(new SortBy[] {SortBy.NATURAL_ORDER}); try (SimpleFeatureIterator features = featureSource.getFeatures(q).features()) { String prevId = null; while (features.hasNext()) { String currId = features.next().getID(); if (prevId != null) assertTrue(prevId.compareTo(currId) <= 0); prevId = currId; } } }
public void testNaturalSortingdesc() throws Exception { Query q = new Query(featureSource.getSchema().getTypeName()); q.setSortBy(new SortBy[] {SortBy.REVERSE_ORDER}); try (SimpleFeatureIterator features = featureSource.getFeatures(q).features()) { String prevId = null; while (features.hasNext()) { String currId = features.next().getID(); if (prevId != null) assertTrue(prevId.compareTo(currId) >= 0); prevId = currId; } } }
public void testGetFeaturesWithMax() throws Exception { Query q = new Query(featureSource.getSchema().getTypeName()); q.setMaxFeatures(2); SimpleFeatureCollection features = featureSource.getFeatures(q); // check size assertEquals(2, features.size()); // check actual iteration try (SimpleFeatureIterator it = features.features()) { int count = 0; ReferencedEnvelope env = new ReferencedEnvelope(features.getSchema().getCoordinateReferenceSystem()); while (it.hasNext()) { SimpleFeature f = it.next(); env.expandToInclude(ReferencedEnvelope.reference(f.getBounds())); count++; } assertEquals(2, count); assertTrue(areReferencedEnvelopesEqual(env, features.getBounds())); } }
/** * Makes sure the datastore works when the renderer uses the typical rendering hints * * @throws Exception */ public void testRendererBehaviour() throws Exception { Query query = new Query(featureSource.getSchema().getTypeName()); query.setHints( new Hints( new Hints( Hints.JTS_COORDINATE_SEQUENCE_FACTORY, new LiteCoordinateSequenceFactory()))); SimpleFeatureCollection fc = featureSource.getFeatures(query); try (SimpleFeatureIterator fi = fc.features()) { while (fi.hasNext()) { fi.next(); } } }
public void testGetFeaturesWithOffsetLimit() throws Exception { Query q = new Query(featureSource.getSchema().getTypeName()); // no sorting, let's see if the database can use native one q.setStartIndex(1); q.setMaxFeatures(1); SimpleFeatureCollection features = featureSource.getFeatures(q); // check size assertEquals(1, features.size()); // check actual iteration try (SimpleFeatureIterator it = features.features()) { assertTrue(it.hasNext()); SimpleFeature f = it.next(); ReferencedEnvelope fe = ReferencedEnvelope.reference(f.getBounds()); assertEquals(1, ((Number) f.getAttribute(aname("intProperty"))).intValue()); assertFalse(it.hasNext()); // assertEquals(fe, features.getBounds()); assertTrue(areReferencedEnvelopesEqual(fe, features.getBounds())); } }
public void testSchema() throws Exception { if (!isGeographySupportAvailable()) { return; } SimpleFeatureType ft = dataStore.getFeatureSource(tname("geopoint")).getSchema(); assertNotNull(ft); assertTrue(ft.getDescriptor(aname("geo")) instanceof GeometryDescriptor); assertEquals(Point.class, ft.getDescriptor("geo").getType().getBinding()); int epsg = CRS.lookupEpsgCode( ((GeometryDescriptor) ft.getDescriptor(aname("geo"))) .getCoordinateReferenceSystem(), false); assertEquals(4326, epsg); }
public void testSchema() throws Exception { SimpleFeatureType schema = featureSource.getSchema(); assertEquals(tname("ft1"), schema.getTypeName()); assertEquals(dataStore.getNamespaceURI(), schema.getName().getNamespaceURI()); assertTrue(areCRSEqual(CRS.decode("EPSG:4326"), schema.getCoordinateReferenceSystem())); assertEquals(5, schema.getAttributeCount()); assertNotNull(schema.getDescriptor(aname("id"))); assertNotNull(schema.getDescriptor(aname("geometry"))); assertNotNull(schema.getDescriptor(aname("intProperty"))); assertNotNull(schema.getDescriptor(aname("stringProperty"))); assertNotNull(schema.getDescriptor(aname("doubleProperty"))); } }
public void testSchema() throws Exception { SimpleFeatureType schema = featureSource.getSchema(); assertEquals(tname("ft1"), schema.getTypeName()); assertEquals(dataStore.getNamespaceURI(), schema.getName().getNamespaceURI()); assertTrue(areCRSEqual(getWGS84(), schema.getCoordinateReferenceSystem())); assertEquals(4, schema.getAttributeCount()); assertNotNull(schema.getDescriptor(aname("geometry"))); assertNotNull(schema.getDescriptor(aname("intProperty"))); assertNotNull(schema.getDescriptor(aname("stringProperty"))); assertNotNull(schema.getDescriptor(aname("doubleProperty"))); }