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 00:12:21 +00:00
|
|
|
# Copyright (c) 2008-2009 Aryeh Leib Taurog, all rights reserved.
|
|
|
|
# Modified from original contribution by Aryeh Leib Taurog, which was
|
|
|
|
# released under the New BSD license.
|
2009-12-17 22:06:41 +00:00
|
|
|
|
2013-07-01 12:22:27 +00:00
|
|
|
import unittest
|
2013-05-11 03:08:45 +00:00
|
|
|
|
2015-04-24 15:24:07 +00:00
|
|
|
from django.contrib.gis.geos import (
|
2017-05-04 15:03:23 +00:00
|
|
|
LinearRing,
|
|
|
|
LineString,
|
|
|
|
MultiPoint,
|
|
|
|
Point,
|
|
|
|
Polygon,
|
|
|
|
fromstr,
|
2015-04-24 15:24:07 +00:00
|
|
|
)
|
2013-05-11 03:08:45 +00:00
|
|
|
|
|
|
|
|
2015-04-24 15:24:07 +00:00
|
|
|
def api_get_distance(x):
|
|
|
|
return x.distance(Point(-200, -200))
|
2013-10-17 08:17:41 +00:00
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_buffer(x):
|
|
|
|
return x.buffer(10)
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_geom_typeid(x):
|
|
|
|
return x.geom_typeid
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_num_coords(x):
|
|
|
|
return x.num_coords
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_centroid(x):
|
|
|
|
return x.centroid
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_empty(x):
|
|
|
|
return x.empty
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_valid(x):
|
|
|
|
return x.valid
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_simple(x):
|
|
|
|
return x.simple
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_ring(x):
|
|
|
|
return x.ring
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_boundary(x):
|
|
|
|
return x.boundary
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_convex_hull(x):
|
|
|
|
return x.convex_hull
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_extent(x):
|
|
|
|
return x.extent
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_area(x):
|
|
|
|
return x.area
|
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def api_get_length(x):
|
|
|
|
return x.length
|
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 00:12:21 +00:00
|
|
|
|
2016-11-12 17:11:23 +00:00
|
|
|
|
2016-04-04 00:37:32 +00:00
|
|
|
geos_function_tests = [
|
|
|
|
val
|
|
|
|
for name, val in vars().items()
|
|
|
|
if hasattr(val, "__call__") and name.startswith("api_get_")
|
|
|
|
]
|
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 00:12:21 +00:00
|
|
|
|
2013-05-11 03:08:45 +00:00
|
|
|
|
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 00:12:21 +00:00
|
|
|
class GEOSMutationTest(unittest.TestCase):
|
|
|
|
"""
|
|
|
|
Tests Pythonic Mutability of Python GEOS geometry wrappers
|
|
|
|
get/set/delitem on a slice, normal list methods
|
|
|
|
"""
|
|
|
|
|
|
|
|
def test00_GEOSIndexException(self):
|
2015-08-12 12:42:01 +00:00
|
|
|
"Testing Geometry IndexError"
|
2013-10-24 17:30:03 +00:00
|
|
|
p = Point(1, 2)
|
|
|
|
for i in range(-2, 2):
|
2013-10-17 08:17:41 +00:00
|
|
|
p._checkindex(i)
|
2016-01-17 11:26:39 +00:00
|
|
|
with self.assertRaises(IndexError):
|
|
|
|
p._checkindex(2)
|
|
|
|
with self.assertRaises(IndexError):
|
|
|
|
p._checkindex(-3)
|
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 00:12:21 +00:00
|
|
|
|
|
|
|
def test01_PointMutations(self):
|
|
|
|
"Testing Point mutations"
|
2013-10-24 17:30:03 +00:00
|
|
|
for p in (Point(1, 2, 3), fromstr("POINT (1 2 3)")):
|
2009-04-10 18:32:17 +00:00
|
|
|
self.assertEqual(
|
|
|
|
p._get_single_external(1), 2.0, "Point _get_single_external"
|
|
|
|
)
|
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 00:12:21 +00:00
|
|
|
|
|
|
|
# _set_single
|
2013-10-24 17:30:03 +00:00
|
|
|
p._set_single(0, 100)
|
|
|
|
self.assertEqual(p.coords, (100.0, 2.0, 3.0), "Point _set_single")
|
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 00:12:21 +00:00
|
|
|
|
2009-04-10 18:32:17 +00:00
|
|
|
# _set_list
|
2013-10-24 17:30:03 +00:00
|
|
|
p._set_list(2, (50, 3141))
|
|
|
|
self.assertEqual(p.coords, (50.0, 3141.0), "Point _set_list")
|
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 00:12:21 +00:00
|
|
|
|
|
|
|
def test02_PointExceptions(self):
|
|
|
|
"Testing Point exceptions"
|
2016-01-17 11:26:39 +00:00
|
|
|
with self.assertRaises(TypeError):
|
|
|
|
Point(range(1))
|
|
|
|
with self.assertRaises(TypeError):
|
|
|
|
Point(range(4))
|
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 00:12:21 +00:00
|
|
|
|
|
|
|
def test03_PointApi(self):
|
|
|
|
"Testing Point API"
|
2013-10-24 17:30:03 +00:00
|
|
|
q = Point(4, 5, 3)
|
|
|
|
for p in (Point(1, 2, 3), fromstr("POINT (1 2 3)")):
|
|
|
|
p[0:2] = [4, 5]
|
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 00:12:21 +00:00
|
|
|
for f in geos_function_tests:
|
|
|
|
self.assertEqual(f(q), f(p), "Point " + f.__name__)
|
|
|
|
|
|
|
|
def test04_LineStringMutations(self):
|
|
|
|
"Testing LineString mutations"
|
2013-10-24 17:30:03 +00:00
|
|
|
for ls in (
|
|
|
|
LineString((1, 0), (4, 1), (6, -1)),
|
2013-12-12 20:23:24 +00:00
|
|
|
fromstr("LINESTRING (1 0,4 1,6 -1)"),
|
|
|
|
):
|
2013-10-24 17:30:03 +00:00
|
|
|
self.assertEqual(
|
|
|
|
ls._get_single_external(1),
|
|
|
|
(4.0, 1.0),
|
|
|
|
"LineString _get_single_external",
|
|
|
|
)
|
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 00:12:21 +00:00
|
|
|
|
|
|
|
# _set_single
|
2013-10-24 17:30:03 +00:00
|
|
|
ls._set_single(0, (-50, 25))
|
2013-10-26 17:50:40 +00:00
|
|
|
self.assertEqual(
|
|
|
|
ls.coords,
|
|
|
|
((-50.0, 25.0), (4.0, 1.0), (6.0, -1.0)),
|
|
|
|
"LineString _set_single",
|
|
|
|
)
|
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 00:12:21 +00:00
|
|
|
|
2009-04-10 18:32:17 +00:00
|
|
|
# _set_list
|
2013-10-24 17:30:03 +00:00
|
|
|
ls._set_list(2, ((-50.0, 25.0), (6.0, -1.0)))
|
|
|
|
self.assertEqual(
|
|
|
|
ls.coords, ((-50.0, 25.0), (6.0, -1.0)), "LineString _set_list"
|
|
|
|
)
|
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 00:12:21 +00:00
|
|
|
|
|
|
|
lsa = LineString(ls.coords)
|
|
|
|
for f in geos_function_tests:
|
|
|
|
self.assertEqual(f(lsa), f(ls), "LineString " + f.__name__)
|
|
|
|
|
|
|
|
def test05_Polygon(self):
|
|
|
|
"Testing Polygon mutations"
|
2013-10-26 17:50:40 +00:00
|
|
|
for pg in (
|
|
|
|
Polygon(
|
|
|
|
((1, 0), (4, 1), (6, -1), (8, 10), (1, 0)),
|
2013-12-12 20:23:24 +00:00
|
|
|
((5, 4), (6, 4), (6, 3), (5, 4)),
|
2022-02-03 19:24:19 +00:00
|
|
|
),
|
2013-12-12 20:23:24 +00:00
|
|
|
fromstr("POLYGON ((1 0,4 1,6 -1,8 10,1 0),(5 4,6 4,6 3,5 4))"),
|
|
|
|
):
|
2009-04-10 18:32:17 +00:00
|
|
|
self.assertEqual(
|
|
|
|
pg._get_single_external(0),
|
2013-12-12 20:23:24 +00:00
|
|
|
LinearRing((1, 0), (4, 1), (6, -1), (8, 10), (1, 0)),
|
|
|
|
"Polygon _get_single_external(0)",
|
|
|
|
)
|
2009-04-10 18:32:17 +00:00
|
|
|
self.assertEqual(
|
|
|
|
pg._get_single_external(1),
|
2013-12-12 20:23:24 +00:00
|
|
|
LinearRing((5, 4), (6, 4), (6, 3), (5, 4)),
|
|
|
|
"Polygon _get_single_external(1)",
|
|
|
|
)
|
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 00:12:21 +00:00
|
|
|
|
2009-04-10 18:32:17 +00:00
|
|
|
# _set_list
|
2016-04-08 02:04:45 +00:00
|
|
|
pg._set_list(
|
|
|
|
2,
|
|
|
|
(
|
|
|
|
((1, 2), (10, 0), (12, 9), (-1, 15), (1, 2)),
|
|
|
|
((4, 2), (5, 2), (5, 3), (4, 2)),
|
2022-02-03 19:24:19 +00:00
|
|
|
),
|
2016-04-08 02:04:45 +00:00
|
|
|
)
|
2013-10-19 23:33:10 +00:00
|
|
|
self.assertEqual(
|
|
|
|
pg.coords,
|
2022-02-03 19:24:19 +00:00
|
|
|
(
|
2013-10-26 17:50:40 +00:00
|
|
|
((1.0, 2.0), (10.0, 0.0), (12.0, 9.0), (-1.0, 15.0), (1.0, 2.0)),
|
|
|
|
((4.0, 2.0), (5.0, 2.0), (5.0, 3.0), (4.0, 2.0)),
|
2022-02-03 19:24:19 +00:00
|
|
|
),
|
2013-10-19 23:33:10 +00:00
|
|
|
"Polygon _set_list",
|
|
|
|
)
|
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 00:12:21 +00:00
|
|
|
|
|
|
|
lsa = Polygon(*pg.coords)
|
|
|
|
for f in geos_function_tests:
|
|
|
|
self.assertEqual(f(lsa), f(pg), "Polygon " + f.__name__)
|
|
|
|
|
|
|
|
def test06_Collection(self):
|
|
|
|
"Testing Collection mutations"
|
2016-04-08 02:04:45 +00:00
|
|
|
points = (
|
|
|
|
MultiPoint(*map(Point, ((3, 4), (-1, 2), (5, -4), (2, 8)))),
|
|
|
|
fromstr("MULTIPOINT (3 4,-1 2,5 -4,2 8)"),
|
|
|
|
)
|
|
|
|
for mp in points:
|
2013-10-26 17:50:40 +00:00
|
|
|
self.assertEqual(
|
|
|
|
mp._get_single_external(2),
|
|
|
|
Point(5, -4),
|
|
|
|
"Collection _get_single_external",
|
|
|
|
)
|
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 00:12:21 +00:00
|
|
|
|
2013-10-26 17:50:40 +00:00
|
|
|
mp._set_list(3, map(Point, ((5, 5), (3, -2), (8, 1))))
|
|
|
|
self.assertEqual(
|
|
|
|
mp.coords, ((5.0, 5.0), (3.0, -2.0), (8.0, 1.0)), "Collection _set_list"
|
|
|
|
)
|
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 00:12:21 +00:00
|
|
|
|
2013-10-26 17:50:40 +00:00
|
|
|
lsa = MultiPoint(*map(Point, ((5, 5), (3, -2), (8, 1))))
|
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 00:12:21 +00:00
|
|
|
for f in geos_function_tests:
|
|
|
|
self.assertEqual(f(lsa), f(mp), "MultiPoint " + f.__name__)
|