Opened 9 years ago
Closed 9 years ago
#27557 closed Bug (fixed)
Overzealous GEOSGeometry sub-subclasses casts
| Reported by: | Claude Paroz | Owned by: | nobody |
|---|---|---|---|
| Component: | GIS | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Reported by Pete Flugstad in https://groups.google.com/forum/#!topic/geodjango/-tao0uPNYY8
When writing a Point, Polygon, etc. subclass, the parent GEOSGeometry._post_init is force casting the instance to one of the hardcoded GEOSGeometry subclass, which breaks method overriding of the subclass.
Example:
from django.contrib.gis.geos import Polygon
class ExtendedPolygon(Polygon):
def __init__(self, point_list, data=0 ):
super(ExtendedPolygon, self).__init__(point_list)
self._data = data
def __str__(self):
return "EXT_POLYGON - data: %d - %s" % (self._data, self.wkt )
>>> from extpoly import ExtendedPolygon
>>> points = ((-75.1, 34.3), (-74.9, 34.3), (-74.9, 34.4), (-75.1, 34.4), (-75.1, 34.3))
>>> ex = ExtendedPolygon( points, altitude=123, speed=456, direction=789 )
>>> print(ex)
POLYGON ((-75.09999999999999 34.3, -74.90000000000001 34.3, -74.90000000000001 34.4, -75.09999999999999 34.4, -75.09999999999999 34.3))
>>> type(ex)
<class 'django.contrib.gis.geos.polygon.Polygon'>
Change History (3)
comment:1 by , 9 years ago
| Has patch: | set |
|---|
comment:2 by , 9 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Note:
See TracTickets
for help on using tickets.
PR