我很长时间坚持这个,请帮助我。请让我知道我们怎么做 在geotools地图上添加一个Mapinfo文件图层请帮忙
OGRDataStoreFactory factory = new JniOGRDataStoreFactory();
Map<String, String> connectionParams = new HashMap<String, String>();
connectionParams.put("DriverName", "MapInfo File");
connectionParams.put("DatasourceName",
"C:\\Users\\Varun\\Desktop\\Test\\export\\MS1_Longcall0608143822_001.tab");
DataStore store = factory.createDataStore(connectionParams);
SimpleFeatureSource featureSource = store.getFeatureSource("MS1_Longcall0608143822_001");
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);
堆栈跟踪
2016-09-27T18:36:44.839+0530 SEVERE org.gdal.ogr.ogrJNI.Layer_SetSpatialFilter(JLorg/gdal/ogr/Layer;JLorg/gdal/ogr/Geometry;)V
java.lang.UnsatisfiedLinkError: org.gdal.ogr.ogrJNI.Layer_SetSpatialFilter(JLorg/gdal/ogr/Layer;JLorg/gdal/ogr/Geometry;)V
at org.gdal.ogr.ogrJNI.Layer_SetSpatialFilter(Native Method)
at org.gdal.ogr.Layer.SetSpatialFilter(Layer.java:89)
at org.geotools.data.ogr.jni.JniOGR.LayerSetSpatialFilter(JniOGR.java:257)
at org.geotools.data.ogr.OGRFeatureSource.setLayerFilters(OGRFeatureSource.java:124)
at org.geotools.data.ogr.OGRFeatureSource.getReaderInternal(OGRFeatureSource.java:230)
at org.geotools.data.ogr.OGRFeatureSource.getReaderInternal(OGRFeatureSource.java:167)
at org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:647)
at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:173)
at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:58)
at org.geotools.renderer.lite.StreamingRenderer.drawPlain(StreamingRenderer.java:2285)
at org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1920)
at org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:833)
at org.geotools.swing.RenderingTask.call(RenderingTask.java:106)
at org.geotools.swing.RenderingTask.call(RenderingTask.java:41)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:0)
GeoTools无法找到您的GDAL库。您需要检查几件事。从数据存储页面:
您需要使用Java支持编译GDAL / OGR的安装才能使用此模块。
安装GDAL会出现这种情况吗?
OGR DataStore确实需要GDAL / OGR本机库。安装后,您需要将位置添加到Windows上的PATH,Mac上的DYLD_LIBRARY_PATH和Linux上的LD_LIBRARY_PATH。如果您使用gt-ogr-bridj并且dll / dylib / so文件未命名为gdal,则需要设置GDAL_LIBRARY_NAME。通常它类似于gdal10,具体取决于您安装的GDAL版本。在运行程序时,您还必须将java.library.path设置为GDAL的位置。
您是否设置了这些环境变量?