summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2016-06-10 11:50:07 +0500
committerTim Graham <timograham@gmail.com>2016-06-21 15:46:27 -0400
commit5ce660cd65a4ffcf74d94ba987fe03a16b7436a0 (patch)
tree5604cabb82104ac37dfec47da76cddb240156ef1 /django
parent20d1cb33c2ec1242e16c49deb88e8c70517b2d1a (diff)
Fixed #25940 -- Added OGRGeometry.from_gml() and GEOSGeometry.from_gml().
Diffstat (limited to 'django')
-rw-r--r--django/contrib/gis/gdal/geometries.py5
-rw-r--r--django/contrib/gis/gdal/prototypes/geom.py1
-rw-r--r--django/contrib/gis/geos/geometry.py4
3 files changed, 10 insertions, 0 deletions
diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
index 1d76da18d8..4407e147e5 100644
--- a/django/contrib/gis/gdal/geometries.py
+++ b/django/contrib/gis/gdal/geometries.py
@@ -52,6 +52,7 @@ from django.contrib.gis.gdal.prototypes import geom as capi, srs as srs_api
from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference
from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex
from django.utils import six
+from django.utils.encoding import force_bytes
from django.utils.six.moves import range
@@ -150,6 +151,10 @@ class OGRGeometry(GDALBase):
return OGRGeometry('POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % (
x0, y0, x0, y1, x1, y1, x1, y0, x0, y0))
+ @classmethod
+ def from_gml(cls, gml_string):
+ return cls(capi.from_gml(force_bytes(gml_string)))
+
# ### Geometry set-like operations ###
# g = g1 | g2
def __or__(self, other):
diff --git a/django/contrib/gis/gdal/prototypes/geom.py b/django/contrib/gis/gdal/prototypes/geom.py
index d1c43a47c2..aac8b99bae 100644
--- a/django/contrib/gis/gdal/prototypes/geom.py
+++ b/django/contrib/gis/gdal/prototypes/geom.py
@@ -44,6 +44,7 @@ getz = pnt_func(lgdal.OGR_G_GetZ)
# Geometry creation routines.
from_wkb = geom_output(lgdal.OGR_G_CreateFromWkb, [c_char_p, c_void_p, POINTER(c_void_p), c_int], offset=-2)
from_wkt = geom_output(lgdal.OGR_G_CreateFromWkt, [POINTER(c_char_p), c_void_p, POINTER(c_void_p)], offset=-1)
+from_gml = geom_output(lgdal.OGR_G_CreateFromGML, [c_char_p])
create_geom = geom_output(lgdal.OGR_G_CreateGeometry, [c_int])
clone_geom = geom_output(lgdal.OGR_G_Clone, [c_void_p])
get_geom_ref = geom_output(lgdal.OGR_G_GetGeometryRef, [c_void_p, c_int])
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index d0a9455659..66f78e70de 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -166,6 +166,10 @@ class GEOSGeometry(GEOSBase, ListMixin):
self.ptr = ptr
self._post_init(srid)
+ @classmethod
+ def from_gml(cls, gml_string):
+ return gdal.OGRGeometry.from_gml(gml_string).geos
+
# Comparison operators
def __eq__(self, other):
"""