0

I am stuck into this from very long please help me in this. Please let me know how we can add a Mapinfo file Layer on geotools map please help in this

  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);

Stack Trace

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)
WitVault
  • 23,445
  • 19
  • 103
  • 133

1 Answers1

0

GeoTools is unable to find your GDAL library. There are several things you need to check. From the datastore page:

Your installation of GDAL/OGR needs to be compiled with Java support to use this module.

Is this the case with your install of GDAL?

The OGR DataStore does require the GDAL/OGR native library. Once installed you need to add the location to your PATH on Windows, DYLD_LIBRARY_PATH on Mac, and LD_LIBRARY_PATH on Linux. If you use gt-ogr-bridj and the dll/dylib/so file is not named gdal you will need to set the GDAL_LIBRARY_NAME. Often it is something like gdal10 depending on the version of GDAL you installed. You will also have to set the java.library.path to the GDAL’s location when running your program.

Have you set these environment variables?

Ian Turton
  • 10,018
  • 1
  • 28
  • 47
  • thanks for your answer but i have already installed the gdal and set the two enviourment variables which is working fine because when i iterate my GeoFeatures using SimpleFeatureSource it will give me exact results but my error in when i render that particular FeatureSource to my layer it shows me an error in rendering to map. – Shubham Goyal Sep 28 '16 at 15:24
  • please help into this i m stuck if anyone have any solution to open a Mapinfo TabFile using Geotools – Shubham Goyal Oct 03 '16 at 13:23