当前位置: 首页>>代码示例>>Java>>正文


Java DataStoreFinder类代码示例

本文整理汇总了Java中org.geotools.data.DataStoreFinder的典型用法代码示例。如果您正苦于以下问题:Java DataStoreFinder类的具体用法?Java DataStoreFinder怎么用?Java DataStoreFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataStoreFinder类属于org.geotools.data包,在下文中一共展示了DataStoreFinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.geotools.data.DataStoreFinder; //导入依赖的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.DataStoreFinder; //导入依赖的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.DataStoreFinder; //导入依赖的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.DataStoreFinder; //导入依赖的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: populateAvailableDataStores

import org.geotools.data.DataStoreFinder; //导入依赖的package包/类
/**
 * Populates the list of available data stores that can be connected to.
 */
private void populateAvailableDataStores()
{
    DataAccessFactory fac;

    logger.debug("Available data store factories:");

    Iterator<DataStoreFactorySpi> iterator = DataStoreFinder.getAvailableDataStores();
    while (iterator.hasNext()) {
        fac = (DataAccessFactory) iterator.next();

        logger.debug("\t" + fac.getDisplayName());

        availableDataStoreList.add(fac.getDisplayName());
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:19,代码来源:DataSourceImpl.java

示例6: populateNameMap

import org.geotools.data.DataStoreFinder; //导入依赖的package包/类
/**
 * Populate name map.
 */
private static void populateNameMap() {
    Iterator<DataStoreFactorySpi> datastore = DataStoreFinder.getAvailableDataStores();

    while (datastore.hasNext()) {
        DataStoreFactorySpi dSPI = datastore.next();

        Param dbType = null;
        for (Param param : dSPI.getParametersInfo()) {
            if (param.key.equals(JDBCDataStoreFactory.DBTYPE.key)) {
                dbType = param;
                break;
            }
        }
        if (dbType != null) {
            nameMap.put(dSPI.getDisplayName(), (String) dbType.sample);
        }
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:22,代码来源:DatabaseConnectionFactory.java

示例7: run

import org.geotools.data.DataStoreFinder; //导入依赖的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

示例8: main

import org.geotools.data.DataStoreFinder; //导入依赖的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

示例9: exportUAZ

import org.geotools.data.DataStoreFinder; //导入依赖的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

示例10: AbstractGeospatialDataSource

import org.geotools.data.DataStoreFinder; //导入依赖的package包/类
public AbstractGeospatialDataSource(final Map<String, Object> dataStoreParams)
    throws IOException {
  dataStore = DataStoreFinder.getDataStore(dataStoreParams);
  if (dataStore instanceof WFSDataStore) {
    try {
      // when this doesn't throw an exception, it means we're using
      // WFS version > 1.0.0
      ((WFSDataStore) dataStore).getServiceVersion();
      LOGGER.debug("Using getFeature 1.1.0");
      // we'll default to using FeatureSource's getFeatures() implementation

    } catch (final UnsupportedOperationException e) {
      // this exception is usually thrown when we're trying to talk to WFS
      // 1.0.0
      // at the moment, geotools WFS Plugin only supports WFS 1.1.0.
      // for cases that the geotools WFS Plugin cannot handle our query,
      // we'll have to revert back to our old way of running getFeature
      LOGGER.debug("Using getFeature 1.0.0", e);
      wfsWorkaround = new Wfs_1_0_0_Workaround(dataStoreParams);
    }
  }

  datasetsCache = new HashMap<String, GeospatialDataset>();
}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:25,代码来源:AbstractGeospatialDataSource.java

示例11: getFeatures

import org.geotools.data.DataStoreFinder; //导入依赖的package包/类
/**
 * Gets the features from a given table in postGIS.
 * 
 * @param tableName
 *          the table name
 * @return the features
 * @throws DataStoreCreationException
 *           the data store creation exception
 */
public FeatureCollection<SimpleFeatureType, SimpleFeature> getFeatures(
    final String tableName) throws DataStoreCreationException {
  LOGGER.info("Entering DataStoreToPostgisExporter.getFeatures()");
  LOGGER.info("using the following server: {} for database/schema: {}",
      postgisDataStoreConfig.getDataStoreParams().get(HOST.key),
      postgisDataStoreConfig.getDataStoreParams().get(DATABASE.key) + "/"
          + postgisDataStoreConfig.getDataStoreParams().get(SCHEMA.key));

  try {
    final DataStore dataStore = DataStoreFinder
        .getDataStore(postgisDataStoreConfig.getDataStoreParams());
    return dataStore.getFeatureSource(tableName).getFeatures();
  } catch (final IOException e) {
    final String msg = "obtaining postGIS spatial features from table name "
        + tableName + " failed";
    LOGGER.error(msg);
    throw new DataStoreCreationException(msg, e);
  }

}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:30,代码来源:DataStoreToPostgisExporter.java

示例12: testLoadShapeFilePolyLine

import org.geotools.data.DataStoreFinder; //导入依赖的package包/类
/**
   * test if shapeRDD load .shp fie with shape type = PolyLine correctly.
   * @throws IOException
   */
  @Test
  public void testLoadShapeFilePolyLine() throws IOException{
      InputLocation = ShapefileRDDTest.class.getClassLoader().getResource("shapefiles/polyline").getPath();
      // load shape with geotool.shapefile
      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);
      FeatureIterator<SimpleFeature> features = collection.features();
      ArrayList<String> featureTexts = new ArrayList<String>();
      while(features.hasNext()){
          SimpleFeature feature = features.next();
          featureTexts.add(String.valueOf(feature.getDefaultGeometry()));
      }
      final Iterator<String> featureIterator = featureTexts.iterator();
      ShapefileRDD shapefileRDD = new ShapefileRDD(sc,InputLocation);
      LineStringRDD spatialRDD = new LineStringRDD(shapefileRDD.getLineStringRDD());
      try {
	RangeQuery.SpatialRangeQuery(spatialRDD, new Envelope(-180,180,-90,90), false, false).count();
} catch (Exception e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
      for (Geometry geometry : shapefileRDD.getShapeRDD().collect()) {
          Assert.assertEquals(featureIterator.next(), geometry.toText());
      }
      dataStore.dispose();
  }
 
开发者ID:DataSystemsLab,项目名称:GeoSpark,代码行数:38,代码来源:ShapefileRDDTest.java

示例13: testLoadShapeFileMultiPoint

import org.geotools.data.DataStoreFinder; //导入依赖的package包/类
/**
 * Test if shapeRDD load shape type = MultiPoint correctly.
 * @throws IOException
 */
@Test
public void testLoadShapeFileMultiPoint() throws IOException{
    InputLocation = ShapefileRDDTest.class.getClassLoader().getResource("shapefiles/multipoint").getPath();
    // load shape with geotool.shapefile
    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);
    FeatureIterator<SimpleFeature> features = collection.features();
    ArrayList<String> featureTexts = new ArrayList<String>();
    while(features.hasNext()){
        SimpleFeature feature = features.next();
        featureTexts.add(String.valueOf(feature.getDefaultGeometry()));
    }
    final Iterator<String> featureIterator = featureTexts.iterator();
    ShapefileRDD shapefileRDD = new ShapefileRDD(sc,InputLocation);
    for (Geometry geometry : shapefileRDD.getShapeRDD().collect()) {
        Assert.assertEquals(featureIterator.next(), geometry.toText());
    }
    dataStore.dispose();
}
 
开发者ID:DataSystemsLab,项目名称:GeoSpark,代码行数:31,代码来源:ShapefileRDDTest.java

示例14: buildDataStore

import org.geotools.data.DataStoreFinder; //导入依赖的package包/类
private DataStore buildDataStore() {
	Map<String, Object> parameters = new HashMap<String, Object>();
	parameters.put(WFSDataStoreFactory.URL.key, wCapabilitiesUrl.getText());
	parameters.put(WFSDataStoreFactory.PROTOCOL.key,
			wMethod[1].getSelection() ? Boolean.TRUE : Boolean.FALSE);
	parameters.put(WFSDataStoreFactory.TIMEOUT.key, GTUtils.TIMEOUT);
	if (!Const.isEmpty(wUsername.getText()))
		parameters.put(WFSDataStoreFactory.USERNAME.key,
				wUsername.getText());
	if (!Const.isEmpty(wPassword.getText()))
		parameters.put(WFSDataStoreFactory.PASSWORD.key,
				wPassword.getText());
	try {
		ds = DataStoreFinder.getDataStore(parameters);
	} catch (IOException e) {
		MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
		mb.setMessage(Messages
				.getString("WFSInputDialog.ErrorBuildingDataStore.DialogMessage"));
		mb.setText(Messages.getString("WFSInputDialog.Error.DialogTitle"));
		mb.open();
	}
	return ds;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:24,代码来源:WFSInputDialog.java

示例15: example2

import org.geotools.data.DataStoreFinder; //导入依赖的package包/类
private static void example2() throws IOException {
    System.out.println("example2 start\n");
    // example2 start
    Map<String, Serializable> params = new HashMap<String, Serializable>();
    params.put("directory", directory);
    DataStore store = DataStoreFinder.getDataStore(params);

    SimpleFeatureType type = store.getSchema("example");

    System.out.println("       typeName: " + type.getTypeName());
    System.out.println("           name: " + type.getName());
    System.out.println("attribute count: " + type.getAttributeCount());

    AttributeDescriptor id = type.getDescriptor(0);
    System.out.println("attribute 'id'    name:" + id.getName());
    System.out.println("attribute 'id'    type:" + id.getType().toString());
    System.out.println("attribute 'id' binding:"
            + id.getType().getDescription());

    AttributeDescriptor name = type.getDescriptor("name");
    System.out.println("attribute 'name'    name:" + name.getName());
    System.out.println("attribute 'name' binding:"
            + name.getType().getBinding());
    // example2 end
    System.out.println("\nexample2 end\n");
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:27,代码来源:PropertyExamples.java


注:本文中的org.geotools.data.DataStoreFinder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。