[Geoserver-users] SHAPE-ZIP Wfs request doesn't work.

Dear List,

I’m having difficulties with 1.7.2 getting a WFS shapefile. Windows 2003 Server, PostGIS.

The funny thing is that if I do the exact same WFS request without specifying outputFormat=“SHAPE-ZIP”, it works just fine.

Here is the output log at the error: (the full log is attached)

2009-03-11 14:30:30,480 ERROR [data.shapefile] - The following locker still has a lock? read on file:/C:/DOCUME~1/rbedell/LOCALS~1/Temp/1/wfsshptemp0.1673785030168745/rivers.shp by org.geotools.data.shapefile.shp.ShapefileReader

it was created with the following stack trace

org.geotools.data.shapefile.ShpFilesLocker$Trace: Locking file:/C:/DOCUME~1/rbedell/LOCALS~1/Temp/1/wfsshptemp0.1673785030168745/rivers.shp for read by org.geotools.data.shapefile.shp.ShapefileReader in thread btpool0-6

at org.geotools.data.shapefile.ShpFilesLocker.setTraceException(ShpFilesLocker.java:54)

at org.geotools.data.shapefile.ShpFilesLocker.(ShpFilesLocker.java:33)

at org.geotools.data.shapefile.ShpFiles.acquireRead(ShpFiles.java:365)

at org.geotools.data.shapefile.ShpFiles.getReadChannel

I’ve checked the permissions, and since this is running as a normal task under my login, it has Full Control over my Temp directory (C:/DOCUME~1/rbedell/LOCALS~1/Temp). There is a SHP file in the above temp directory, but is empty.

Thanks!
Roger

WFS-SHPerror.txt (120 KB)

Hi Roger,

Confirmed, I just noticed the same problem with shapefile output. Looks like a bug. Andrea, can you confirm?

Roger Bedell wrote:

Dear List,
I'm having difficulties with 1.7.2 getting a WFS shapefile. Windows 2003 Server, PostGIS.
The funny thing is that if I do the exact same WFS request without specifying outputFormat="SHAPE-ZIP", it works just fine.
Here is the output log at the error: (the full log is attached)

2009-03-11 14:30:30,480 ERROR [data.shapefile] - The following locker still has a lock? read on file:/C:/DOCUME~1/rbedell/LOCALS~1/Temp/1/wfsshptemp0.1673785030168745/rivers.shp by org.geotools.data.shapefile.shp.ShapefileReader

it was created with the following stack trace

org.geotools.data.shapefile.ShpFilesLocker$Trace: Locking file:/C:/DOCUME~1/rbedell/LOCALS~1/Temp/1/wfsshptemp0.1673785030168745/rivers.shp for read by org.geotools.data.shapefile.shp.ShapefileReader in thread btpool0-6

at org.geotools.data.shapefile.ShpFilesLocker.setTraceException(ShpFilesLocker.java:54)

at org.geotools.data.shapefile.ShpFilesLocker.<init>(ShpFilesLocker.java:33)

at org.geotools.data.shapefile.ShpFiles.acquireRead(ShpFiles.java:365)

at org.geotools.data.shapefile.ShpFiles.getReadChannel

...

I've checked the permissions, and since this is running as a normal task under my login, it has Full Control over my Temp directory (C:/DOCUME~1/rbedell/LOCALS~1/Temp). There is a SHP file in the above temp directory, but is empty.

Thanks!
Roger

------------------------------------------------------------------------

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Justin Deoliveira ha scritto:

Hi Roger,

Confirmed, I just noticed the same problem with shapefile output. Looks like a bug. Andrea, can you confirm?

Hmmm... not in the same way. I tried the following requests against our sample data:

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=topp:states&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326&outputFormat=SHAPE-ZIP
http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=topp:states&outputFormat=SHAPE-ZIP
http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=sf:roads&outputFormat=SHAPE-ZIP
http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=sf:roads,topp:states&outputFormat=SHAPE-ZIP

and they all work fine. Then I tried to export a postgis table and
yeah, I've found an error, but a different one:

12 mar 10:24:30 ERROR [geoserver.ows] -
java.lang.ClassCastException: java.lang.String cannot be cast to com.vividsoluti
ons.jts.geom.Geometry

There is an assumption in the current code, that the schema generated
in the shapefile is the same as the one coming from the db, but that
is not always the case, in particular, shapefile datastore forces the
geometry to be the first attribute, whilst in the postgis data it
was the last one. When a direct feature copy occurs, the mismatched
position of attributes results in the above exception.

I have to change the code to account this kind of schema morphing.
Hmmm... looking into the code history, that kind of issue has always
been there, the code always tried to just write the collection coming
from the datastore into the shapefile verbatim... Odd? Possible no-one
ever stumbled into this? A search in jira does not turn out anything,
not even in the closed issues. Oh well, here is a new one:

http://jira.codehaus.org/browse/GEOS-2732

Roger, if you register in jira and "watch" the issue you'll be notified
of when it will be resolved. I could use your feedback to know wheter
that one is actually the one you're seeing, or if we're looking
at two different problems.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Andrea,
If you look at the log I sent, you will see the same ClassCastException error, but it occurs later in the log, after two of the Locker errors. Perhaps the lock errors don't matter, or perhaps there are two problems.
I'll watch Jira and try it here when you've solved it.
Thanks for your help in this, as it is very important to us.
Roger

--------------------------------------------------
From: "Andrea Aime" <aaime@anonymised.com>
Sent: Thursday, March 12, 2009 10:42 AM
To: "Justin Deoliveira" <jdeolive@anonymised.com>
Cc: "Roger Bedell" <roger@anonymised.com>; <geoserver-users@lists.sourceforge.net>
Subject: Re: [Geoserver-users] SHAPE-ZIP Wfs request doesn't work.

Justin Deoliveira ha scritto:

Hi Roger,

Confirmed, I just noticed the same problem with shapefile output. Looks like a bug. Andrea, can you confirm?

Hmmm... not in the same way. I tried the following requests against our sample data:

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=topp:states&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326&outputFormat=SHAPE-ZIP
http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=topp:states&outputFormat=SHAPE-ZIP
http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=sf:roads&outputFormat=SHAPE-ZIP
http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.0.0&typeName=sf:roads,topp:states&outputFormat=SHAPE-ZIP

and they all work fine. Then I tried to export a postgis table and
yeah, I've found an error, but a different one:

12 mar 10:24:30 ERROR [geoserver.ows] -
java.lang.ClassCastException: java.lang.String cannot be cast to com.vividsoluti
ons.jts.geom.Geometry

There is an assumption in the current code, that the schema generated
in the shapefile is the same as the one coming from the db, but that
is not always the case, in particular, shapefile datastore forces the
geometry to be the first attribute, whilst in the postgis data it
was the last one. When a direct feature copy occurs, the mismatched
position of attributes results in the above exception.

I have to change the code to account this kind of schema morphing.
Hmmm... looking into the code history, that kind of issue has always
been there, the code always tried to just write the collection coming
from the datastore into the shapefile verbatim... Odd? Possible no-one
ever stumbled into this? A search in jira does not turn out anything,
not even in the closed issues. Oh well, here is a new one:

http://jira.codehaus.org/browse/GEOS-2732

Roger, if you register in jira and "watch" the issue you'll be notified
of when it will be resolved. I could use your feedback to know wheter
that one is actually the one you're seeing, or if we're looking
at two different problems.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Andrea Aime ha scritto:

http://jira.codehaus.org/browse/GEOS-2732

Roger, if you register in jira and "watch" the issue you'll be notified
of when it will be resolved. I could use your feedback to know wheter
that one is actually the one you're seeing, or if we're looking
at two different problems.

Well, it turned out to be a quick fix, so I went for it and closed
it. Now I can get shapefiles out of postgis on my PC.
Roger, if you want to try out, wait until tomorrow, then pick the
nightly stamped as 031309 (or later) and tell me if it works for you
too:
http://gridlock.openplans.org/geoserver/1.7.x/

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Andrea,
I also found another work-around using the OGR2OGR Output Format.

Adding this to the ogr2ogr.xml:

    <Format>
      <ogrFormat>ESRI Shapefile</ogrFormat>
      <formatName>OGR-SHP-ZIP</formatName>
      <fileExtension>.shp</fileExtension>
    </Format>

You get another way to generate SHP files using OGR2OGR, and it seems to work fine.

Roger

--------------------------------------------------
From: "Andrea Aime" <aaime@anonymised.com>
Sent: Thursday, March 12, 2009 11:45 AM
To: "Justin Deoliveira" <jdeolive@anonymised.com>
Cc: "Roger Bedell" <roger@anonymised.com>; <geoserver-users@lists.sourceforge.net>
Subject: Re: [Geoserver-users] SHAPE-ZIP Wfs request doesn't work.

Andrea Aime ha scritto:

http://jira.codehaus.org/browse/GEOS-2732

Roger, if you register in jira and "watch" the issue you'll be notified
of when it will be resolved. I could use your feedback to know wheter
that one is actually the one you're seeing, or if we're looking
at two different problems.

Well, it turned out to be a quick fix, so I went for it and closed
it. Now I can get shapefiles out of postgis on my PC.
Roger, if you want to try out, wait until tomorrow, then pick the
nightly stamped as 031309 (or later) and tell me if it works for you
too:
http://gridlock.openplans.org/geoserver/1.7.x/

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Roger Bedell ha scritto:

Andrea,
I also found another work-around using the OGR2OGR Output Format.

Adding this to the ogr2ogr.xml:

    <Format>
      <ogrFormat>ESRI Shapefile</ogrFormat>
      <formatName>OGR-SHP-ZIP</formatName>
      <fileExtension>.shp</fileExtension>
    </Format>

You get another way to generate SHP files using OGR2OGR, and it seems to work fine.

Yep, it should just be slower than SHAPE-ZIP.
Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.