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


Java FileDataStoreFinder类代码示例

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


FileDataStoreFinder类属于org.geotools.data包,在下文中一共展示了FileDataStoreFinder类的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: writeShapefile

import org.geotools.data.FileDataStoreFinder; //导入依赖的package包/类
private void writeShapefile(MemoryDataStore memoryDataStore, File outputFile) throws Exception {

		SimpleFeatureSource featureSource = memoryDataStore.getFeatureSource(memoryDataStore.getTypeNames()[0]);
		SimpleFeatureType featureType = featureSource.getSchema();

		Map<String, java.io.Serializable> creationParams = new HashMap<String, java.io.Serializable>();
		creationParams.put("url", DataUtilities.fileToURL(outputFile));

		ShapefileDataStoreFactory factory = (ShapefileDataStoreFactory) FileDataStoreFinder.getDataStoreFactory("shp");
		ShapefileDataStore dataStore = (ShapefileDataStore) factory.createNewDataStore(creationParams);
		dataStore.setCharset(Charset.forName("UTF-8"));
		dataStore.createSchema(featureType);

		SimpleFeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(dataStore.getTypeNames()[0]);

		Transaction transaction = new DefaultTransaction();
		try {
			SimpleFeatureCollection collection = featureSource.getFeatures();
			featureStore.addFeatures(collection);
			transaction.commit();
		} catch (IOException e) {
			try {
				transaction.rollback();
				throw new Exception("Failed to commit data to feature store", e);
			} catch (IOException e2 ) {
				logger.error("Failed to commit data to feature store", e);
				throw new Exception("Transaction rollback failed", e2);
			}
		} finally {
			transaction.close();
		}
	}
 
开发者ID:dainst,项目名称:gazetteer,代码行数:33,代码来源:ShapefileCreator.java

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

示例8: main

import org.geotools.data.FileDataStoreFinder; //导入依赖的package包/类
/**
 * GeoTools Quickstart demo application. Prompts the user for a shapefile and displays its
 * contents on the screen in a map frame
 */
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();

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

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

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

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

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

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

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

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

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


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