org.geotools.data.DataStore Java Examples
The following examples show how to use
org.geotools.data.DataStore.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShpConnector.java From TripleGeo with GNU General Public License v3.0 | 6 votes |
/** * Loads the shape file from the configuration path and returns the * feature collection associated according to the configuration. * * @param shapePath with the path to the shapefile. * @param featureString with the featureString to filter. * * @return FeatureCollection with the collection of features filtered. */ private FeatureCollection getShapeFileFeatureCollection(String shapePath, String featureString) throws IOException { File file = new File(shapePath); // Create the map with the file URL to be passed to DataStore. Map map = new HashMap(); try { map.put("url", file.toURL()); } catch (MalformedURLException ex) { Logger.getLogger(ShpConnector.class.getName()).log(Level.SEVERE, null, ex); } if (map.size() > 0) { DataStore dataStore = DataStoreFinder.getDataStore(map); FeatureSource featureSource = dataStore.getFeatureSource(featureString); return featureSource.getFeatures(); } return null; }
Example #2
Source File: ShapeInMemFeatureModelTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { ClassLoader classloader = Thread.currentThread().getContextClassLoader(); URL url = classloader.getResource(SHAPE_FILE); DataStore dataStore = new ShapefileDataStore(url); featureModel = new ShapeInMemFeatureModel(dataStore, LAYER_NAME, 4326, converterService); featureModel.setLayerInfo(layerInfo); FeatureSource<SimpleFeatureType, SimpleFeature> fs = featureModel.getFeatureSource(); FeatureIterator<SimpleFeature> fi = fs.getFeatures().features(); feature = fi.next(); feature = fi.next(); feature = fi.next(); feature = fi.next(); feature = fi.next(); fi.close(); }
Example #3
Source File: GeoWaveFeatureSourceTest.java From geowave with Apache License 2.0 | 6 votes |
public void testPartial(final Populater populater, final String ext) throws CQLException, Exception { final String typeName = "GeoWaveFeatureSourceTest_p" + ext; final SimpleFeatureType type = DataUtilities.createType( typeName, "geometry:Geometry:srid=4326,pop:java.lang.Long,pid:String,when:Date"); final DataStore dataStore = createDataStore(); populater.populate(type, dataStore); final SimpleFeatureSource source = dataStore.getFeatureSource(typeName); final Query query = new Query( typeName, CQL.toFilter( "BBOX(geometry,42,28,44,30) and when during 2005-05-01T20:32:56Z/2005-05-29T21:32:56Z"), new String[] {"geometry", "when", "pid"}); final ReferencedEnvelope env = source.getBounds(query); assertEquals(43.454, env.getMaxX(), 0.0001); assertEquals(28.232, env.getMinY(), 0.0001); assertEquals(28.242, env.getMaxY(), 0.0001); assertEquals(2, source.getCount(query)); }
Example #4
Source File: MultiPolygons.java From amodeus with GNU General Public License v2.0 | 6 votes |
private static Set<MultiPolygon> initializeFrom(File shapeFile) throws IOException { URL shapeFileURL = shapeFile.toURI().toURL(); Map<String, URL> inputMap = new HashMap<>(); inputMap.put("url", shapeFileURL); DataStore dataStore = DataStoreFinder.getDataStore(inputMap); SimpleFeatureSource featureSource = dataStore.getFeatureSource(dataStore.getTypeNames()[0]); SimpleFeatureCollection collection = DataUtilities.collection(featureSource.getFeatures()); dataStore.dispose(); Set<MultiPolygon> polygons = new HashSet<>(); SimpleFeatureIterator iterator = collection.features(); while (iterator.hasNext()) polygons.add((MultiPolygon) iterator.next().getDefaultGeometry()); return polygons; }
Example #5
Source File: CreateExternalDataSource.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Connect to vector data source. * * @param typeName the type name * @param dataStore the data store * @throws IOException Signals that an I/O exception has occurred. */ private void connectToVectorDataSource(String typeName, DataStore dataStore) throws IOException { dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); if (schema.getCoordinateReferenceSystem() == null) { // No crs found to set a default and reload if (dataStore instanceof ShapefileDataStore) { ShapefileDataStore shapeFileDatastore = (ShapefileDataStore) dataStore; CoordinateReferenceSystem crs = JCRSChooser.showDialog( Localisation.getString( CreateExternalDataSource.class, "CRSPanel.title"), defaultCRS.getIdentifiers().iterator().next().toString()); if (crs != null) { shapeFileDatastore.forceSchemaCRS(crs); } source = dataStore.getFeatureSource(typeName); schema = source.getSchema(); } } dsInfo.setSchema(schema); determineGeometryType(schema.getGeometryDescriptor().getType()); }
Example #6
Source File: ShapeFileParser.java From GeoTriples with Apache License 2.0 | 6 votes |
public List<GeneralResultRow> getData(String tablename) throws Exception { if (cacheList.containsKey(tablename)) { return cacheList.get(tablename); } else if (cacheList.containsKey(tablename.replaceAll("_geometry", ""))) { return cacheList.get(tablename.replaceAll("_geometry", "")); } DataStore dataStore = null; List<GeneralResultRow> result = null; try { Map<String, URL> connect = new HashMap<String, URL>(); connect.put("url", shapefile.toURI().toURL()); dataStore = DataStoreFinder.getDataStore(connect); FeatureSource<?, ?> featureSource = dataStore.getFeatureSource(tablename .replaceAll("_geometry", "")); if (featureSource != null) { result = getData(featureSource); } } catch (Exception ex) { ex.printStackTrace(); } finally { dataStore.dispose(); } cacheList.put(tablename.replaceAll("_geometry", ""), result); return result; }
Example #7
Source File: ElasticDataStoreFactory.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
public DataStore createDataStore(RestClient client, RestClient proxyClient, Map<String, Serializable> params) throws IOException { final String indexName = (String) INDEX_NAME.lookUp(params); final String arrayEncoding = getValue(ARRAY_ENCODING, params); final boolean runAsGeoServerUser = getValue(RUNAS_GEOSERVER_USER, params); if (isForceRunas() && !runAsGeoServerUser) { throw new IllegalArgumentException(RUNAS_GEOSERVER_USER.key + " is disabled but " + FORCE_RUNAS_PROPERTY + " is set. " + "Enable " + RUNAS_GEOSERVER_USER.key + " or unset " + FORCE_RUNAS_PROPERTY + " in the system environment."); } final ElasticDataStore dataStore = new ElasticDataStore(client, proxyClient, indexName, runAsGeoServerUser); dataStore.setDefaultMaxFeatures(getValue(DEFAULT_MAX_FEATURES, params)); dataStore.setSourceFilteringEnabled(getValue(SOURCE_FILTERING_ENABLED, params)); dataStore.setScrollEnabled(getValue(SCROLL_ENABLED, params)); dataStore.setScrollSize(((Number)getValue(SCROLL_SIZE, params)).longValue()); dataStore.setScrollTime(getValue(SCROLL_TIME_SECONDS, params)); dataStore.setArrayEncoding(ArrayEncoding.valueOf(arrayEncoding.toUpperCase())); dataStore.setGridSize((Long) GRID_SIZE.lookUp(params)); dataStore.setGridThreshold((Double) GRID_THRESHOLD.lookUp(params)); return dataStore; }
Example #8
Source File: GeoMesaGeoIndexer.java From rya with Apache License 2.0 | 6 votes |
private static SimpleFeatureType getStatementFeatureType(final DataStore dataStore) throws IOException, SchemaException { SimpleFeatureType featureType; final String[] datastoreFeatures = dataStore.getTypeNames(); if (Arrays.asList(datastoreFeatures).contains(FEATURE_NAME)) { featureType = dataStore.getSchema(FEATURE_NAME); } else { final String featureSchema = SUBJECT_ATTRIBUTE + ":String," // + PREDICATE_ATTRIBUTE + ":String," // + OBJECT_ATTRIBUTE + ":String," // + CONTEXT_ATTRIBUTE + ":String," // + GEOMETRY_ATTRIBUTE + ":Geometry:srid=4326;geomesa.mixed.geometries='true'"; featureType = SimpleFeatureTypes.createType(FEATURE_NAME, featureSchema); dataStore.createSchema(featureType); } return featureType; }
Example #9
Source File: DatabaseClient.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Connect to datastore. * * @param dataStore the data store */ private void connectToDatastore(DataStore dataStore) { try { List<Name> nameList = dataStore.getNames(); if (nameList != null) { for (Name name : nameList) { if (hasGeometryField(dataStore, name)) { featureClassList.add(name.getLocalPart()); } } } dataStore.dispose(); connected = true; } catch (Exception e) { ConsoleManager.getInstance().exception(this, e); } }
Example #10
Source File: ElasticDatastoreFactoryTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Before public void setUp() throws IOException { dataStoreFactory = Mockito.spy(new ElasticDataStoreFactory()); clientBuilder = mock(RestClientBuilder.class); hostsCaptor = ArgumentCaptor.forClass(HttpHost[].class); Mockito.doReturn(clientBuilder).when(dataStoreFactory).createClientBuilder(hostsCaptor.capture()); final RestClient restClient = mock(RestClient.class); when(clientBuilder.build()).thenReturn(restClient); final DataStore dataStore = mock(DataStore.class); Mockito.doReturn(dataStore).when(dataStoreFactory).createDataStore(any(RestClient.class), any(), anyMap()); configCallbackCaptor = ArgumentCaptor.forClass(RestClientBuilder.HttpClientConfigCallback.class); when(clientBuilder.setHttpClientConfigCallback(configCallbackCaptor.capture())).thenReturn(clientBuilder); httpClientBuilder = mock(HttpAsyncClientBuilder.class); credentialsProviderCaptor = ArgumentCaptor.forClass(CredentialsProvider.class); when(httpClientBuilder.setDefaultCredentialsProvider(credentialsProviderCaptor.capture())).thenReturn(httpClientBuilder); threadFactoryCaptor = ArgumentCaptor.forClass(ThreadFactory.class); when(httpClientBuilder.setThreadFactory(threadFactoryCaptor.capture())).thenReturn(httpClientBuilder); requestConfigCallbackCaptor = ArgumentCaptor.forClass(RestClientBuilder.RequestConfigCallback.class); when(clientBuilder.setRequestConfigCallback(requestConfigCallbackCaptor.capture())).thenReturn(clientBuilder); requestConfigBuilder = mock(RequestConfig.Builder.class); when(requestConfigBuilder.setAuthenticationEnabled(true)).thenReturn(requestConfigBuilder); params = getParams("localhost", 9200, "admin", "proxy"); ElasticDataStoreFactory.httpThreads.set(1); }
Example #11
Source File: GeoMesaGeoIndexer.java From rya with Apache License 2.0 | 6 votes |
private void initInternal() throws IOException { validPredicates = ConfigUtils.getGeoPredicates(conf); final DataStore dataStore = createDataStore(conf); try { featureType = getStatementFeatureType(dataStore); } catch (final IOException | SchemaException e) { throw new IOException(e); } featureSource = dataStore.getFeatureSource(featureType.getName()); if (!(featureSource instanceof FeatureStore)) { throw new IllegalStateException("Could not retrieve feature store"); } featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource; }
Example #12
Source File: GeoWaveGeoIndexer.java From rya with Apache License 2.0 | 6 votes |
private static SimpleFeatureType getStatementFeatureType(final DataStore dataStore) throws IOException, SchemaException { SimpleFeatureType featureType; final String[] datastoreFeatures = dataStore.getTypeNames(); if (Arrays.asList(datastoreFeatures).contains(FEATURE_NAME)) { featureType = dataStore.getSchema(FEATURE_NAME); } else { featureType = DataUtilities.createType(FEATURE_NAME, SUBJECT_ATTRIBUTE + ":String," + PREDICATE_ATTRIBUTE + ":String," + OBJECT_ATTRIBUTE + ":String," + CONTEXT_ATTRIBUTE + ":String," + GEOMETRY_ATTRIBUTE + ":Geometry:srid=4326," + GEO_ID_ATTRIBUTE + ":String"); dataStore.createSchema(featureType); } return featureType; }
Example #13
Source File: GeoToolsFeatureModelTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Before public void init() throws Exception { ClassLoader classloader = Thread.currentThread().getContextClassLoader(); URL url = classloader.getResource(SHAPE_FILE); DataStore dataStore = new ShapefileDataStore(url); featureModel = new GeoToolsFeatureModel(dataStore, LAYER_NAME, 4326, converterService); featureModel.setLayerInfo(layerInfo); FeatureSource<SimpleFeatureType, SimpleFeature> fs = featureModel.getFeatureSource(); FeatureIterator<SimpleFeature> fi = fs.getFeatures().features(); feature = fi.next(); feature = fi.next(); feature = fi.next(); feature = fi.next(); feature = fi.next(); }
Example #14
Source File: GeoWaveGeoIndexer.java From rya with Apache License 2.0 | 6 votes |
/** * Creates the {@link DataStore} for the {@link GeoWaveGeoIndexer}. * @param conf the {@link Configuration}. * @return the {@link DataStore}. */ public DataStore createDataStore(final Configuration conf) throws IOException, GeoWavePluginException { final Map<String, Serializable> params = getParams(conf); final Instance instance = ConfigUtils.getInstance(conf); final boolean useMock = instance instanceof MockInstance; final StoreFactoryFamilySpi storeFactoryFamily; if (useMock) { storeFactoryFamily = new MemoryStoreFactoryFamily(); } else { storeFactoryFamily = new AccumuloStoreFactoryFamily(); } final GeoWaveGTDataStoreFactory geoWaveGTDataStoreFactory = new GeoWaveGTDataStoreFactory(storeFactoryFamily); final DataStore dataStore = geoWaveGTDataStoreFactory.createNewDataStore(params); return dataStore; }
Example #15
Source File: GeoWaveFeatureSourceTest.java From geowave with Apache License 2.0 | 5 votes |
@Override public void populate(final SimpleFeatureType type, final DataStore dataStore) throws IOException, CQLException, ParseException { dataStore.createSchema(type); final Transaction transaction1 = new DefaultTransaction(); final SimpleFeatureStore source = (SimpleFeatureStore) dataStore.getFeatureSource(type.getName()); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(type.getTypeName(), transaction1); assertFalse(writer.hasNext()); SimpleFeature newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(77)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-19T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232))); source.addFeatures(DataUtilities.collection(newFeature)); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(66)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-18T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 27.232))); source.addFeatures(DataUtilities.collection(newFeature)); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-17T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.242))); source.addFeatures(DataUtilities.collection(newFeature)); transaction1.commit(); transaction1.close(); }
Example #16
Source File: GeoToolsVectorDataStoreIngestPlugin.java From geowave with Apache License 2.0 | 5 votes |
@Override public boolean supportsFile(final URL file) { DataStore dataStore = null; try { dataStore = getDataStore(file); if (dataStore != null) { dataStore.dispose(); } } catch (final Exception e) { LOGGER.info("GeoTools was unable to read data source for file '" + file.getPath() + "'", e); } return dataStore != null; }
Example #17
Source File: DataSourceInfoTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.datasource.impl.DataSourceInfo#getPropertyDescriptorList()}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testGetPropertyDescriptorList() { URL url = SLDEditorFile.class .getClassLoader() .getResource("point/sld/shp/sld_cookbook_point.shp"); Map map = new HashMap(); map.put("url", url); DataStore dataStore; try { dataStore = DataStoreFinder.getDataStore(map); DataSourceInfo dsInfo = new DataSourceInfo(); String typeName = dataStore.getTypeNames()[0]; dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); assertNull(dsInfo.getPropertyDescriptorList()); dsInfo.setSchema(schema); Collection<PropertyDescriptor> fieldList = dsInfo.getPropertyDescriptorList(); assertTrue(fieldList.size() == 3); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #18
Source File: GeoWaveFeatureSourceTest.java From geowave with Apache License 2.0 | 5 votes |
@Override public void populate(final SimpleFeatureType type, final DataStore dataStore) throws IOException, CQLException, ParseException { dataStore.createSchema(type); final Transaction transaction1 = new DefaultTransaction(); final FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter(type.getTypeName(), transaction1); assertFalse(writer.hasNext()); SimpleFeature newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(77)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-19T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.232))); writer.write(); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(66)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-18T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 27.232))); writer.write(); newFeature = writer.next(); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("when", DateUtilities.parseISO("2005-05-17T20:32:56Z")); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(43.454, 28.242))); writer.write(); writer.close(); transaction1.commit(); transaction1.close(); }
Example #19
Source File: GeoWaveFeatureSourceTest.java From geowave with Apache License 2.0 | 5 votes |
public void testEmpty() throws Exception { final SimpleFeatureType type = DataUtilities.createType( "GeoWaveFeatureSourceTest_e", "geometry:Geometry:srid=4326,pop:java.lang.Long,pid:String,when:Date"); final DataStore dataStore = createDataStore(); dataStore.createSchema(type); final SimpleFeatureSource source = dataStore.getFeatureSource("GeoWaveFeatureSourceTest_e"); final ReferencedEnvelope env = source.getBounds(); assertEquals(90.0, env.getMaxX(), 0.0001); assertEquals(-180.0, env.getMinY(), 0.0001); final Query query = new Query("GeoWaveFeatureSourceTest_e", Filter.INCLUDE); assertEquals(0, source.getCount(query)); }
Example #20
Source File: GeoWaveGTDataStoreFactory.java From geowave with Apache License 2.0 | 5 votes |
@Override public DataStore createNewDataStore(final Map<String, Serializable> params) throws IOException { final GeoWaveGTDataStore dataStore; try { dataStore = new GeoWaveGTDataStore(new GeoWavePluginConfig(geowaveStoreFactoryFamily, params)); dataStoreCache.add(new DataStoreCacheEntry(params, dataStore)); } catch (final Exception ex) { throw new IOException("Error initializing datastore", ex); } return dataStore; }
Example #21
Source File: SimpleFeatureGeoWaveWrapper.java From geowave with Apache License 2.0 | 5 votes |
public SimpleFeatureGeoWaveWrapper( final List<SimpleFeatureCollection> featureCollections, final String[] indexNames, final String visibility, final DataStore dataStore, final RetypingVectorDataPlugin retypingPlugin, final Filter filter) { this.featureCollections = featureCollections; this.visibility = visibility; this.indexNames = indexNames; this.dataStore = dataStore; this.retypingPlugin = retypingPlugin; this.filter = filter; }
Example #22
Source File: ElasticDataStoreIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGetNamesByAlias() throws IOException { Map<String,Serializable> params = createConnectionParams(); params.put(ElasticDataStoreFactory.INDEX_NAME.key, indexName + "_alias"); ElasticDataStoreFactory factory = new ElasticDataStoreFactory(); DataStore dataStore = factory.createDataStore(params); String[] typeNames = dataStore.getTypeNames(); assertTrue(typeNames.length > 0); }
Example #23
Source File: ElasticDataStoreIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testConstructionWithHostAndPortAndIndex() throws IOException { Map<String,Serializable> params = createConnectionParams(); String host = ElasticDataStoreFactory.getValue(ElasticDataStoreFactory.HOSTNAME, params); Integer port = ElasticDataStoreFactory.getValue(ElasticDataStoreFactory.HOSTPORT, params); String indexName = ElasticDataStoreFactory.getValue(ElasticDataStoreFactory.INDEX_NAME, params); DataStore dataStore = new ElasticDataStore(host, port, indexName); String[] typeNames = dataStore.getTypeNames(); assertTrue(typeNames.length > 0); }
Example #24
Source File: GeoToolsLayer.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Override public DataStore getDataStore() { if (!featureModelUsable) { retryInitFeatures(); } return super.getDataStore(); }
Example #25
Source File: ElasticDataStoreFactory.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Override public DataStore createDataStore(Map<String, Serializable> params) throws IOException { final String user = getValue(USER, params); final String passwd = getValue(PASSWD, params); final String proxyUser = getValue(PROXY_USER, params); final String proxyPasswd = getValue(PROXY_PASSWD, params); final RestClient client = createRestClient(params, user, passwd); final RestClient proxyClient = proxyUser != null ? createRestClient(params, proxyUser, proxyPasswd) : null; return createDataStore(client, proxyClient, params); }
Example #26
Source File: GamaSqlConnection.java From gama with GNU General Public License v3.0 | 5 votes |
public DataStore Connect(final IScope scope) throws Exception { final Map<String, Object> connectionParameters = createConnectionParams(scope); DataStore dStore; dStore = DataStoreFinder.getDataStore(connectionParameters); // get // connection // DEBUG.LOG("data store postgress:" + dStore); if (dStore == null) { throw new IOException("Can't connect to " + database); } return dStore; }
Example #27
Source File: DataSourceInfoTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getGeometryFieldName()}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testGetGeometryFieldName() { URL url = SLDEditorFile.class .getClassLoader() .getResource("point/sld/shp/sld_cookbook_point.shp"); Map map = new HashMap(); map.put("url", url); DataStore dataStore; try { dataStore = DataStoreFinder.getDataStore(map); DataSourceInfo dsInfo = new DataSourceInfo(); String typeName = dataStore.getTypeNames()[0]; dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); assertNull(dsInfo.getGeometryFieldName()); dsInfo.setSchema(schema); assertEquals("the_geom", dsInfo.getGeometryFieldName()); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #28
Source File: DataSourceInfoTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatureStore()}. Test * method for {@link * com.sldeditor.datasource.impl.DataSourceInfo#setSchema(org.opengis.feature.type.FeatureType)}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testGetFeatureStore() { URL url = SLDEditorFile.class .getClassLoader() .getResource("point/sld/shp/sld_cookbook_point.shp"); Map map = new HashMap(); map.put("url", url); DataStore dataStore; try { dataStore = DataStoreFinder.getDataStore(map); DataSourceInfo dsInfo = new DataSourceInfo(); String typeName = dataStore.getTypeNames()[0]; dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); dsInfo.setSchema(schema); assertNull(dsInfo.getFeatureStore()); dsInfo.setDataStore(dataStore); FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = dsInfo.getFeatureStore(); assertTrue(featureStore != null); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #29
Source File: DataSourceInfoTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatureCollection()}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testGetFeatureCollection() { URL url = SLDEditorFile.class .getClassLoader() .getResource("point/sld/shp/sld_cookbook_point.shp"); Map map = new HashMap(); map.put("url", url); DataStore dataStore; try { dataStore = DataStoreFinder.getDataStore(map); DataSourceInfo dsInfo = new DataSourceInfo(); String typeName = dataStore.getTypeNames()[0]; dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); assertNull(dsInfo.getGeometryFieldName()); dsInfo.setSchema(schema); assertEquals("the_geom", dsInfo.getGeometryFieldName()); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #30
Source File: DataSourceInfoTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatures()}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testGetFeatures() { URL url = SLDEditorFile.class .getClassLoader() .getResource("point/sld/shp/sld_cookbook_point.shp"); Map map = new HashMap(); map.put("url", url); DataStore dataStore; try { dataStore = DataStoreFinder.getDataStore(map); DataSourceInfo dsInfo = new DataSourceInfo(); String typeName = dataStore.getTypeNames()[0]; dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); assertNull(dsInfo.getFeatures()); dsInfo.setSchema(schema); assertNull(dsInfo.getFeatures()); dsInfo.setDataStore(dataStore); assertTrue(dsInfo.getFeatures() != null); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }