[OpenMap Users] Problem reading Shape file from a JAR

From: Fabrice Bouye <FabriceB_at_spc.int>
Date: Wed, 19 Aug 2009 12:58:21 +1100

Hi,

I am having trouble reading some shape files out of a JAR.

 

I've got some shape files from http://www.vliz.be/vmdcdata/marbound/ which contain Worldwide EEZ definitions. Each "shape file" is spit into 7 files (.dbf, .prj, .sbn, .sbx, .shp.xml, .shp and .shx) and it's missing the .ssx file that comes with shape files provided with OpenMap.

 

If I initiate a ShapeLayer using file on the disk, somewhat similar to (1st code is JavaFX, 2nd code is Java ; error happens similar on both) :

 

    def shapeFile:String = "C:/Fabriceb/Devel/GIS/shape/World_EEZ_v3_20090430/World_Maritime_Boundaries_v3_20090430.shp";

    def properties:Properties = new Properties();

    properties.setProperty("prettyName", "EEZ"); //NOI18N

    properties.setProperty("shapeFile", shapeFile); //NOI18N

    properties.setProperty("lineColor", "000000"); //NOI18N

    def result:ShapeLayer = new ShapeLayer();

    result.setProperties(properties);

 

   String shapeFile = "C:/Fabriceb/Devel/GIS/shape/World_EEZ_v3_20090430/World_Maritime_Boundaries_v3_20090430.shp";

   Properties properties = new Properties();

   properties.setProperty("prettyName", "EEZ"); //NOI18N

   properties.setProperty("shapeFile", shapeFile); //NOI18N

   properties.setProperty("lineColor", "000000"); //NOI18N

   ShapeLayer result = new ShapeLayer();

   result.setProperties(properties);

 

The shape is loaded and displayed properly but I get this output on the console:

 

   Creating spatial index file: C:/Fabriceb/Devel/GIS/shape/World_EEZ_v3_20090430/World_Maritime_Boundaries_v3_20090430.ssx

Even if no file is created in that directory whatsoever.

 

If I use a path that points to a file in the JAR such as :

 

   def shapeFile:String = "org/spc/ofp/seapodym/view/ui/map/resources/eez/World_Maritime_Boundaries_v3_20090430.shp";

   def properties:Properties = new Properties();

   properties.setProperty("prettyName", "EEZ");

   properties.setProperty("shapeFile", shapeFile); //NOI18N

   properties.setProperty("lineColor", "000000"); //NOI18N

   def result:ShapeLayer = new ShapeLayer();

   result.setProperties(properties);

 

   String shapeFile = " org/spc/ofp/seapodym/view/ui/map/resources/eez/World_Maritime_Boundaries_v3_20090430.shp ";

   Properties properties = new Properties();

   properties.setProperty("prettyName", "EEZ"); //NOI18N

   properties.setProperty("shapeFile", shapeFile); //NOI18N

   properties.setProperty("lineColor", "000000"); //NOI18N

   ShapeLayer result = new ShapeLayer();

   result.setProperties(properties);

 

I got that trace :

 

java.io.FileNotFoundException: org\spc\ofp\seapodym\view\ui\map\resources\eez\World_Maritime_Boundaries_v3_20090430.shp (The system cannot find the path specified)

        at java.io.FileInputStream.open(Native Method)

        at java.io.FileInputStream.<init>(FileInputStream.java:106)

        at java.io.FileInputStream.<init>(FileInputStream.java:66)

        at com.bbn.openmap.layer.shape.SpatialIndex$MemoryIndex.createIndex(SpatialIndex.java:1675)

        at com.bbn.openmap.layer.shape.SpatialIndex$MemoryIndex.create(SpatialIndex.java:1449)

        at com.bbn.openmap.layer.shape.SpatialIndex.readIndexFile(SpatialIndex.java:769)

        at com.bbn.openmap.layer.shape.SpatialIndex.entryIterator(SpatialIndex.java:727)

        at com.bbn.openmap.layer.shape.SpatialIndex.getOMGraphics(SpatialIndex.java:526)

        at com.bbn.openmap.layer.shape.ShapeLayer.prepare(ShapeLayer.java:509)

        at com.bbn.openmap.layer.policy.StandardRenderPolicy.prepare(StandardRenderPolicy.java:99)

        at com.bbn.openmap.layer.OMGraphicHandlerLayer$LayerWorker.construct(OMGraphicHandlerLayer.java:695)

        at com.bbn.openmap.util.SwingWorker$2.run(SwingWorker.java:127)

        at java.lang.Thread.run(Thread.java:619)

and that output:

      EEZ|LayerWorker.construct(): null

 

The trace is misleading as the path is good and further test using the Shapfiles provided with OpenMap indicates this error happens only because the .ssx file is missing and (probably) because OpenMap cannot write into the directory within JAR to create it.

For example, if I recopy dcwpo-browse.ssx to the proper location and rename it World_Maritime_Boundaries_v3_20090430.ssx, there is no error anymore (but nothing is displayed of course).

On the other hand if I use dcwpo-browse.shp and dcwpo-browse.ssx, it works good from a JAR but if I remove dcwpo-browse.ssx then I get a similar java.io.FileNotFoundException on dcwpo-browse.shp (notice the FileNotFoundException indicates that the .shp file is missing instead of the .ssx).

 

Is there any way to circumvent this issue? Would it be possible, when using JAR and that the ssx is missing, to specify that the ssx is to be created in as a TMP file or in the TMP folder instead?

 

----
Fabrice Bouyé (http://fabricebouye.cv.fm/ <http://fabricebouye.cv.fm/> )
Fisheries IT Specialist
Tel: +687 26 20 00 (Ext 411)
Oceanic Fisheries, Pacific Community
http://www.spc.int/ <http://www.spc.int/>

 



--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Aug 18 2009 - 22:16:46 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT