[2.1.x] Fixed #29460 -- Added support for GEOS 3.6.

Backport of f185d929fa from master
This commit is contained in:
Tim Graham 2018-05-31 11:35:59 -04:00
parent 31b9cf97b9
commit 67665e0979
4 changed files with 12 additions and 5 deletions

View File

@ -2,7 +2,9 @@ import threading
from ctypes import POINTER, Structure, byref, c_byte, c_char_p, c_int, c_size_t
from django.contrib.gis.geos.base import GEOSBase
from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory
from django.contrib.gis.geos.libgeos import (
GEOM_PTR, GEOSFuncFactory, geos_version_tuple,
)
from django.contrib.gis.geos.prototypes.errcheck import (
check_geom, check_sized_string, check_string,
)
@ -233,7 +235,7 @@ class WKBWriter(IOBase):
from django.contrib.gis.geos import Polygon
geom = self._handle_empty_point(geom)
wkb = wkb_writer_write(self.ptr, geom.ptr, byref(c_size_t()))
if isinstance(geom, Polygon) and geom.empty:
if geos_version_tuple() < (3, 6, 1) and isinstance(geom, Polygon) and geom.empty:
# Fix GEOS output for empty polygon.
# See https://trac.osgeo.org/geos/ticket/680.
wkb = wkb[:-8] + b'\0' * 4
@ -244,7 +246,7 @@ class WKBWriter(IOBase):
from django.contrib.gis.geos.polygon import Polygon
geom = self._handle_empty_point(geom)
wkb = wkb_writer_write_hex(self.ptr, geom.ptr, byref(c_size_t()))
if isinstance(geom, Polygon) and geom.empty:
if geos_version_tuple() < (3, 6, 1) and isinstance(geom, Polygon) and geom.empty:
wkb = wkb[:-16] + b'0' * 8
return wkb

View File

@ -8,7 +8,7 @@ geospatial libraries:
======================== ==================================== ================================ ===================================
Program Description Required Supported Versions
======================== ==================================== ================================ ===================================
:doc:`GEOS <../geos>` Geometry Engine Open Source Yes 3.5, 3.4
:doc:`GEOS <../geos>` Geometry Engine Open Source Yes 3.6, 3.5, 3.4
`PROJ.4`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 4.9, 4.8, 4.7, 4.6, 4.5, 4.4
:doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 2.2, 2.1, 2.0, 1.11, 1.10, 1.9
:doc:`GeoIP <../geoip2>` IP-based geolocation library No 2
@ -23,6 +23,7 @@ totally fine with GeoDjango. Your mileage may vary.
Libs release dates:
GEOS 3.4.0 2013-08-11
GEOS 3.5.0 2015-08-15
GEOS 3.6.0 2016-10-25
GDAL 1.9.0 2012-01-03
GDAL 1.10.0 2013-04-29
GDAL 1.11.0 2014-04-25

View File

@ -9,4 +9,5 @@ Django 1.11.14 fixes several bugs in 1.11.13.
Bugfixes
========
* ...
* Fixed ``WKBWriter.write()`` and ``write_hex()`` for empty polygons on
GEOS 3.6.1+ (:ticket:`29460`).

View File

@ -17,3 +17,6 @@ Bugfixes
* Fixed a regression that added an unnecessary subquery to the ``GROUP BY``
clause on MySQL when using a ``RawSQL`` annotation (:ticket:`29416`).
* Fixed ``WKBWriter.write()`` and ``write_hex()`` for empty polygons on
GEOS 3.6.1+ (:ticket:`29460`).