Commit 5ce660cd authored by Sergey Fedoseev's avatar Sergey Fedoseev Committed by Tim Graham
Browse files

Fixed #25940 -- Added OGRGeometry.from_gml() and GEOSGeometry.from_gml().

parent 20d1cb33
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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):
+1 −0
Original line number Diff line number Diff line
@@ -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])
+4 −0
Original line number Diff line number Diff line
@@ -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):
        """
+6 −0
Original line number Diff line number Diff line
@@ -448,6 +448,12 @@ coordinate transformation::

    __ http://www.gdal.org/classOGRGeometry.html

    .. classmethod:: from_gml(gml_string)

    .. versionadded:: 1.11

    Constructs an :class:`OGRGeometry` from the given GML string.

    .. classmethod:: from_bbox(bbox)

    Constructs a :class:`Polygon` from the given bounding-box (a 4-tuple).
+6 −0
Original line number Diff line number Diff line
@@ -198,6 +198,12 @@ WKB / EWKB ``buffer``
GeoJSON                  ``str`` or ``unicode``
=======================  ======================

.. classmethod:: GEOSGeometry.from_gml(gml_string)

    .. versionadded:: 1.11

    Constructs a :class:`GEOSGeometry` from the given GML string.

Properties
~~~~~~~~~~

Loading