public T getSchema() { return delegate.getSchema(); }
@Override public FeatureType getFeatureType() throws IOException { return featureSource.getSchema(); }
/** * Retreives the bounds for a feature source. * * <p>If the feautre source can calculate the bounds directly, those bounds are returned. * Otherwise, the underlying feature collection is retreived and asked to calculate bounds. If * that fails, an empty envelope is returned. * * @param fs The feature source. * @return The bounds. * @throws IOException Execption calculating bounds on feature source. */ public static ReferencedEnvelope getBoundingBoxEnvelope( FeatureSource<? extends FeatureType, ? extends Feature> fs) throws IOException { ReferencedEnvelope ev = fs.getBounds(); if ((ev == null) || ev.isNull()) { try { ev = fs.getFeatures().getBounds(); } catch (Throwable t) { LOGGER.log( Level.FINE, "Could not compute the data bounding box. Returning an empty envelope", t); ev = new ReferencedEnvelope(fs.getSchema().getCoordinateReferenceSystem()); } } return ev; } }
if (crs == null) { if (data != null) { crs = data.getSchema().getCoordinateReferenceSystem(); } else { crs = ftinfo.getFeatureType().getCoordinateReferenceSystem();
@Override public FeatureType getSchema() { return originalFeatureSource.getSchema(); }
public SimpleFeatureType getSchema() { return delegate.getSchema(); }
@Test public void testMetadataFromFeatueSource() throws Exception { CatalogBuilder cb = new CatalogBuilder(getCatalog()); cb.setStore(cb.buildDataStore("fooStore")); FeatureType ft = createMock(FeatureType.class); expect(ft.getName()).andReturn(new NameImpl("foo")).anyTimes(); expect(ft.getCoordinateReferenceSystem()).andReturn(null).anyTimes(); expect(ft.getGeometryDescriptor()).andReturn(null).anyTimes(); replay(ft); ResourceInfo rInfo = createMock(ResourceInfo.class); expect(rInfo.getTitle()).andReturn("foo title"); expect(rInfo.getDescription()).andReturn("foo description"); expect(rInfo.getKeywords()) .andReturn(new LinkedHashSet<String>(Arrays.asList("foo", "bar", "baz", ""))) .anyTimes(); replay(rInfo); FeatureSource fs = createMock(FeatureSource.class); expect(fs.getSchema()).andReturn(ft).anyTimes(); expect(fs.getInfo()).andReturn(rInfo).anyTimes(); expect(fs.getName()).andReturn(ft.getName()).anyTimes(); replay(fs); FeatureTypeInfo ftInfo = cb.buildFeatureType(fs); assertEquals("foo title", ftInfo.getTitle()); assertEquals("foo description", ftInfo.getDescription()); assertTrue(ftInfo.getKeywords().contains(new Keyword("foo"))); assertTrue(ftInfo.getKeywords().contains(new Keyword("bar"))); assertTrue(ftInfo.getKeywords().contains(new Keyword("baz"))); }
FeatureType featureType = featureSource.getSchema();
@Override public CoordinateReferenceSystem getCRS() { return fs.getSchema().getCoordinateReferenceSystem(); }
public DefaultResourceInfo(FeatureSource fs) { this.fs = fs; words = new HashSet<String>(); { words.add("features"); words.add(fs.getSchema().getName().toString()); } }
@Override public URI getSchema() { Name name = fs.getSchema().getName(); URI namespace; try { namespace = new URI(name.getNamespaceURI()); return namespace; } catch (URISyntaxException e) { return null; } }
@Override public String getTitle() { Name name = fs.getSchema().getName(); return name.getLocalPart(); } }
@Override public String getName() { return fs.getSchema().getName().getLocalPart(); }
private FeatureChainLink(FeatureTypeMapping featureType) { if (featureType == null) { throw new NullPointerException("featureType is null"); } this.featureTypeMapping = featureType; this.nestedFeatureAttribute = null; this.chainingByReference = false; this.alias = featureType.getSource().getSchema().getName().getLocalPart(); this.nextStep = null; this.previousStep = null; }
/** * {@inheritDoc} The {@code layer} argument must be an instance of {@linkplain FeatureLayer}. */ @Override public void setLayer(Layer layer) { if (!(layer instanceof FeatureLayer)) { throw new IllegalArgumentException("layer must be an instance of FeatureLayer"); } super.setLayer(layer); GeometryDescriptor geomDesc = layer.getFeatureSource().getSchema().getGeometryDescriptor(); attrName = geomDesc.getLocalName(); Class<? extends Geometry> geomClass = (Class<? extends Geometry>) geomDesc.getType().getBinding(); geomType = Geometries.getForBinding(geomClass); }
/** * Convert query to retrieve only id field, no other fields * * @return converted Query */ protected Query transformQueryToIdsOnly() { Query idsQuery = new Query(unrollIndexes(query)); idsQuery.setProperties(getIndexQueryProperties()); idsQuery.setTypeName(mapping.getIndexSource().getSchema().getTypeName()); return idsQuery; }
private WrappedFilterToSql createFilterToSQL(FeatureTypeMapping featureMapping) { JDBCDataStore store = (JDBCDataStore) featureMapping.getSource().getDataStore(); SimpleFeatureType sourceType = (SimpleFeatureType) featureMapping.getSource().getSchema(); FilterToSQL filterToSQL = null; if (store.getSQLDialect() instanceof PreparedStatementSQLDialect) { PreparedFilterToSQL preparedFilterToSQL = store.createPreparedFilterToSQL(sourceType); // disable prepared statements to have literals actually encoded in the SQL preparedFilterToSQL.setPrepareEnabled(false); filterToSQL = preparedFilterToSQL; } else { filterToSQL = store.createFilterToSQL(sourceType); } return new WrappedFilterToSql(featureMapping, filterToSQL); }
@Test public void testGetFeatureSource() throws IOException { FeatureSource<FeatureType, Feature> complexSource = dataStore.getFeatureSource(targetName); assertNotNull(complexSource); assertEquals(targetType, complexSource.getSchema()); }
/** * Build the query for execute on index source partial Implementation manages pagination by * itself, so remove bounds from query * * @return Query */ @Override protected Query transformQueryToIdsOnly() { Query idsQuery = new Query(unrollIndexes(partialIQM.getIndexQuery())); idsQuery.setProperties(getIndexQueryProperties()); idsQuery.setTypeName(mapping.getIndexSource().getSchema().getTypeName()); idsQuery.setStartIndex(null); idsQuery.setMaxFeatures(Integer.MAX_VALUE); return idsQuery; }
public void testGetFeatureById() throws Exception { FeatureSource fsView = dataStore.getFeatureSource("riverReducedPk"); assertFalse(fsView instanceof FeatureStore); // the problem is actually in pk computation PrimaryKey pk = dataStore.getPrimaryKey((SimpleFeatureType) fsView.getSchema()); assertEquals("riverReducedPk", pk.getTableName()); assertEquals(1, pk.getColumns().size()); PrimaryKeyColumn col = pk.getColumns().get(0); assertEquals(aname("id"), col.getName()); assertTrue(Number.class.isAssignableFrom(col.getType())); FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); Id filter = ff.id(Collections.singleton(ff.featureId("riverReducedPk.0"))); assertEquals(1, fsView.getCount(new Query(null, filter))); }