mirror of
https://github.com/django/django.git
synced 2025-11-23 12:26:57 +00:00
Refs #27472 -- Fixed OGRGeometry('POINT EMPTY').geos crash.
This commit is contained in:
parent
65a1f32319
commit
a413ef2155
6 changed files with 35 additions and 3 deletions
|
|
@ -254,6 +254,10 @@ class OGRGeometry(GDALBase):
|
|||
# TODO: Fix Envelope() for Point geometries.
|
||||
return Envelope(capi.get_envelope(self.ptr, byref(OGREnvelope())))
|
||||
|
||||
@property
|
||||
def empty(self):
|
||||
return capi.is_empty(self.ptr)
|
||||
|
||||
@property
|
||||
def extent(self):
|
||||
"Returns the envelope as a 4-tuple, instead of as an Envelope object."
|
||||
|
|
@ -305,11 +309,15 @@ class OGRGeometry(GDALBase):
|
|||
srid = property(_get_srid, _set_srid)
|
||||
|
||||
# #### Output Methods ####
|
||||
def _geos_ptr(self):
|
||||
from django.contrib.gis.geos import GEOSGeometry
|
||||
return GEOSGeometry._from_wkb(self.wkb)
|
||||
|
||||
@property
|
||||
def geos(self):
|
||||
"Returns a GEOSGeometry object from this OGRGeometry."
|
||||
from django.contrib.gis.geos import GEOSGeometry
|
||||
return GEOSGeometry(self.wkb, self.srid)
|
||||
return GEOSGeometry(self._geos_ptr(), self.srid)
|
||||
|
||||
@property
|
||||
def gml(self):
|
||||
|
|
@ -504,6 +512,10 @@ class OGRGeometry(GDALBase):
|
|||
# The subclasses for OGR Geometry.
|
||||
class Point(OGRGeometry):
|
||||
|
||||
def _geos_ptr(self):
|
||||
from django.contrib.gis import geos
|
||||
return geos.Point._create_empty() if self.empty else super(Point, self)._geos_ptr()
|
||||
|
||||
@classmethod
|
||||
def _create_empty(cls):
|
||||
return capi.create_geom(OGRGeomType('point').num)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue