當前位置: 首頁>>代碼示例>>Java>>正文


Java DataStore類代碼示例

本文整理匯總了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");

}
 
開發者ID:graphhopper,項目名稱:timezone,代碼行數:25,代碼來源:TZShapeReader.java

示例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;
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:11,代碼來源:GamaSqlConnection.java

示例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();
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:23,代碼來源:ShapefileRDDTest.java

示例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);
    }
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:25,代碼來源:PostgisIO.java

示例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();
}
   }
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:21,代碼來源:SimpleShapefile.java

示例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;
}
 
開發者ID:geomesa,項目名稱:geomesa-tutorials,代碼行數:27,代碼來源:OSMIngest.java

示例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)));
}
 
開發者ID:geomesa,項目名稱:geomesa-tutorials,代碼行數:24,代碼來源:GDELTIngest.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:23,代碼來源:GeoWaveGeoIndexer.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:20,代碼來源:GeoWaveGeoIndexer.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:18,代碼來源:GeoMesaGeoIndexer.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:18,代碼來源:GeoMesaGeoIndexer.java

示例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;
}
 
開發者ID:AURIN,項目名稱:online-whatif,代碼行數:36,代碼來源:PostgisToDataStoreExporter.java

示例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;
}
 
開發者ID:AURIN,項目名稱:online-whatif,代碼行數:28,代碼來源:GeodataFinder.java

示例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);
  }
}
 
開發者ID:AURIN,項目名稱:online-whatif,代碼行數:31,代碼來源:GeodataFinder.java

示例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);
  }
}
 
開發者ID:AURIN,項目名稱:online-whatif,代碼行數:29,代碼來源:GeodataFinder.java


注:本文中的org.geotools.data.DataStore類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。