@Override public List<Name> getNames() throws IOException { return delegate.getNames(); }
public List<Name> getNames() throws IOException { return delegate.getNames(); }
@Override public List<Name> getNames() throws IOException { return delegate.getNames(); }
public void testDataStore() throws IOException { SimpleFeatureSource features = DataUtilities.source(roadFeatures); Name name = features.getName(); String typeName = name.getLocalPart(); DataStore store = DataUtilities.dataStore(features); assertSame(features.getSchema(), store.getSchema(name)); assertSame(features.getSchema(), store.getSchema(typeName)); assertSame(features, store.getFeatureSource(name)); assertSame(features, store.getFeatureSource(typeName)); assertEquals(name, store.getNames().get(0)); assertEquals(typeName, store.getTypeNames()[0]); }
File = ...;//the shapefile Map<Object, Object> map = new HashMap<>(); map.put( "url", file.toURI().toURL() ); DataStore dataStore = DataStoreFinder.getDataStore(map); List<Name> names = dataStore.getNames(); SimpleFeatureSource featureSource = dataStore.getFeatureSource(names.get(0)); SimpleFeatureCollection collection = featureSource.getFeatures(filter); SpatialIndexFeatureCollection spatialCollection = new SpatialIndexFeatureCollection(collection); // Fast spatial Access SimpleFeatureSource source = DataUtilities.source( spatialCollection ); SimpleFeatureCollection features = source.getFeatures(); // use features.features();
/** * Executes the list operation on the provided data store. * * @return a list of all tables, or Optional.absent() if none were found */ @Override protected Optional<List<String>> _call() { if (dataStore == null) { throw new GeoToolsOpException(StatusCode.DATASTORE_NOT_DEFINED); } List<String> features = new ArrayList<String>(); boolean foundTable = false; List<Name> typeNames; try { typeNames = dataStore.getNames(); } catch (Exception e) { throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_NAMES); } for (Name typeName : typeNames) { foundTable = true; features.add(typeName.toString()); } if (!foundTable) { return Optional.absent(); } return Optional.of(features); }
/** * Executes the list operation on the provided data store. * * @return a list of all tables, or Optional.absent() if none were found */ @Override protected Optional<List<String>> _call() { if (dataStore == null) { throw new GeoToolsOpException(StatusCode.DATASTORE_NOT_DEFINED); } List<String> features = new ArrayList<String>(); boolean foundTable = false; List<Name> typeNames; try { typeNames = dataStore.getNames(); } catch (Exception e) { throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_NAMES); } for (Name typeName : typeNames) { foundTable = true; features.add(typeName.toString()); } if (!foundTable) { return Optional.absent(); } return Optional.of(features); }
public static SimpleFeature resourceToFeature(final URL filterResource) throws IOException { final Map<String, Object> map = new HashMap<>(); DataStore dataStore = null; map.put("url", filterResource); final SimpleFeature savedFilter; SimpleFeatureIterator sfi = null; try { dataStore = DataStoreFinder.getDataStore(map); if (dataStore == null) { LOGGER.error("Could not get dataStore instance, getDataStore returned null"); throw new IOException("Could not get dataStore instance, getDataStore returned null"); } // just grab the first feature and use it as a filter sfi = dataStore.getFeatureSource(dataStore.getNames().get(0)).getFeatures().features(); savedFilter = sfi.next(); } finally { if (sfi != null) { sfi.close(); } if (dataStore != null) { dataStore.dispose(); } } return savedFilter; }
List<Name> names = null; try { names = dataStore.getNames(); } catch (IOException e) { LOGGER.error("Unable to get feature tpes from datastore '" + input.getPath() + "'", e);
public static DataStoreFactorySpi createFactoryWithGetNamesException() throws Exception { DataStore testDataStore = mock(DataStore.class); when(testDataStore.getNames()).thenThrow(new IOException()); when(testDataStore.getTypeNames()).thenThrow(new RuntimeException()); when(testDataStore.getSchema(anyString())).thenThrow(new IOException()); final DataStoreFactorySpi factory = mock(DataStoreFactorySpi.class); when(factory.createDataStore(anyMapOf(String.class, Serializable.class))) .thenReturn(testDataStore); when(factory.canProcess(anyMapOf(String.class, Serializable.class))).thenReturn(true); return factory; }
public static DataStoreFactorySpi createFactoryWithGetNamesException() throws Exception { DataStore testDataStore = mock(DataStore.class); when(testDataStore.getNames()).thenThrow(new IOException()); when(testDataStore.getTypeNames()).thenThrow(new RuntimeException()); when(testDataStore.getSchema(anyString())).thenThrow(new IOException()); final DataStoreFactorySpi factory = mock(DataStoreFactorySpi.class); when(factory.createDataStore(anyMapOf(String.class, Serializable.class))) .thenReturn(testDataStore); when(factory.canProcess(anyMapOf(String.class, Serializable.class))).thenReturn(true); return factory; }
/** * 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); } }
/** Helper method that create a new table on DB to store resource informations */ private void createFeatureType(DataStore dataStore, boolean forceDelete) throws Exception { boolean exists = dataStore.getNames().contains(new NameImpl(STORE_SCHEMA_NAME)); // Schema exists if (exists) { // Delete of exist is required, and then create a new one if (forceDelete) { dataStore.removeSchema(STORE_SCHEMA_NAME); SimpleFeatureType schema = DataUtilities.createType(STORE_SCHEMA_NAME, STORE_SCHEMA); dataStore.createSchema(schema); } // Schema not exists, create a new one } else { SimpleFeatureType schema = DataUtilities.createType(STORE_SCHEMA_NAME, STORE_SCHEMA); dataStore.createSchema(schema); } }
typeNames = dataStore.getNames(); } catch (Exception e) { throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_NAMES);
typeNames = dataStore.getNames(); } catch (Exception e) { throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_NAMES);
dataStore.getFeatureSource(dataStore.getNames().get(0)).getFeatures();
List<Name> nameList = dataStore.getNames(); if (!nameList.isEmpty()) { typeName = nameList.get(0).getLocalPart();
AttributeDescriptor attrib = dataStore.getSchema(dataStore.getNames().get(0)) .getDescriptor(fidAttribute); if (attrib == null) {
AttributeDescriptor attrib = dataStore.getSchema(dataStore.getNames().get(0)) .getDescriptor(fidAttribute); if (attrib == null) {