Refs #27472 -- Fixed OGRGeometry('POINT EMPTY').geos crash.

This commit is contained in:
Sergey Fedoseev 2016-12-02 13:18:41 +05:00 committed by Tim Graham
parent 65a1f32319
commit a413ef2155
6 changed files with 35 additions and 3 deletions

View file

@ -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)