Refactored the GEOS interface. Improvements include:
* Geometries now allow list-like manipulation, e.g., can add, insert, delete vertexes (or other geometries in collections) like Python lists. Thanks, Aryeh Leib Taurog.
* Added support for GEOS prepared geometries via `prepared` property. Prepared geometries significantly speed up certain operations.
* Added support for GEOS cascaded union as `MultiPolygon.cascaded_union` property.
* Added support for GEOS line merge as `merged` property on `LineString`, and `MultiLineString` geometries. Thanks, Paul Smith.
* No longer use the deprecated C API for serialization to/from WKB and WKT. Now use the GEOS I/O classes, which are now exposed as `WKTReader`, `WKTWriter`, `WKBReader`, and `WKBWriter` (which supports 3D and SRID inclusion)
* Moved each type of geometry to their own module, eliminating the cluttered `geometries.py`.
* Internally, all C API methods are explicitly called from a module rather than a star import.
Fixed #9557, #9877, #10222
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10131 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-24 08:12:21 +08:00
|
|
|
"""
|
|
|
|
Module that holds classes for performing I/O operations on GEOS geometry
|
|
|
|
objects. Specifically, this has Python implementations of WKB/WKT
|
|
|
|
reader and writer classes.
|
|
|
|
"""
|
2009-03-29 00:36:48 +08:00
|
|
|
from django.contrib.gis.geos.geometry import GEOSGeometry
|
2010-01-13 02:40:54 +08:00
|
|
|
from django.contrib.gis.geos.prototypes.io import _WKTReader, _WKBReader, WKBWriter, WKTWriter
|
Refactored the GEOS interface. Improvements include:
* Geometries now allow list-like manipulation, e.g., can add, insert, delete vertexes (or other geometries in collections) like Python lists. Thanks, Aryeh Leib Taurog.
* Added support for GEOS prepared geometries via `prepared` property. Prepared geometries significantly speed up certain operations.
* Added support for GEOS cascaded union as `MultiPolygon.cascaded_union` property.
* Added support for GEOS line merge as `merged` property on `LineString`, and `MultiLineString` geometries. Thanks, Paul Smith.
* No longer use the deprecated C API for serialization to/from WKB and WKT. Now use the GEOS I/O classes, which are now exposed as `WKTReader`, `WKTWriter`, `WKBReader`, and `WKBWriter` (which supports 3D and SRID inclusion)
* Moved each type of geometry to their own module, eliminating the cluttered `geometries.py`.
* Internally, all C API methods are explicitly called from a module rather than a star import.
Fixed #9557, #9877, #10222
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10131 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-24 08:12:21 +08:00
|
|
|
|
2013-10-18 19:25:30 +08:00
|
|
|
__all__ = ['WKBWriter', 'WKTWriter', 'WKBReader', 'WKTReader']
|
|
|
|
|
2013-11-03 01:18:46 +08:00
|
|
|
|
2010-01-13 02:40:54 +08:00
|
|
|
# Public classes for (WKB|WKT)Reader, which return GEOSGeometry
|
2009-03-29 00:36:48 +08:00
|
|
|
class WKBReader(_WKBReader):
|
|
|
|
def read(self, wkb):
|
|
|
|
"Returns a GEOSGeometry for the given WKB buffer."
|
|
|
|
return GEOSGeometry(super(WKBReader, self).read(wkb))
|
|
|
|
|
2013-11-03 01:18:46 +08:00
|
|
|
|
2010-01-13 02:40:54 +08:00
|
|
|
class WKTReader(_WKTReader):
|
|
|
|
def read(self, wkt):
|
|
|
|
"Returns a GEOSGeometry for the given WKT string."
|
|
|
|
return GEOSGeometry(super(WKTReader, self).read(wkt))
|