Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#11827 closed Uncategorized (fixed)

GeoQuerySet extent() method fails if contains only one object with point geometry

Reported by: mal Owned by: nobody
Component: GIS Version: 1.1
Severity: Normal Keywords: oracle
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a point object, with valid, non null geometry.

qs=Point.objects.filter(id=123456)

qs is not empty and contains one object with non null point geometry.

Then, when calling

qs.extent()

i get the following error (as in the end of the stack trace):

     36             # the 4-tuple from the coordinates in the polygon.

     37             poly = SpatialBackend.Geometry(clob.read())
---> 38             shell = poly.shell
     39             ll, ur = shell[0], shell[2]
     40             xmin, ymin = ll

AttributeError: 'Point' object has no attribute 'shell'

Change History (7)

comment:1 by mal, 15 years ago

That happens with Oracle Spatial database

comment:2 by anonymous, 15 years ago

The reason seems to be that when calling "qs.extent" system executes sql like this:

SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_AGGR_MBR("POINT"."GEOMETRY")) AS geoagg FROM "POINT" WHERE "POINT"."ID" = 123456

so, it's a search by primary key, results in 1 object, and in Oracle (don't know about Postgis) SDO_AGGR_MBR on a collection that contains only one point will result in *point* object, not polygon...

comment:3 by Jani Tiainen, 15 years ago

Keywords: oracle added

Well this is "feature" of Oracle Spatial SDO_AGGR_MBR function. It's describes few "exceptions" as follows (excerpt from Oracle Spatial documentation):

  • This function does not return an MBR geometry if a proper MBR cannot be constructed. Specifically:
    • If the input geometries are all null, the function returns a null geometry.
    • If all data in the input geometries is on a single point, the function returns the point.
    • If all data in the input geometries consists of points on a straight line, the function returns a two-point line.

AFAIK at least PostGIS uses st_extent for extent() method which always returns real bounding box.

comment:4 by anonymous, 15 years ago

Yes, it's documented Oracle behavior, so it's a bug in the geodjango code.

comment:5 by jbronn, 15 years ago

Resolution: fixed
Status: newclosed

(In [11577]) Fixed #11827: Can now calculate extent in Oracle on tables with one point.

comment:6 by jbronn, 15 years ago

(In [11578]) [1.1.X] Fixed #11827: Can now calculate extent in Oracle on tables with one point.

Backport of r11577 from trunk.

comment:7 by anonymous, 13 years ago

Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset

Apparently it still crashes in this case (Oracle):

"If all data in the input geometries consists of points on a straight line, the function returns a two-point line."

Note: See TracTickets for help on using tickets.
Back to Top