public FeatureSource<T, F> getFeatureSource(Name typeName) throws IOException { return delegate.getFeatureSource(typeName); }
/** * Builds a {@link FeatureTypeInfo} from the current datastore and the specified type name * * <p>The resulting object is not added to the catalog, it must be done by the calling code * after the fact. */ public FeatureTypeInfo buildFeatureType(Name typeName) throws Exception { if (store == null || !(store instanceof DataStoreInfo)) { throw new IllegalStateException("Data store not set."); } DataStoreInfo dstore = (DataStoreInfo) store; return buildFeatureType(dstore.getDataStore(null).getFeatureSource(typeName)); }
public SimpleFeatureSource getFeatureSource(Name typeName) throws IOException { return DataUtilities.simple(delegate.getFeatureSource(typeName)); }
return dataAccess.getFeatureSource(info.getQualifiedName());
@Test public void testLookupSRSDetached() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); DataStoreInfo sf = cat.getDataStoreByName("sf"); FeatureSource fs = sf.getDataStore(null).getFeatureSource(toName(MockData.PRIMITIVEGEOFEATURE)); FeatureTypeInfo ft = cat.getFactory().createFeatureType(); ft.setNativeName("PrimitiveGeoFeature"); assertNull(ft.getSRS()); assertNull(ft.getCRS()); cb.lookupSRS(ft, fs, true); assertNotNull(ft.getSRS()); assertNotNull(ft.getCRS()); }
@Override public SimpleFeatureSource getFeatureSource(String typeName) throws IOException { // simple case, no lookups needed if (delegate instanceof DataStore) { return ((DataStore) delegate).getFeatureSource(typeName); } Name name = getNameFromLocal(typeName); return DataUtilities.simple(delegate.getFeatureSource(name)); }
@Test public void testSetupBoundsDetached() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); DataStoreInfo sf = cat.getDataStoreByName("sf"); FeatureSource fs = sf.getDataStore(null).getFeatureSource(toName(MockData.PRIMITIVEGEOFEATURE)); FeatureTypeInfo ft = cat.getFactory().createFeatureType(); ft.setNativeName("PrimitiveGeoFeature"); assertNull(ft.getNativeBoundingBox()); assertNull(ft.getLatLonBoundingBox()); cb.lookupSRS(ft, fs, true); cb.setupBounds(ft, fs); assertNotNull(ft.getNativeBoundingBox()); assertNotNull(ft.getLatLonBoundingBox()); }
/** * Get a feature source for built features with supplied feature type name. * * @param featureTypeName * @return feature source * @throws IOException */ public synchronized FeatureSource<FeatureType, Feature> featureSource(Name name) throws IOException { for (DataAccess<FeatureType, Feature> dataAccess : registry) { if (dataAccess.getNames().contains(name)) { if (dataAccess instanceof AppSchemaDataAccess) { return ((AppSchemaDataAccess) dataAccess).getFeatureSourceByName(name); } else { return dataAccess.getFeatureSource(name); } } } throwDataSourceException(name); return null; }
private FeatureSource<FeatureType, Feature> getFeatureSource( TypeMapping dto, Map<String, DataAccess<FeatureType, Feature>> sourceDataStores) throws IOException { String dsId = dto.getSourceDataStore(); String typeName = dto.getSourceTypeName(); DataAccess<FeatureType, Feature> sourceDataStore = sourceDataStores.get(dsId); if (sourceDataStore == null) { throw new DataSourceException( "datastore " + dsId + " not found for type mapping " + dto); } AppSchemaDataAccessConfigurator.LOGGER.fine( "asking datastore " + sourceDataStore + " for source type " + typeName); Name name = Types.degloseName(typeName, namespaces); FeatureSource fSource = sourceDataStore.getFeatureSource(name); if (fSource instanceof XmlFeatureSource) { ((XmlFeatureSource) fSource).setNamespaces(namespaces); } AppSchemaDataAccessConfigurator.LOGGER.fine("found feature source for " + typeName); return fSource; }
@Before public void setUp() throws Exception { factory = new AppSchemaDataAccessFactory(); params = new HashMap(); params.put("dbtype", "app-schema"); URL resource = getClass().getResource(schemaBase + "stationsIndexed.xml"); if (resource == null) { fail("Can't find resouce " + schemaBase + "stationsIndexed.xml"); } params.put("url", resource); dataStore = factory.createDataStore(params); mappedSource = (MappingFeatureSource) dataStore.getFeatureSource(mappedTypeName); }
protected void setUp() { factory = new AppSchemaDataAccessFactory(); params = new HashMap(); params.put("dbtype", "app-schema"); URL resource = getClass().getResource(schemaBase + filename); if (resource == null) { fail("Can't find resouce " + schemaBase + filename); } params.put("url", resource); try { dataStore = factory.createDataStore(params); mappedSource = (MappingFeatureSource) dataStore.getFeatureSource(mappedTypeName); } catch (IOException ex) { throw new RuntimeException(ex); } }
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); } }
/** * Load all the data accesses. * * @return * @throws Exception */ private static void loadDataAccesses() throws Exception { /** Load mapped feature data access */ Map dsParams = new HashMap(); URL url = PolymorphicChainingTest.class.getResource(schemaBase + "artifact_mapping.xml"); assertNotNull(url); dsParams.put("dbtype", "app-schema"); dsParams.put("url", url.toExternalForm()); DataAccess<FeatureType, Feature> mfDataAccess = DataAccessFinder.getDataStore(dsParams); assertNotNull(mfDataAccess); FeatureType mappedFeatureType = mfDataAccess.getSchema(ARTIFACT); assertNotNull(mappedFeatureType); artifactSource = (FeatureSource) mfDataAccess.getFeatureSource(ARTIFACT); }
@BeforeClass public static void onetimeSetUp() throws Exception { final String GSML_URI = "urn:cgi:xmlns:CGI:GeoSciML:2.0"; /** Set up filter factory */ NamespaceSupport namespaces = new NamespaceSupport(); namespaces.declarePrefix("gsml", GSML_URI); namespaces.declarePrefix("gml", "http://www.opengis.net/gml"); ff = new FilterFactoryImplNamespaceAware(namespaces); /** Load data access */ final Name FEATURE_TYPE = Types.typeName(GSML_URI, "MappedFeature"); final String schemaBase = "/test-data/"; Map<String, Serializable> dsParams = new HashMap<String, Serializable>(); dsParams.put("dbtype", "app-schema"); URL url = BBoxTest.class.getResource(schemaBase + "MappedFeatureAsOccurrence.xml"); assertNotNull(url); dsParams.put("url", url.toExternalForm()); dataAccess = DataAccessFinder.getDataStore(dsParams); fSource = (FeatureSource<FeatureType, Feature>) dataAccess.getFeatureSource(FEATURE_TYPE); }
/** * Load all the data accesses. * * @return * @throws Exception */ private static void loadDataAccesses() throws Exception { /** Load observation data access */ Map dsParams = new HashMap(); URL url = SweValuesTest.class.getResource(SWE_VALUES_MAPPING); assertNotNull(url); dsParams.put("dbtype", "app-schema"); dsParams.put("url", url.toExternalForm()); DataAccess<FeatureType, Feature> omsoDataAccess = DataAccessFinder.getDataStore(dsParams); assertNotNull(omsoDataAccess); FeatureType observationFeatureType = omsoDataAccess.getSchema(OBSERVATION_FEATURE); assertNotNull(observationFeatureType); obsSource = (FeatureSource) omsoDataAccess.getFeatureSource(OBSERVATION_FEATURE); obsFeatures = (FeatureCollection) obsSource.getFeatures(); assertEquals(2, size(obsFeatures)); }
@Before public void setUp() throws Exception { /** Set up filter factory */ NamespaceSupport namespaces = new NamespaceSupport(); namespaces.declarePrefix("ex", "http://example.com"); namespaces.declarePrefix("gml", "http://www.opengis.net/gml"); ff = new FilterFactoryImplNamespaceAware(namespaces); /** Load data access */ final Name EXAMPLE_TYPE = Types.typeName("http://example.com", "FirstParentFeature"); final String schemaBase = "/test-data/"; Map dsParams = new HashMap(); dsParams.put("dbtype", "app-schema"); URL url = getClass().getResource(schemaBase + "VocabFunctionsTest.xml"); assertNotNull(url); dsParams.put("url", url.toExternalForm()); dataAccess = DataAccessFinder.getDataStore(dsParams); FeatureSource<FeatureType, Feature> fSource = (FeatureSource) dataAccess.getFeatureSource(EXAMPLE_TYPE); exCollection = (FeatureCollection<FeatureType, Feature>) fSource.getFeatures(); assertEquals(3, size(exCollection)); }
/** @throws IOException */ @Test public void testFactoryLookup() throws IOException { DataAccess<FeatureType, Feature> ds = DataAccessFinder.getDataStore(params); assertNotNull(ds); assertTrue(ds instanceof AppSchemaDataAccess); FeatureSource<FeatureType, Feature> mappedSource = ds.getFeatureSource(mappedTypeName); assertNotNull(mappedSource); ds.dispose(); }
/** @throws IOException */ @Test public void testCreateDataStore() throws IOException { DataAccess<FeatureType, Feature> ds = factory.createDataStore(params); assertNotNull(ds); FeatureSource<FeatureType, Feature> mappedSource = ds.getFeatureSource(mappedTypeName); assertNotNull(mappedSource); assertSame(ds, mappedSource.getDataStore()); ds.dispose(); }
/** * Test that getting features from a feature source with a query honours the namespace. * * @throws Exception */ @Test public void testFeatureSourceHonoursQueryNamespace() throws Exception { final Name typeName = Types.typeName(GSMLNS, "MappedFeature"); FeatureSource<FeatureType, Feature> source = mappingDataStore.getFeatureSource(typeName); DefaultQuery query = new DefaultQuery(); query.setNamespace(new URI(typeName.getNamespaceURI())); query.setTypeName(typeName.getLocalPart()); FeatureCollection<FeatureType, Feature> features = source.getFeatures(query); assertNotNull(features); assertEquals(2, size(features)); }
/** * Grab a feature and traverse it in deep as an encoder might do * * @throws Exception */ @Test public void testTraverseDeep() throws Exception { final FeatureSource<FeatureType, Feature> fSource = (FeatureSource<FeatureType, Feature>) mappingDataStore.getFeatureSource(typeName); final String queryProperty = "sa:shape/geo:LineByVector/geo:origin/@xlink:href"; final String queryLiteral = "#bh.176909a.start"; NamespaceSupport namespaces = new NamespaceSupport(); namespaces.declarePrefix("sa", SANS); namespaces.declarePrefix("geo", GEONS); namespaces.declarePrefix("xlink", XLINK.NAMESPACE); FeatureCollection<FeatureType, Feature> features = (FeatureCollection) fSource.getFeatures(); Feature f = (Feature) features.features().next(); traverse(f); }