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


Java DataStore.dispose方法代碼示例

本文整理匯總了Java中org.geotools.data.DataStore.dispose方法的典型用法代碼示例。如果您正苦於以下問題:Java DataStore.dispose方法的具體用法?Java DataStore.dispose怎麽用?Java DataStore.dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.geotools.data.DataStore的用法示例。


在下文中一共展示了DataStore.dispose方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: testLoadShapeFilePolyLine

import org.geotools.data.DataStore; //導入方法依賴的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

示例5: testLoadShapeFileMultiPoint

import org.geotools.data.DataStore; //導入方法依賴的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

示例6: supportsFile

import org.geotools.data.DataStore; //導入方法依賴的package包/類
@Override
public boolean supportsFile(
		final URL file ) {
	DataStore dataStore = null;
	try {
		dataStore = getDataStore(file);
		if (dataStore != null) {
			dataStore.dispose();
		}
	}
	catch (final Exception e) {
		LOGGER.info(
				"GeoTools was unable to read data source for file '" + file.getPath() + "'",
				e);
	}
	return dataStore != null;
}
 
開發者ID:locationtech,項目名稱:geowave,代碼行數:18,代碼來源:GeoToolsVectorDataStoreIngestPlugin.java

示例7: save

import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
* Save the corresponding VDS into corresponding format [kmz,xml,ddbb]
* @param layer
* @param projection
*/
  @Override
  public void save(File output, String projection,GeoTransform transform) {
      try {
      	//Data store to get access to ddbb
          DataStore datastore = (DataStore) DataStoreFinder.getDataStore(config);
          //Access to the corresponding VDS layer on ddbb f.i: 'VESSELS'
          FeatureStore featurestore = (FeatureStore) datastore.getFeatureSource(layername);
          SimpleFeatureType featuretype = (SimpleFeatureType) featurestore.getSchema();
          /* @FIX I need explanation
           impleFeatureTypeBuilder builder =  new SimpleFeatureTypeBuilder();
          builder.setName(featuretype.getName());

          builder.setCRS(featuretype.getCoordinateReferenceSystem());
          System.out.println(featuretype.getDescriptors().size());
          //build the type
          //SimpleFeatureType type = builder.buildFeatureType();
          // System.out.println(type.getDescriptors().size());
          //*/
          FeatureCollection features = createFeatures(featuretype, glayer, projection, gir.getGeoTransform());
          featurestore.addFeatures(features);
          writeToDB(datastore, features);
          datastore.dispose();


      } catch (Exception ex) {
      	logger.error(ex.getMessage(),ex);
      }
  }
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:34,代碼來源:PostgisIO.java

示例8: createLayer

import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
 *
 * @param shpInput
 * @param transform
 * @return
 */
public static GeometryImage createLayer(File shpInput,GeoTransform transform) {
   	GeometryImage out=null;
       try {
       	Map<String, Serializable> params = new HashMap<String, Serializable>();
           params.put("url", shpInput.toURI().toURL());

           //create a DataStore object to connect to the physical source
           DataStore dataStore = DataStoreFinder.getDataStore(params);
           //retrieve a FeatureSource to work with the feature data
           SimpleFeatureSource featureSource = (SimpleFeatureSource) dataStore.getFeatureSource(dataStore.getTypeNames()[0]);


           SimpleFeatureCollection fc=featureSource.getFeatures();

           if (fc.isEmpty()) {
               return null;
           }
           String[] schema = createSchema(fc.getSchema().getDescriptors());
           String[] types = createTypes(fc.getSchema().getDescriptors());

           String geoName = fc.getSchema().getGeometryDescriptor().getType().getName().toString();


           out=GeometryImage.createLayerFromFeatures(geoName, dataStore,fc , schema, types,true ,transform);
           dataStore.dispose();

           //glout = GeometricLayer.createImageProjectedLayer(out, transform,null);


       } catch (Exception ex) {
       	logger.error(ex.getMessage(),ex);
       }
       return out;

   }
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:42,代碼來源:SimpleShapefile.java

示例9: importDatasource

import org.geotools.data.DataStore; //導入方法依賴的package包/類
@Override
final public void importDatasource(Datasource datasource, List<String> geographyScope, List<String> temporalScope, List<String> datasourceLocation) throws Exception {
    DataStore dataStore = getDataStoreForDatasource(datasource);
    FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = GeotoolsDataStoreUtils.getFeatureReader(dataStore, getTypeNameForDatasource(datasource));

    // Load attribute values
    withSubjects(featureReader, dataStore, (feature, subject) -> {
        timedValueBuffer.addAll(buildTimedValuesFromFeature(datasource, feature, subject));
        fixedValueBuffer.addAll(buildFixedValuesFromFeature(datasource, feature, subject));
    });

    featureReader.close();
    dataStore.dispose();
}
 
開發者ID:FutureCitiesCatapult,項目名稱:TomboloDigitalConnector,代碼行數:15,代碼來源:AbstractGeotoolsDataStoreImporter.java

示例10: testLoadShapeFilePoint

import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
   * Test if shapeRDD load shape type = Point correctly.
   * @throws IOException
   */
  @Test
  public void testLoadShapeFilePoint() throws IOException{
      InputLocation = ShapefileRDDTest.class.getClassLoader().getResource("shapefiles/point").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);
      PointRDD spatialRDD = new PointRDD(shapefileRDD.getPointRDD());
      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

示例11: main

import org.geotools.data.DataStore; //導入方法依賴的package包/類
public static void main (String[] arg) throws Exception {
    Map<String,Serializable> params = new HashMap<String,Serializable>();
    params.put( "dbtype", "monetdb");
    params.put( "hostname", "farm12.ewi.utwente.nl");
    params.put ("schema", "sys");
    params.put( "database", "twitter");
    params.put( "username", "monetdb");
    params.put( "password", "monetdb");
    params.put ("port", 50000);
    
    DataStore dataStore = (new SimpleMonetDBDataStoreFactory()).createDataStore(params);
    if (dataStore == null) {
    	throw new Exception("Unable to create datastore!");
    }        
    System.out.println("DataStore created!");
    
    FeatureSource fsSource = dataStore.getFeatureSource("uk_neogeo");
    
    FeatureType schema = fsSource.getSchema();
    
    final GeometryDescriptor geometryAttribute = schema.getGeometryDescriptor();
    
    //System.out.println(featureType);
    
    System.out.println(geometryAttribute.getType().getCoordinateReferenceSystem());
    
    
    
    dataStore.dispose();
}
 
開發者ID:DennisPallett,項目名稱:gt-jdbc-monetdb-simple,代碼行數:31,代碼來源:SimpleMonetDBDataStoreFactory.java

示例12: getShapefileFieldnames

import org.geotools.data.DataStore; //導入方法依賴的package包/類
@Override
public List<String> getShapefileFieldnames(File shapefileOrODLRG) {
	// turn an .odlrg file reference into a shapefile reference 
	if(Strings.equalsStd(FilenameUtils.getExtension(shapefileOrODLRG.getName()), RogReaderUtils.RENDER_GEOMETRY_FILE_EXT)){
		String s = FilenameUtils.removeExtension(shapefileOrODLRG.getAbsolutePath());
		s += ".shp";
		shapefileOrODLRG = new File(s);
	}

	DataStore shapefile = null;
	try {
		Map<String, URL> map = new HashMap<String, URL>();
		map.put("url", shapefileOrODLRG.toURI().toURL());
		shapefile = DataStoreFinder.getDataStore(map);

		// check not corrupt
		if (shapefile.getTypeNames().length != 1) {
			throw new RuntimeException("Shapefile should only contain one type");
		}

		String typename = shapefile.getTypeNames()[0];
		SimpleFeatureType schema = shapefile.getSchema(typename);
		int nAttrib = schema.getAttributeCount();
		ArrayList<String> ret = new ArrayList<>();
		for (int i = 0; i < nAttrib; i++) {
			ret.add(schema.getDescriptor(i).getLocalName());
		}
		return ret;

	} catch (Throwable e) {
		throw Exceptions.asUnchecked(e);
	} finally {

		if (shapefile != null) {
			shapefile.dispose();
		}
	}
}
 
開發者ID:PGWelch,項目名稱:com.opendoorlogistics,代碼行數:39,代碼來源:IOImpl.java

示例13: resourceToFeature

import org.geotools.data.DataStore; //導入方法依賴的package包/類
public static SimpleFeature resourceToFeature(
		final URL filterResource )
		throws IOException {
	final Map<String, Object> map = new HashMap<String, Object>();
	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;
}
 
開發者ID:locationtech,項目名稱:geowave,代碼行數:35,代碼來源:TestUtils.java

示例14: setup

import org.geotools.data.DataStore; //導入方法依賴的package包/類
@Override
public void setup(
        final Configuration configuration,
        final List<ColumnInterface> columnList) throws IOException
{
    m_spatialIndex = new STRtree();
    m_buffer = configuration.getFloat(GeoEnrichmentJob.KEY_BUFFER, 0.000001F);

    final URL url = getUrl(configuration);
    final ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
    final Map params = new HashMap();
    params.put(ShapefileDataStoreFactory.URLP.key, url);
    final DataStore dataStore = factory.createDataStore(params);
    try
    {
        final String[] typeNames = dataStore.getTypeNames();
        final SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeNames[0]);
        m_geometryName = featureSource.getSchema().getGeometryDescriptor().getLocalName();
        final SimpleFeatureCollection featureCollection = featureSource.getFeatures();
        featureCollection.accepts(new FeatureVisitor()
        {
            public void visit(final Feature feature)
            {
                final Geometry geometry = (Geometry) feature.getProperty(m_geometryName).getValue();
                final PreparedGeometry preparedGeometry = PreparedGeometryFactory.prepare(geometry);
                m_spatialIndex.insert(geometry.getEnvelopeInternal(), new PreparedFeature(feature, preparedGeometry));
            }
        }, new NullProgressListener());
    }
    finally
    {
        dataStore.dispose();
    }
}
 
開發者ID:mraad,項目名稱:GeoEnrichment,代碼行數:35,代碼來源:SearchShapefileIndexPolygon.java

示例15: getParameters

import org.geotools.data.DataStore; //導入方法依賴的package包/類
public List<ShapeFileParameter> getParameters(String shapeFile) {
	File paramFile = new File(folder, shapeFile + ".gisolca");
	if (paramFile.exists())
		return readParameterFile(paramFile);
	else {
		log.trace("create parameter file {}", paramFile);
		DataStore store = openDataStore(shapeFile);
		List<ShapeFileParameter> params = readParameters(store);
		writeParameterFile(shapeFile, params);
		store.dispose();
		return params;
	}
}
 
開發者ID:GreenDelta,項目名稱:olca-modules,代碼行數:14,代碼來源:ShapeFileFolder.java


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