本文整理匯總了Java中org.geotools.data.DataStore類的典型用法代碼示例。如果您正苦於以下問題:Java DataStore類的具體用法?Java DataStore怎麽用?Java DataStore使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DataStore類屬於org.geotools.data包,在下文中一共展示了DataStore類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: read
import org.geotools.data.DataStore; //導入依賴的package包/類
public void read(URL file) throws IOException {
Map<String, Object> map = new HashMap<>();
map.put("url", file);
DataStore dataStore = DataStoreFinder.getDataStore(map);
String typeName = dataStore.getTypeNames()[0];
FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(typeName);
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures();
FeatureIterator<SimpleFeature> features = collection.features();
int count = 0;
LOGGER.info("reading world time zones ...");
while (features.hasNext()) {
count++;
SimpleFeature feature = features.next();
ReferencedEnvelope referencedEnvelope = new ReferencedEnvelope(feature.getBounds());
quadtree.insert(referencedEnvelope,feature);
}
LOGGER.info(count + " features read");
}
示例2: Connect
import org.geotools.data.DataStore; //導入依賴的package包/類
public DataStore Connect(final IScope scope) throws Exception {
Map<String, Object> connectionParameters = new HashMap<String, Object>();
connectionParameters = createConnectionParams(scope);
DataStore dStore;
dStore = DataStoreFinder.getDataStore(connectionParameters); // get
// connection
// System.out.println("data store postgress:" + dStore);
if (dStore == null) { throw new IOException("Can't connect to " + database); }
return dStore;
}
示例3: testLoadShapeFile
import org.geotools.data.DataStore; //導入依賴的package包/類
/**
* Test if shapeRDD get correct number of shapes from .shp file
* @throws IOException
*/
@Test
public void testLoadShapeFile() throws IOException {
// load shape with geotool.shapefile
InputLocation = ShapefileRDDTest.class.getClassLoader().getResource("shapefiles/polygon").getPath();
File file = new File(InputLocation);
Map<String, Object> map = new HashMap<String, Object>();
map.put("url", file.toURI().toURL());
DataStore dataStore = DataStoreFinder.getDataStore(map);
String typeName = dataStore.getTypeNames()[0];
FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore
.getFeatureSource(typeName);
Filter filter = Filter.INCLUDE;
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures(filter);
// load shapes with our tool
ShapefileRDD shapefileRDD = new ShapefileRDD(sc,InputLocation);
Assert.assertEquals(shapefileRDD.getShapeRDD().collect().size(), collection.size());
dataStore.dispose();
}
示例4: saveAll
import org.geotools.data.DataStore; //導入依賴的package包/類
/**
* Method to store analysed image params in a table on the DDBB for posterior data mining
*
* @param layer
* @param projection
* @param imageCis
*/
public void saveAll(GeometryImage layer, String projection, Object[] imageCis,GeoImageReader gir) {
try {
//Data store to get access to ddbb
DataStore datastore = (DataStore) DataStoreFinder.getDataStore(config);
//Access to the corresponding Imagery table on ddbb
FeatureStore featurestore = (FeatureStore) datastore.getFeatureSource(imageCis[0].toString());
SimpleFeatureType featuretype = (SimpleFeatureType) featurestore.getSchema();
FeatureCollection features = createTabFeatures(featuretype,imageCis);
featurestore.addFeatures(features);
writeToDB(datastore, features);
datastore.dispose();
// store extracted VDS points
save(null,projection,((SarImageReader)gir).getGeoTransform());
} catch (Exception ex) {
logger.error(ex.getMessage(),ex);
}
}
示例5: exportFeaturesToShapeFile
import org.geotools.data.DataStore; //導入依賴的package包/類
public static void exportFeaturesToShapeFile(File fileOutput,FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection){
DataStore data =null;
try {
if (!fileOutput.exists()){
fileOutput.createNewFile();
fileOutput.setWritable(true);
}
FileDataStoreFactorySpi factory = new ShapefileDataStoreFactory();
data = factory.createDataStore( fileOutput.toURI().toURL() );
data.createSchema(featureCollection.getSchema());
exportToShapefile(data,featureCollection);
} catch (Exception e) {
logger.error("Export to shapefile failed",e );
}finally{
if(data!=null)
data.dispose();
}
}
示例6: run
import org.geotools.data.DataStore; //導入依賴的package包/類
public static int run(String[] args) throws Exception {
CommandLineParser parser = new BasicParser();
Options options = getCommonRequiredOptions();
CommandLine cmd = parser.parse( options, args);
Map<String, String> dsConf = getAccumuloDataStoreConf(cmd);
String featureName = cmd.getOptionValue(FEATURE_NAME);
SimpleFeatureType featureType = DataUtilities.createType(featureName, "geom:Point:srid=4326");
DataStore ds = DataStoreFinder.getDataStore(dsConf);
ds.createSchema(featureType);
TopologyBuilder topologyBuilder = new TopologyBuilder();
String topic = cmd.getOptionValue(TOPIC);
String groupId = topic;
dsConf.put(OSMIngest.FEATURE_NAME, featureName);
OSMKafkaSpout OSMKafkaSpout = new OSMKafkaSpout(dsConf, groupId, topic);
topologyBuilder.setSpout("Spout", OSMKafkaSpout, 10).setNumTasks(10);
OSMKafkaBolt OSMKafkaBolt = new OSMKafkaBolt(dsConf, groupId, topic);
topologyBuilder.setBolt("Bolt", OSMKafkaBolt, 20).shuffleGrouping("Spout");
Config stormConf = new Config();
stormConf.setNumWorkers(10);
stormConf.setDebug(true);
StormSubmitter.submitTopology(topic, stormConf, topologyBuilder.createTopology());
return 0;
}
示例7: main
import org.geotools.data.DataStore; //導入依賴的package包/類
public static void main(String [ ] args) throws Exception {
CommandLineParser parser = new BasicParser();
Options options = getCommonRequiredOptions();
Option ingestFileOpt = OptionBuilder.withArgName(INGEST_FILE)
.hasArg()
.isRequired()
.withDescription("ingest tsv file on hdfs")
.create(INGEST_FILE);
options.addOption(ingestFileOpt);
CommandLine cmd = parser.parse( options, args);
Map<String, String> dsConf = getAccumuloDataStoreConf(cmd);
String featureName = cmd.getOptionValue(FEATURE_NAME);
SimpleFeatureType featureType = buildGDELTFeatureType(featureName);
DataStore ds = DataStoreFinder.getDataStore(dsConf);
ds.createSchema(featureType);
runMapReduceJob(featureName,
dsConf,
new Path(cmd.getOptionValue(INGEST_FILE)));
}
示例8: createDataStore
import org.geotools.data.DataStore; //導入依賴的package包/類
/**
* 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;
}
示例9: getStatementFeatureType
import org.geotools.data.DataStore; //導入依賴的package包/類
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;
}
示例10: initInternal
import org.geotools.data.DataStore; //導入依賴的package包/類
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;
}
示例11: getStatementFeatureType
import org.geotools.data.DataStore; //導入依賴的package包/類
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;
}
示例12: exportUAZ
import org.geotools.data.DataStore; //導入依賴的package包/類
/**
* Export uaz.
*
* @param project
* the project
* @param userId
* the user id
* @return the string
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws DataStoreCreationException
* the data store creation exception
* @throws MiddlewarePersistentException
*/
public String exportUAZ(final WifProject project, final String userId)
throws IOException, DataStoreCreationException,
MiddlewarePersistentException {
LOGGER.info("Entering exportUAZ/share in my aurin");
LOGGER.info("using the following server: {} for database/schema: {}",
postgisDataStoreConfig.getDataStoreParams().get(HOST.key),
postgisDataStoreConfig.getDataStoreParams().get(DATABASE.key) + "/"
+ postgisDataStoreConfig.getDataStoreParams().get(SCHEMA.key));
final String tableName = project.getSuitabilityConfig()
.getUnifiedAreaZone();
final DataStore dataStore = DataStoreFinder
.getDataStore(postgisDataStoreConfig.getDataStoreParams());
final SimpleFeatureSource featureSource = dataStore
.getFeatureSource(tableName);
final SimpleFeatureCollection features = featureSource.getFeatures();
final String result = shareUAZSnapshot(features, userId, project);
LOGGER
.info("exporting finished, information sent to AURIN/middleware persistence!");
return result;
}
示例13: getWifUAZfromDB
import org.geotools.data.DataStore; //導入依賴的package包/類
/**
* Gets the wif ua zfrom db.
*
* @param uazTbl
* the uaz tbl
* @return the wif ua zfrom db
*/
public SimpleFeatureCollection getWifUAZfromDB(final String uazTbl) {
LOGGER.info("getWifUAZfromDB for table : {}", uazTbl);
SimpleFeatureCollection uazFeatureCollection = FeatureCollections
.newCollection();
DataStore wifDataStore;
try {
wifDataStore = openPostgisDataStore();
final SimpleFeatureSource featureSourceUD = wifDataStore
.getFeatureSource(uazTbl);
uazFeatureCollection = featureSourceUD.getFeatures();
LOGGER.info("UAZ featureCollection size : {} ",
uazFeatureCollection.size());
} catch (final IOException e) {
LOGGER.error("could not access table {} ", uazTbl);
}
return uazFeatureCollection;
}
示例14: updateUAZArea
import org.geotools.data.DataStore; //導入依賴的package包/類
/**
* Update uaz area.
*
* @param uazTbl
* the uaz tbl
*/
public void updateUAZArea(final String uazTbl) {
LOGGER.info("updateUAZArea for table : {}", uazTbl);
DataStore wifDataStore;
try {
wifDataStore = openPostgisDataStore();
final SimpleFeatureSource featureSourceUD = wifDataStore
.getFeatureSource(uazTbl);
final SimpleFeatureType schema = featureSourceUD.getSchema();
final String geomColumnName = schema.getGeometryDescriptor()
.getLocalName();
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
final String queryTxt = "UPDATE "
+ postgisDataStoreConfig.getDataStoreParams().get(SCHEMA.key) + "."
+ uazTbl + " SET \"" + WifKeys.DEFAULT_AREA_COLUMN_NAME + "\" = "
+ " (ST_Area( " + geomColumnName + " )) ";
LOGGER.debug("updateUAZArea: {}", queryTxt);
jdbcTemplate.execute(queryTxt);
} catch (final IOException e) {
LOGGER.error("could not access table {} ", uazTbl);
}
}
示例15: getFeatureSourcefromDB
import org.geotools.data.DataStore; //導入依賴的package包/類
/**
* Gets the feature sourcefrom db.
*
* @param uazTbl
* the uaz tbl
* @return the feature sourcefrom db
* @throws WifInvalidInputException
* the wif invalid input exception
*/
public SimpleFeatureSource getFeatureSourcefromDB(final String uazTbl)
throws WifInvalidInputException {
LOGGER.info("getFeatureSourcefromDB for table : {}", uazTbl);
DataStore wifDataStore;
SimpleFeatureSource featureSourceUD;
try {
wifDataStore = openPostgisDataStore();
featureSourceUD = wifDataStore.getFeatureSource(uazTbl);
LOGGER.info("UAZ featureSource Name: {} ", featureSourceUD.getName());
return featureSourceUD;
}
catch (final IOException e) {
LOGGER.error("could not access table {} ", uazTbl);
throw new WifInvalidInputException("could not access table" + uazTbl);
}
}