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


Java FileDataStoreFinder.getDataStore方法代码示例

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


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

示例1: zipFileToPostGIS

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
/**
 * Zip file to post gis.
 * 
 * @param shpFile
 *          the shp file
 * @return the simple feature collection
 * @throws ShapeFile2PostGISCreationException
 *           the shape file2 post gis creation exception
 */
public SimpleFeatureCollection zipFileToPostGIS(final File shpFile)
    throws ShapeFile2PostGISCreationException {
  final String msg = "Converting shape file operation failed...";

  try {

    final FileDataStore store = FileDataStoreFinder.getDataStore(shpFile);
    final SimpleFeatureSource featureSource = store.getFeatureSource();
    final SimpleFeatureCollection features = featureSource.getFeatures();
    LOGGER.info("Shape filename = {}", featureSource.getSchema()
        .getTypeName());
    final CoordinateReferenceSystem crs = featureSource.getSchema()
        .getCoordinateReferenceSystem();
    validatorCRS.validateSimple(crs, msg);
    return features;
  } catch (final Exception e) {
    LOGGER.error(msg, e.getMessage());
    throw new ShapeFile2PostGISCreationException(msg, e);
  }
}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:30,代码来源:FileToPostgisExporter.java

示例2: run

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
@Override
public void run() {
	final Display display = WorkbenchHelper.getDisplay();
	final Shell shell = new Shell(display);
	final File openFile = JFileDataStoreChooser.showOpenFile(new String[] { "*.shp" }, shell); //$NON-NLS-1$

	try {
		if (openFile != null && openFile.exists()) {
			final MapContent mapContent = mapPane.getMapContent();
			final FileDataStore store = FileDataStoreFinder.getDataStore(openFile);
			final SimpleFeatureSource featureSource = store.getFeatureSource();
			final Style style = Utils.createStyle(openFile, featureSource);
			final FeatureLayer featureLayer = new FeatureLayer(featureSource, style);
			mapContent.addLayer(featureLayer);
			mapPane.redraw();
		}
	} catch (final IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:21,代码来源:OpenShapefileAction.java

示例3: findDescription

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
public static ShapeFileDesc findDescription(File file) throws IOException {
        FileDataStore store = FileDataStoreFinder.getDataStore(file);
        SimpleFeatureType schema = store.getSchema();
        GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
        GeometryType type = geometryDescriptor.getType();
        CoordinateReferenceSystem coordinateReferenceSystem = geometryDescriptor.getCoordinateReferenceSystem();
        List<AttributeDescriptor> attributeDescriptors = schema.getAttributeDescriptors();
        List<String> labels = new ArrayList();
        for (AttributeDescriptor a : attributeDescriptors) {
            labels.add(a.getLocalName());
            //labels
            System.out.println(a.getLocalName());
        }
        //projection system
//        System.out.println(coordinateReferenceSystem.getCoordinateSystem().getName().toString());
        //type
        System.out.println(parseGeometry(type));
        double w = store.getFeatureSource().getBounds().getWidth();
        double h = store.getFeatureSource().getBounds().getHeight();

        return new ShapeFileDesc(coordinateReferenceSystem == null ? null : coordinateReferenceSystem.getCoordinateSystem().getName().toString(),
                parseGeometry(type), labels, Math.sqrt(w * w + h * h));
    }
 
开发者ID:skp703,项目名称:RainInterpolator,代码行数:24,代码来源:ParseShapefiles.java

示例4: createCoastlineLayer

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
private static Layer createCoastlineLayer() {
    try {
        // File file = new File(
        // "/home/dxm/Downloads/shapefile-australia-coastline-polygon/cstauscd_r.shp");
        File file = new File("src/main/resources/shapes/countries.shp");
        FileDataStore store = FileDataStoreFinder.getDataStore(file);
        SimpleFeatureSource featureSource = store.getFeatureSource();

        // Style style = SLD.createSimpleStyle(featureSource.getSchema());
        Style style = SLD.createPolygonStyle(Color.black, new Color(242, 237, 206), 1);
        Layer layer = new FeatureLayer(featureSource, style);
        return layer;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:17,代码来源:Map.java

示例5: readFeatureCollection

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
@Execute
public void readFeatureCollection() throws IOException {
    if (!concatOr(geodata == null, doReset)) {
        return;
    }

    try {
        File shapeFile = new File(file);
        pm.beginTask("Reading features from shapefile: " + shapeFile.getName(), -1);
        FileDataStore store = FileDataStoreFinder.getDataStore(shapeFile);
        SimpleFeatureSource featureSource = store.getFeatureSource();
        geodata = featureSource.getFeatures();
        store.dispose();
    } finally {
        pm.done();
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:18,代码来源:OmsShapefileFeatureReader.java

示例6: main

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
/**
 * This method demonstrates using a memory-based cache to speed up the display (e.g. when
 * zooming in and out).
 * 
 * There is just one line extra compared to the main method, where we create an instance of
 * CachingFeatureStore.
 */
public static void main(String[] args) throws Exception {
    // display a data store file chooser dialog for shapefiles
    File file = JFileDataStoreChooser.showOpenFile("shp", null);
    if (file == null) {
        return;
    }

    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    SimpleFeatureSource featureSource = store.getFeatureSource();

    CachingFeatureSource cache = new CachingFeatureSource(featureSource);

    // Create a map content and add our shapefile to it
    MapContent map = new MapContent();
    map.setTitle("Using cached features");
    Style style = SLD.createSimpleStyle(featureSource.getSchema());
    Layer layer = new FeatureLayer(cache, style);
    map.addLayer(layer);

    // Now display the map
    JMapFrame.showMap(map);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:QuickstartCache.java

示例7: displayShapefile

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
/**
 * Prompts the user for a shapefile (unless a filename is provided
 * on the command line; then creates a simple Style and displays
 * the shapefile on screen
 */
private void displayShapefile() throws Exception {
    File file = JFileDataStoreChooser.showOpenFile("shp", null);
    if (file == null) {
        return;
    }

    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    FeatureSource featureSource = store.getFeatureSource();

    // Create a map content and add our shapefile to it
    MapContent map = new MapContent();
    map.setTitle("StyleLab");

    // Create a basic Style to render the features
    Style style = createStyle(file, featureSource);

    // Add the features and the associated Style object to
    // the MapContent as a new Layer
    Layer layer = new FeatureLayer(featureSource, style);
    map.addLayer(layer);

    // Now display the map
    JMapFrame.showMap(map);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:30,代码来源:StyleLab.java

示例8: TwoAttributes

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
public TwoAttributes(String[] args) throws IOException {
	File file = new File(args[0]);
	FileDataStore store = FileDataStoreFinder.getDataStore(file);
	SimpleFeatureSource featureSource = store.getFeatureSource();
	SimpleFeatureType schema = featureSource.getSchema();
	System.out.println(schema);
	// Create a map content and add our shapefile to it
	MapContent mapContent = new MapContent();
	mapContent.setTitle("GeoTools Mapping");
	Style style = SLD.createSimpleStyle(featureSource.getSchema());
	Layer layer = new FeatureLayer(featureSource, style);
	mapContent.addLayer(layer);
	frame = new JMapFrame(mapContent);
	frame.enableStatusBar(true);
	frame.enableToolBar(true);
	JToolBar toolBar = frame.getToolBar();
	toolBar.addSeparator();
	SaveAction save = new SaveAction("Save");
	toolBar.add(save);
	frame.initComponents();
	frame.setSize(1000, 500);
	frame.setVisible(true);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:24,代码来源:TwoAttributes.java

示例9: SaveMapAsImage

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
public SaveMapAsImage(File file) throws IOException {

		FileDataStore store = FileDataStoreFinder.getDataStore(file);
		SimpleFeatureSource featureSource = store.getFeatureSource();

		// Create a map content and add our shapefile to it
		mapContent = new MapContent();
		mapContent.setTitle("GeoTools Mapping");
		Style style = SLD.createSimpleStyle(featureSource.getSchema());
		Layer layer = new FeatureLayer(featureSource, style);
		mapContent.addLayer(layer);
		frame = new JMapFrame(mapContent);
		frame.enableStatusBar(true);
		frame.enableToolBar(true);
		JToolBar toolBar = frame.getToolBar();
		toolBar.addSeparator();
		SaveAction save = new SaveAction("Save");
		toolBar.add(save);
		frame.initComponents();
		frame.setSize(1000, 500);
		frame.setVisible(true);
	}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:23,代码来源:SaveMapAsImage.java

示例10: load

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
public static LinkedList<PreparedPolygon> load() throws IOException {

		URL krajeShp = Kraje.class
				.getResource("kraje/hranice_krajov_simpl.shp");
		FileDataStore store = FileDataStoreFinder.getDataStore(krajeShp);
		FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = store
				.getFeatureSource();
		FeatureCollection<SimpleFeatureType, SimpleFeature> fC = featureSource
				.getFeatures();

		FeatureIterator<SimpleFeature> iter = fC.features();

		LinkedList<PreparedPolygon> list = new LinkedList<PreparedPolygon>();

		try {
			while (iter.hasNext()) {
				Feature f = iter.next();
				GeometryAttribute geomAttr = f.getDefaultGeometryProperty();
				list.add(new PreparedPolygon((Polygonal) geomAttr.getValue()));
			}
		} finally {
			iter.close();
		}

		return list;
	}
 
开发者ID:MilanNobonn,项目名称:freemapKaPor,代码行数:27,代码来源:Kraje.java

示例11: createDataStore

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private static FileDataStore createDataStore(String filename, SimpleFeatureType ft, String projection) throws Exception {
      	File file = new File(filename);
       FileDataStore dataStore = FileDataStoreFinder.getDataStore(file);
    // Tell the DataStore what type of Coordinate Reference System (CRS) to use
       if (projection != null) {
           ((ShapefileDataStore)dataStore).forceSchemaCRS(CRS.decode(projection));
       }

       return dataStore;
   }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:12,代码来源:SimpleShapefile.java

示例12: initMap

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
private void initMap() {
	try {
		FileDataStore store = FileDataStoreFinder
				.getDataStore(this.getClass().getClassLoader().getResource("maps/countries.shp"));
		SimpleFeatureSource featureSource = store.getFeatureSource();
		map = new MapContent();
		map.setTitle("Quickstart");
		Style style = SLD.createSimpleStyle(featureSource.getSchema());
		FeatureLayer layer = new FeatureLayer(featureSource, style);
		map.addLayer(layer);
		map.getViewport().setScreenArea(new Rectangle((int) canvas.getWidth(), (int) canvas.getHeight()));
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:gnoubi,项目名称:MarrakAir,代码行数:16,代码来源:MapCanvas.java

示例13: getFeatureSourceFromFile

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
/**
 * This function is really just a simplification of the process to create a
 * SimpleFeatureSource object. It will prompt the user for a file via a dialog
 * and then proceed to process it into a feature source.
 *
 * @return SimpleFeatureSource The processed feature source.
 * @throws IOException 
 */
private static SimpleFeatureSource getFeatureSourceFromFile() throws IOException{

	//Open a file and process it into a FeatureSource.
	File file = JFileDataStoreChooser.showOpenFile("shp", null);
       FileDataStore store = FileDataStoreFinder.getDataStore(file);
       
       return store.getFeatureSource();
}
 
开发者ID:Stefangemfind,项目名称:MapMatching,代码行数:17,代码来源:App.java

示例14: load

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
public void load (ShapeDataStore store) throws Exception {
    FileDataStore fds = FileDataStoreFinder.getDataStore(shapefile);
    SimpleFeatureSource src = fds.getFeatureSource();

    Query q = new Query();
    q.setCoordinateSystem(src.getInfo().getCRS());
    q.setCoordinateSystemReproject(CRS.decode("EPSG:4326", true));
    SimpleFeatureCollection sfc = src.getFeatures(q);

    for (SimpleFeatureIterator it = sfc.features(); it.hasNext();) {
        GeobufFeature feat = new GeobufFeature(it.next());
        feat.id = null;
        feat.numericId = Long.parseLong((String) feat.properties.get("GEOID10"));
        feat.properties = new HashMap<>();
        store.add(feat);
    }
}
 
开发者ID:conveyal,项目名称:seamless-census,代码行数:18,代码来源:TigerLineSource.java

示例15: readAttributes

import org.geotools.data.FileDataStoreFinder; //导入方法依赖的package包/类
public static List<String> readAttributes(File file, String attribute) throws IOException {
    List<String> values = new ArrayList();
    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    try (FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = store.getFeatureReader()) {
        while (featureReader.hasNext()) {
            SimpleFeature next = featureReader.next();
            values.add(next.getAttribute(attribute).toString());
            // values
            System.out.println(next.getAttribute(attribute).toString());
        }
    }

    return values;
}
 
开发者ID:skp703,项目名称:RainInterpolator,代码行数:15,代码来源:ParseShapefiles.java


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