【发布时间】:2017-04-21 01:07:45
【问题描述】:
我正在使用 geotools 库。我的目标是输入一个坐标,然后获取包含它的特征信息。
Geotools 快速入门教程的地图完全符合我的要求,使用下面红色圈出的按钮。但是,我找不到使用的方法。
我一直在谷歌搜索、阅读文档和调试代码,但无济于事。这种方法似乎是要走的路: FeatureCollection myCollection = mySimpleFeatureSource.getFeatures(查询查询);
或
FeatureCollection myCollection = mySimpleFeatureSource.getFeatures(Filter filter);
但我还没有弄清楚或发现如何使用坐标进行查询。如果有人愿意借 手,非常感谢!
提前致谢!
我运行的例子如下:
package org.geotools.tutorial.quickstart;
import java.io.File;
import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.map.FeatureLayer;
import org.geotools.map.Layer;
import org.geotools.map.MapContent;
import org.geotools.styling.SLD;
import org.geotools.styling.Style;
import org.geotools.swing.JMapFrame;
import org.geotools.swing.data.JFileDataStoreChooser;
/**
* Prompts the user for a shapefile and displays the contents on the screen in a map frame.
* <p>
* This is the GeoTools Quickstart application used in documentationa and tutorials. *
*/
public class Quickstart {
/**
* 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);
}
}
【问题讨论】:
标签: java maps shapefile coordinate geotools