jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • GeoTools
  • GEOT-2765

Query rows with empty geometries produce exception

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.5.7
  • Fix Version/s: 2.6.3
  • Component/s: jdbc
  • Labels:
    None

Description

An error came up changing from geoserver 1.7.4 with the Old Oracle Datastore to the latest 1.7.6 with the Oracle NG Datastore.

The WFS that before was working fine, now is failing. It queries an Oracle table with some rows that don't have geometry:

--------------------------------------------------------
select count(1) from activitats;

COUNT(1)
----------------------
1691
1 rows selected

select count(1) from activitats where GEOM is null;

COUNT(1)
----------------------
17
1 rows selected
--------------------------------------------------------

I want to obtain the rows that don't have geometry, the WFS filter used is:

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsNull>
<ogc:PropertyName>GEOM</ogc:PropertyName>
</ogc:PropertyIsNull>
</ogc:Filter>

And at the attachment file you can see the logs produced at geoserver.

The solution is to edit the java Class: org.geotools.data.oracle.OracleDialect replacing the following method:

--------------------------------------------------------
public Geometry decodeGeometryValue(GeometryDescriptor descriptor,
ResultSet rs, String column, GeometryFactory factory, Connection cx )
throws IOException, SQLException {

//read the geometry
Geometry geom = readGeometry( rs, column, factory, cx );

//grab the binding
Class targetClazz = descriptor.getType().getBinding();

// in Oracle you can have polygons in a column declared to be multipolygon, and so on...
// so we better convert geometries, since our feature model is not so lenient
if(targetClazz.equals(MultiPolygon.class) && geom instanceof Polygon){
if (geom == null) return factory.createMultiPolygon(null);// added avalls to suppport null/empty geometries
else return factory.createMultiPolygon(new Polygon[] {(Polygon) geom});
}
else if(targetClazz.equals(MultiPoint.class) && geom instanceof Point) {
if (geom == null) return factory.createGeometryCollection(null);// added avalls to suppport null/empty geometries
else return factory.createMultiPoint(new Point[] {(Point) geom});
}
else if(targetClazz.equals(MultiLineString.class) && geom instanceof LineString) {
if (geom == null) return factory.createMultiLineString(null);// added avalls to suppport null/empty geometries
else return factory.createMultiLineString(new LineString[] {(LineString) geom});
}
else if(targetClazz.equals(GeometryCollection.class)) {
if (geom == null) return factory.createGeometryCollection(null);// added avalls to suppport null/empty geometries
else return factory.createGeometryCollection(new Geometry[] {geom});
}
return geom;
}
--------------------------------------------------------

If you need further information don't hesitate to ask.

albert

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    geoserver FAILS.log
    07/Oct/09 4:20 AM
    208 kB
    albert valls
  2. Java Source File
    OracleDialect.java
    07/Oct/09 4:20 AM
    24 kB
    albert valls
  1. browser_error.gif
    82 kB
    07/Oct/09 4:20 AM

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Andrea Aime added a comment - 07/Oct/09 5:33 AM
So basically you're saying that it's necessary to create empty geometry collections?
That seems odd... it would be better to fix the code upstream that's not handling the null geometries properly. Do you have a full copy of the original stack trace?
Show
Andrea Aime added a comment - 07/Oct/09 5:33 AM So basically you're saying that it's necessary to create empty geometry collections? That seems odd... it would be better to fix the code upstream that's not handling the null geometries properly. Do you have a full copy of the original stack trace?
Hide
Permalink
Andrea Aime added a comment - 07/Oct/09 5:34 AM
Ok sorry, the log is there. Isn't a better solution to just return null straight if the geometry is null?
Show
Andrea Aime added a comment - 07/Oct/09 5:34 AM Ok sorry, the log is there. Isn't a better solution to just return null straight if the geometry is null?
Hide
Permalink
albert valls added a comment - 07/Oct/09 5:42 AM
I'm just pointing to a bug I've found, of course It would be better to fix the code upstream, but I haven't been able to do so. Maybe you can give a try.
Show
albert valls added a comment - 07/Oct/09 5:42 AM I'm just pointing to a bug I've found, of course It would be better to fix the code upstream, but I haven't been able to do so. Maybe you can give a try.
Hide
Permalink
Andrea Aime added a comment - 14/Mar/10 6:15 AM
Commited a fix for this one, sorry it took so long, I just forgot this issue even existed.
If you want to try out the fix you can grab a nightly build of GeoServer 2.0.x along with the associated Oracle plugin here:
http://gridlock.openplans.org/geoserver/2.0.x/
(starting from tomorrow March 14, today's nightly does not contain the fixes)
Show
Andrea Aime added a comment - 14/Mar/10 6:15 AM Commited a fix for this one, sorry it took so long, I just forgot this issue even existed. If you want to try out the fix you can grab a nightly build of GeoServer 2.0.x along with the associated Oracle plugin here: http://gridlock.openplans.org/geoserver/2.0.x/ (starting from tomorrow March 14, today's nightly does not contain the fixes)

People

  • Assignee:
    Andrea Aime
    Reporter:
    albert valls
Vote (0)
Watch (0)

Dates

  • Created:
    07/Oct/09 4:20 AM
    Updated:
    02/Jun/11 8:16 AM
    Resolved:
    14/Mar/10 6:15 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.