Code

Opened 5 years ago

Closed 5 years ago

Last modified 2 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'

Attachments (0)

Change History (7)

comment:1 Changed 5 years ago by mal

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

That happens with Oracle Spatial database

comment:2 Changed 5 years ago by anonymous

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 Changed 5 years ago by jtiai

  • 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 Changed 5 years ago by anonymous

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

comment:5 Changed 5 years ago by jbronn

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:6 Changed 5 years ago by jbronn

(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 Changed 2 years ago by anonymous

  • Easy pickings unset
  • Severity set to Normal
  • Type set to 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."

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.