use of org.geotools.data.DataStore in project incubator-rya by apache.
the class GeoWaveGeoIndexer method createDataStore.
/**
* 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;
}
use of org.geotools.data.DataStore in project graphhopper by graphhopper.
the class ShapeFileReader method openShapefileDataStore.
protected DataStore openShapefileDataStore(File file) {
try {
Map<String, Object> map = new HashMap<String, Object>();
map.put("url", file.toURI().toURL());
DataStore ds = DataStoreFinder.getDataStore(map);
if (ds == null)
throw new IllegalArgumentException("Cannot find DataStore at " + file);
return ds;
} catch (Exception e) {
throw Utils.asUnchecked(e);
}
}
use of org.geotools.data.DataStore in project GeoGig by boundlessgeo.
the class GeoGigDataStoreFactoryTest method testDataStoreFinder.
@Test
public void testDataStoreFinder() throws Exception {
Map<String, ? extends Serializable> params;
DataStore dataStore;
params = ImmutableMap.of();
dataStore = DataStoreFinder.getDataStore(params);
assertNull(dataStore);
params = ImmutableMap.of(REPOSITORY.key, repoDirectory);
dataStore = DataStoreFinder.getDataStore(params);
assertNotNull(dataStore);
assertTrue(dataStore instanceof GeoGigDataStore);
}
use of org.geotools.data.DataStore in project GeoGig by boundlessgeo.
the class SLImport method runInternal.
/**
* Executes the import command using the provided options.
*/
@Override
protected void runInternal(GeogigCLI cli) throws IOException {
DataStore dataStore = getDataStore();
try {
cli.getConsole().println("Importing from database " + commonArgs.database);
ProgressListener progressListener = cli.getProgressListener();
cli.getGeogig().command(ImportOp.class).setAll(all).setTable(table).setAlter(alter).setOverwrite(!add).setDataStore(dataStore).setAdaptToDefaultFeatureType(!forceFeatureType).setProgressListener(progressListener).call();
cli.getConsole().println("Import successful.");
} catch (GeoToolsOpException e) {
switch(e.statusCode) {
case TABLE_NOT_DEFINED:
throw new CommandFailedException("No tables specified for import. Specify --all or --table <table>.", e);
case ALL_AND_TABLE_DEFINED:
throw new CommandFailedException("Specify --all or --table <table>, both cannot be set.", e);
case NO_FEATURES_FOUND:
throw new CommandFailedException("No features were found in the database.", e);
case TABLE_NOT_FOUND:
throw new CommandFailedException("Could not find the specified table.", e);
case UNABLE_TO_GET_NAMES:
throw new CommandFailedException("Unable to get feature types from the database.", e);
case UNABLE_TO_GET_FEATURES:
throw new CommandFailedException("Unable to get features from the database.", e);
case UNABLE_TO_INSERT:
throw new CommandFailedException("Unable to insert features into the working tree.", e);
case INCOMPATIBLE_FEATURE_TYPE:
throw new CommandFailedException("The feature type of the data to import does not match the feature type of the destination tree and cannot be imported\n" + "USe the --force-featuretype switch to import using the original featuretype and crete a mixed type tree", e);
case ALTER_AND_ALL_DEFINED:
throw new CommandFailedException("Alter cannot be used with --all option and more than one table.", e);
default:
throw new CommandFailedException("Import failed with exception: " + e.statusCode.name(), e);
}
} finally {
dataStore.dispose();
cli.getConsole().flush();
}
}
use of org.geotools.data.DataStore in project GeoGig by boundlessgeo.
the class SLList method runInternal.
/**
* Executes the list command using the provided options.
*/
@Override
protected void runInternal(GeogigCLI cli) throws IOException {
DataStore dataStore = getDataStore();
try {
cli.getConsole().println("Fetching feature types...");
Optional<List<String>> features = cli.getGeogig().command(ListOp.class).setDataStore(dataStore).call();
if (features.isPresent()) {
for (String featureType : features.get()) {
cli.getConsole().println(" - " + featureType);
}
} else {
throw new CommandFailedException("No features types were found in the specified database.");
}
} catch (GeoToolsOpException e) {
throw new CommandFailedException("Unable to get feature types from the database.", e);
} finally {
dataStore.dispose();
cli.getConsole().flush();
}
}
Aggregations