Re: [OpenMap Users] Load Shapefiles from a jarfile?

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Sun, 1 Sep 2013 19:25:01 -0400

Hi Gary,

If the jar file is in your classpath, you can just refer to the shape file by it's relative path inside the jar:

        shpFile=Zips/Zips.shp


If the jar file is not in your classpath, I thought you could do something like this:

        shpFile=file://Zips.jar!/Zips/Zips.shp

but I can't get that to work for me, now.

So you can also use the com.bbn.openmap.util.ClasspathHacker class to add a jar to the classpath programmatically, and then just load the shp file through it's relative path.

Hope this helps,

- Don



On Sep 1, 2013, at 5:18 PM, Gary Briggs wrote:

>
> Is it possible to load shapefiles directly out of a jarfile?
>
> I'm using a ShapeLayer, and setting the "shapeFile" property to the path.
>
> I've tried a variety of combinations. For what it's worth, my data
> are a shapefile for every zip code in the US, inside of a "Zips" directory.
>
> // This is the one I'm currently using
> String fileNamePrefix = "Zips/" + zip;
>
> So then I just zipped it up, with the "Zips/" prefix inside the zipfile,
> to "Zips.jar"
>
> // Neither of these have worked:
> String fileNamePrefix = "jar:file:Zips.jar!/Zips/" + zip;
> String fileNamePrefix = "jar:Zips.jar!/Zips/" + zip;
>
> Am I barking up the wrong tree?
>
> Cheers,
> Gary
>
> --
> [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"]

--
[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 Sun Sep 01 2013 - 19:26:57 EDT

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