Re: reading shapefile from jar

From: Don Dietrick <dietrick@bbn.com>
Date: Wed Jun 12 2002 - 17:08:41 EDT

Hi Chris,

You should just be able to run with the property set to:

mytopo.shapeFile=topol01l.shp

and have your topo.jar listed in your classpath or in your applet html
page as an archive file.

It looks like your code trims your string to the same thing.

The problem with the 1.4 plugin is slightly different. With 1.3, the
getResource() call would return a URL to the cached jar file stored in
the plugin cache. With 1.4, the getResource() call returns a URL to the
jar on the server, which the JarInputReader seems to be OK with,
acknowledging that the resource (file) exists. The problem occurs when
the JarInputReader tries to read the file, resulting in a ZipException,
as if the file is not valid.

Regards,

Don

On Wednesday, June 12, 2002, at 03:17 PM, chrisvanlith@b3partners.nl
wrote:

>
> Don and list,
>
> I am not sure if I do something wrong or that BinaryFile class indeed
> has a bug.
>
> This is what I do.
> In the properties I read  the shapefile with line:
> mytopo.shapeFile=data/shape/topo.jar!/topol01l.shp
>
> This line gives errors with the standard BinaryFile class.
> I changed the lines according to new 4.5 " url =
> Thread.currentThread().getContextClassLoader().getResource(name);"
> Still errors, because the exists function does not know how to handle
> the ! separator.
>
> I added the following lines:
>
>                 int index = name.indexOf("!");
>                 if (index != -1) {
>                     name = name.substring(name.indexOf(":") + 1, index);
>                 }
> just before the "url =
> Thread.currentThread().getContextClassLoader().getResource(name);" line
> in the exists function.
>
> Next the errors continue in the BinaryFile constructor, so I add
>                 int index = name.indexOf("!");
>                 String jarEntryName = null;
>                 if (index != -1) {
>                     // skip !/ "
>                     jarEntryName = name.substring(index + 2);
>                     name = name.substring(name.indexOf(":") + 1, index);
>                 }
> again before the "url =
> Thread.currentThread().getContextClassLoader().getResource(name);" line.
> Finally I add the jarEntryName back to the newname, just before the
> setJarInputReader(newname) function is called.
>                     if (jarEntryName!=null && !jarEntryName.equals(""))
>                         newname += "!" + jarEntryName;
>
> Now the whole thing seems to work, I am still testing. Maybe elsewhere
> problems arise.
>
>
> Is all this new, or am I taking the more complicated route.
>
> Thanks in advance for your comments
>
> Chris van Lith
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, BBN Technologies, dietrick@bbn.com
10 Moulton Street, Cambridge, MA 02138
617-873-3031 [fax]-2794
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Wed Jun 12 17:09:06 2002

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT