shapely 1.5.4__tar.gz → 1.5.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. {Shapely-1.5.4 → Shapely-1.5.5}/CHANGES.txt +4 -0
  2. {Shapely-1.5.4/Shapely.egg-info → Shapely-1.5.5}/PKG-INFO +5 -1
  3. {Shapely-1.5.4 → Shapely-1.5.5/Shapely.egg-info}/PKG-INFO +5 -1
  4. {Shapely-1.5.4 → Shapely-1.5.5}/Shapely.egg-info/SOURCES.txt +2 -0
  5. Shapely-1.5.5/VERSION.txt +1 -0
  6. {Shapely-1.5.4 → Shapely-1.5.5}/setup.py +5 -1
  7. Shapely-1.5.5/shapely/__init__.py +1 -0
  8. Shapely-1.5.5/shapely/_geos.pxi +58 -0
  9. Shapely-1.5.5/shapely/speedups/_speedups.pyx +498 -0
  10. Shapely-1.5.4/VERSION.txt +0 -1
  11. Shapely-1.5.4/shapely/__init__.py +0 -1
  12. {Shapely-1.5.4 → Shapely-1.5.5}/CREDITS.txt +0 -0
  13. {Shapely-1.5.4 → Shapely-1.5.5}/LICENSE.txt +0 -0
  14. {Shapely-1.5.4 → Shapely-1.5.5}/README.rst +0 -0
  15. {Shapely-1.5.4 → Shapely-1.5.5}/Shapely.egg-info/dependency_links.txt +0 -0
  16. {Shapely-1.5.4 → Shapely-1.5.5}/Shapely.egg-info/top_level.txt +0 -0
  17. {Shapely-1.5.4 → Shapely-1.5.5}/docs/design.rst +0 -0
  18. {Shapely-1.5.4 → Shapely-1.5.5}/docs/index.rst +0 -0
  19. {Shapely-1.5.4 → Shapely-1.5.5}/docs/manual.rst +0 -0
  20. {Shapely-1.5.4 → Shapely-1.5.5}/docs/project.rst +0 -0
  21. {Shapely-1.5.4 → Shapely-1.5.5}/setup.cfg +1 -1
  22. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/affinity.py +0 -0
  23. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/algorithms/__init__.py +0 -0
  24. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/algorithms/cga.py +0 -0
  25. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/coords.py +0 -0
  26. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/ctypes_declarations.py +0 -0
  27. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/examples/__init__.py +0 -0
  28. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/examples/dissolve.py +0 -0
  29. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/examples/geoms.py +0 -0
  30. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/examples/intersect.py +0 -0
  31. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/ftools.py +0 -0
  32. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/__init__.py +0 -0
  33. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/base.py +0 -0
  34. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/collection.py +0 -0
  35. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/geo.py +0 -0
  36. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/linestring.py +0 -0
  37. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/multilinestring.py +0 -0
  38. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/multipoint.py +0 -0
  39. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/multipolygon.py +0 -0
  40. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/point.py +0 -0
  41. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/polygon.py +0 -0
  42. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geometry/proxy.py +0 -0
  43. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/geos.py +0 -0
  44. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/impl.py +0 -0
  45. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/iterops.py +0 -0
  46. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/linref.py +0 -0
  47. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/ops.py +0 -0
  48. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/predicates.py +0 -0
  49. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/prepared.py +0 -0
  50. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/speedups/__init__.py +0 -0
  51. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/speedups/_speedups.c +0 -0
  52. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/strtree.py +0 -0
  53. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/topology.py +0 -0
  54. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/validation.py +0 -0
  55. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/vectorized/__init__.py +0 -0
  56. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/vectorized/_vectorized.pyx +0 -0
  57. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/wkb.py +0 -0
  58. {Shapely-1.5.4 → Shapely-1.5.5}/shapely/wkt.py +0 -0
  59. {Shapely-1.5.4 → Shapely-1.5.5}/tests/__init__.py +0 -0
  60. {Shapely-1.5.4 → Shapely-1.5.5}/tests/binascii_hex.txt +0 -0
  61. {Shapely-1.5.4 → Shapely-1.5.5}/tests/conftest.py +0 -0
  62. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_affinity.py +0 -0
  63. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_box.py +0 -0
  64. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_cga.py +0 -0
  65. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_collection.py +0 -0
  66. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_coords.py +0 -0
  67. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_delaunay.py +0 -0
  68. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_delegated.py +0 -0
  69. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_dlls.py +0 -0
  70. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_doctests.py +0 -0
  71. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_emptiness.py +0 -0
  72. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_equality.py +0 -0
  73. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_geointerface.py +0 -0
  74. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_geomseq.py +0 -0
  75. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_getitem.py +0 -0
  76. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_hash.py +0 -0
  77. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_invalid_geometries.py +0 -0
  78. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_iterops.py +0 -0
  79. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_linear_referencing.py +0 -0
  80. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_linemerge.py +0 -0
  81. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_linestring.py +0 -0
  82. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_locale.py +0 -0
  83. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_mapping.py +0 -0
  84. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_multilinestring.py +0 -0
  85. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_multipoint.py +0 -0
  86. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_multipolygon.py +0 -0
  87. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_ndarrays.py +0 -0
  88. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_nearest.py +0 -0
  89. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_operations.py +0 -0
  90. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_operators.py +0 -0
  91. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_persist.py +0 -0
  92. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_pickle.py +0 -0
  93. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_point.py +0 -0
  94. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_polygon.py +0 -0
  95. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_polygonize.py +0 -0
  96. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_predicates.py +0 -0
  97. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_prepared.py +0 -0
  98. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_products_z.py +0 -0
  99. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_singularity.py +0 -0
  100. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_snap.py +0 -0
  101. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_strtree.py +0 -0
  102. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_styles.py +0 -0
  103. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_transform.py +0 -0
  104. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_union.py +0 -0
  105. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_validation.py +0 -0
  106. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_vectorized.py +0 -0
  107. {Shapely-1.5.4 → Shapely-1.5.5}/tests/test_xy.py +0 -0
  108. {Shapely-1.5.4 → Shapely-1.5.5}/tests/threading_test.py +0 -0
@@ -1,6 +1,10 @@
1
1
  Changes
2
2
  =======
3
3
 
4
+ 1.5.5 (2015-01-20)
5
+ ------------------
6
+ - MANIFEST changes to restore _geox.pxi (#231).
7
+
4
8
  1.5.4 (2015-01-19)
5
9
  ------------------
6
10
  - Fixed OS X binary wheel library load path (#224).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: Shapely
3
- Version: 1.5.4
3
+ Version: 1.5.5
4
4
  Summary: Geometric objects, predicates, and operations
5
5
  Home-page: https://github.com/Toblerity/Shapely
6
6
  Author: Sean Gillies
@@ -215,6 +215,10 @@ Description: =======
215
215
  Changes
216
216
  =======
217
217
 
218
+ 1.5.5 (2015-01-20)
219
+ ------------------
220
+ - MANIFEST changes to restore _geox.pxi (#231).
221
+
218
222
  1.5.4 (2015-01-19)
219
223
  ------------------
220
224
  - Fixed OS X binary wheel library load path (#224).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: Shapely
3
- Version: 1.5.4
3
+ Version: 1.5.5
4
4
  Summary: Geometric objects, predicates, and operations
5
5
  Home-page: https://github.com/Toblerity/Shapely
6
6
  Author: Sean Gillies
@@ -215,6 +215,10 @@ Description: =======
215
215
  Changes
216
216
  =======
217
217
 
218
+ 1.5.5 (2015-01-20)
219
+ ------------------
220
+ - MANIFEST changes to restore _geox.pxi (#231).
221
+
218
222
  1.5.4 (2015-01-19)
219
223
  ------------------
220
224
  - Fixed OS X binary wheel library load path (#224).
@@ -13,6 +13,7 @@ docs/index.rst
13
13
  docs/manual.rst
14
14
  docs/project.rst
15
15
  shapely/__init__.py
16
+ shapely/_geos.pxi
16
17
  shapely/affinity.py
17
18
  shapely/coords.py
18
19
  shapely/ctypes_declarations.py
@@ -48,6 +49,7 @@ shapely/geometry/polygon.py
48
49
  shapely/geometry/proxy.py
49
50
  shapely/speedups/__init__.py
50
51
  shapely/speedups/_speedups.c
52
+ shapely/speedups/_speedups.pyx
51
53
  shapely/vectorized/__init__.py
52
54
  shapely/vectorized/_vectorized.pyx
53
55
  tests/__init__.py
@@ -0,0 +1 @@
1
+ 1.5.5
@@ -257,12 +257,13 @@ ext_modules = [
257
257
  include_dirs=[get_config_var('INCLUDEDIR')],),
258
258
  ]
259
259
 
260
+ cmd_classes = setup_args.setdefault('cmdclass', {})
261
+
260
262
  try:
261
263
  import numpy as np
262
264
  from Cython.Distutils import build_ext as cython_build_ext
263
265
  from distutils.extension import Extension as DistutilsExtension
264
266
 
265
- cmd_classes = setup_args.setdefault('cmdclass', {})
266
267
  if 'build_ext' in cmd_classes:
267
268
  raise ValueError('We need to put the Cython build_ext in '
268
269
  'cmd_classes, but it is already defined.')
@@ -295,6 +296,9 @@ except BuildFailed as ex:
295
296
  print("Failure information, if any, is above.")
296
297
  print("I'm retrying the build without the C extension now.")
297
298
 
299
+ if 'build_ext' in cmd_classes:
300
+ del cmd_classes['build_ext']
301
+
298
302
  setup(**setup_args)
299
303
 
300
304
  print(BUILD_EXT_WARNING)
@@ -0,0 +1 @@
1
+ __version__ = "1.5.5"
@@ -0,0 +1,58 @@
1
+ # The beginnings of a Cython definition of GEOS. In the future much of this
2
+ # could be auto-generated.
3
+
4
+ ctypedef long ptr
5
+
6
+
7
+ cdef extern from "geos_c.h":
8
+ ctypedef void *GEOSContextHandle_t
9
+ ctypedef struct GEOSGeometry
10
+ ctypedef struct GEOSCoordSequence
11
+ ctypedef struct GEOSPreparedGeometry
12
+
13
+ GEOSCoordSequence *GEOSCoordSeq_create_r(GEOSContextHandle_t, unsigned int, unsigned int) nogil
14
+ GEOSCoordSequence *GEOSGeom_getCoordSeq_r(GEOSContextHandle_t, GEOSGeometry *) nogil
15
+
16
+ int GEOSCoordSeq_getSize_r(GEOSContextHandle_t, GEOSCoordSequence *, int *) nogil
17
+ int GEOSCoordSeq_setX_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double) nogil
18
+ int GEOSCoordSeq_setY_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double) nogil
19
+ int GEOSCoordSeq_setZ_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double) nogil
20
+ int GEOSCoordSeq_getX_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double *) nogil
21
+ int GEOSCoordSeq_getY_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double *) nogil
22
+ int GEOSCoordSeq_getZ_r(GEOSContextHandle_t, GEOSCoordSequence *, int, double *) nogil
23
+
24
+ GEOSGeometry *GEOSGeom_createPoint_r(GEOSContextHandle_t, GEOSCoordSequence *) nogil
25
+ GEOSGeometry *GEOSGeom_createLineString_r(GEOSContextHandle_t, GEOSCoordSequence *) nogil
26
+ GEOSGeometry *GEOSGeom_createLinearRing_r(GEOSContextHandle_t, GEOSCoordSequence *) nogil
27
+ GEOSGeometry *GEOSGeom_clone_r(GEOSContextHandle_t, GEOSGeometry *) nogil
28
+ GEOSCoordSequence *GEOSCoordSeq_clone_r(GEOSContextHandle_t, GEOSCoordSequence *) nogil
29
+
30
+ void GEOSGeom_destroy_r(GEOSContextHandle_t, GEOSGeometry *) nogil
31
+
32
+ char GEOSPreparedContains_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
33
+ char GEOSPreparedContainsProperly_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
34
+ char GEOSPreparedCoveredBy_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
35
+ char GEOSPreparedCovers_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
36
+ char GEOSPreparedCrosses_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
37
+ char GEOSPreparedDisjoint_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
38
+ char GEOSPreparedIntersects_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
39
+ char GEOSPreparedOverlaps_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
40
+ char GEOSPreparedTouches_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
41
+ char GEOSPreparedWithin_r(GEOSContextHandle_t, const GEOSPreparedGeometry*, const GEOSGeometry*) nogil
42
+
43
+ char GEOSHasZ_r(GEOSContextHandle_t, GEOSGeometry *) nogil
44
+ char GEOSisRing_r(GEOSContextHandle_t, GEOSGeometry *) nogil
45
+ char GEOSisClosed_r(GEOSContextHandle_t, GEOSGeometry *) nogil
46
+
47
+
48
+ cdef GEOSContextHandle_t get_geos_context_handle():
49
+ # Note: This requires that lgeos is defined, so needs to be imported as:
50
+ from shapely.geos import lgeos
51
+ cdef ptr handle = lgeos.geos_handle
52
+ return <GEOSContextHandle_t>handle
53
+
54
+
55
+ cdef GEOSPreparedGeometry *geos_from_prepared(shapely_geom) except *:
56
+ """Get the Prepared GEOS geometry pointer from the given shapely geometry."""
57
+ cdef ptr geos_geom = shapely_geom._geom
58
+ return <GEOSPreparedGeometry *>geos_geom
@@ -0,0 +1,498 @@
1
+ # geos_linestring_from_py was transcribed from shapely.geometry.linestring
2
+ # geos_linearring_from_py was transcribed from shapely.geometry.polygon
3
+ # coordseq_ctypes was transcribed from shapely.coords.CoordinateSequence.ctypes
4
+ #
5
+ # Copyright (c) 2007, Sean C. Gillies
6
+ # Transcription to cython: Copyright (c) 2011, Oliver Tonnhofer
7
+
8
+ import ctypes
9
+
10
+ from shapely.coords import required
11
+ from shapely.geos import lgeos
12
+ from shapely.geometry import Point, LineString, LinearRing
13
+ from shapely.geometry.base import geom_factory
14
+
15
+ include "../_geos.pxi"
16
+
17
+
18
+ cdef inline GEOSGeometry *cast_geom(unsigned long geom_addr):
19
+ return <GEOSGeometry *>geom_addr
20
+
21
+
22
+ cdef inline GEOSContextHandle_t cast_handle(unsigned long handle_addr):
23
+ return <GEOSContextHandle_t>handle_addr
24
+
25
+
26
+ cdef inline GEOSCoordSequence *cast_seq(unsigned long handle_addr):
27
+ return <GEOSCoordSequence *>handle_addr
28
+
29
+
30
+ def destroy(geom):
31
+ GEOSGeom_destroy_r(cast_handle(lgeos.geos_handle), cast_geom(geom))
32
+
33
+
34
+ def geos_linestring_from_py(ob, update_geom=None, update_ndim=0):
35
+ cdef double *cp
36
+ cdef GEOSContextHandle_t handle = cast_handle(lgeos.geos_handle)
37
+ cdef GEOSCoordSequence *cs
38
+ cdef GEOSGeometry *g
39
+ cdef double dx, dy, dz
40
+ cdef int i, n, m, sm, sn
41
+
42
+ # If a LineString is passed in, just clone it and return
43
+ # If a LinearRing is passed in, clone the coord seq and return a LineString
44
+ if isinstance(ob, LineString):
45
+ g = cast_geom(ob._geom)
46
+ if GEOSHasZ_r(handle, g):
47
+ n = 3
48
+ else:
49
+ n = 2
50
+
51
+ if type(ob) == LineString:
52
+ return <unsigned long>GEOSGeom_clone_r(handle, g), n
53
+ else:
54
+ cs = GEOSGeom_getCoordSeq_r(handle, g)
55
+ cs = GEOSCoordSeq_clone_r(handle, cs)
56
+ return <unsigned long>GEOSGeom_createLineString_r(handle, cs), n
57
+
58
+ # If numpy is present, we use numpy.require to ensure that we have a
59
+ # C-continguous array that owns its data. View data will be copied.
60
+ ob = required(ob)
61
+ try:
62
+ # From array protocol
63
+ array = ob.__array_interface__
64
+ assert len(array['shape']) == 2
65
+ m = array['shape'][0]
66
+ if m < 2:
67
+ raise ValueError(
68
+ "LineStrings must have at least 2 coordinate tuples")
69
+ try:
70
+ n = array['shape'][1]
71
+ except IndexError:
72
+ raise ValueError(
73
+ "Input %s is the wrong shape for a LineString" % str(ob))
74
+ assert n == 2 or n == 3
75
+
76
+ # Make pointer to the coordinate array
77
+ if isinstance(array['data'], ctypes.Array):
78
+ cp = <double *><unsigned long>ctypes.addressof(array['data'])
79
+ else:
80
+ cp = <double *><unsigned long>array['data'][0]
81
+
82
+ # Use strides to properly index into cp
83
+ # ob[i, j] == cp[sm*i + sn*j]
84
+ # Just to avoid a referenced before assignment warning.
85
+ dx = 0
86
+ if array.get('strides', None):
87
+ sm = array['strides'][0]/sizeof(dx)
88
+ sn = array['strides'][1]/sizeof(dx)
89
+ else:
90
+ sm = n
91
+ sn = 1
92
+
93
+ # Create a coordinate sequence
94
+ if update_geom is not None:
95
+ cs = GEOSGeom_getCoordSeq_r(handle, cast_geom(update_geom))
96
+ if n != update_ndim:
97
+ raise ValueError(
98
+ "Wrong coordinate dimensions; this geometry has dimensions: %d" \
99
+ % update_ndim)
100
+ else:
101
+ cs = GEOSCoordSeq_create_r(handle, <int>m, <int>n)
102
+
103
+ # add to coordinate sequence
104
+ for i in xrange(m):
105
+ dx = cp[sm*i]
106
+ dy = cp[sm*i+sn]
107
+ dz = 0
108
+ if n == 3:
109
+ dz = cp[sm*i+2*sn]
110
+
111
+ # Because of a bug in the GEOS C API,
112
+ # always set X before Y
113
+ GEOSCoordSeq_setX_r(handle, cs, i, dx)
114
+ GEOSCoordSeq_setY_r(handle, cs, i, dy)
115
+ if n == 3:
116
+ GEOSCoordSeq_setZ_r(handle, cs, i, dz)
117
+
118
+ except AttributeError:
119
+ # Fall back on list
120
+ try:
121
+ m = len(ob)
122
+ except TypeError: # Iterators, e.g. Python 3 zip
123
+ ob = list(ob)
124
+ m = len(ob)
125
+ if m < 2:
126
+ raise ValueError(
127
+ "LineStrings must have at least 2 coordinate tuples")
128
+
129
+ def _coords(o):
130
+ if isinstance(o, Point):
131
+ return o.coords[0]
132
+ else:
133
+ return o
134
+
135
+ try:
136
+ n = len(_coords(ob[0]))
137
+ except TypeError:
138
+ raise ValueError(
139
+ "Input %s is the wrong shape for a LineString" % str(ob))
140
+ assert n == 2 or n == 3
141
+
142
+ # Create a coordinate sequence
143
+ if update_geom is not None:
144
+ cs = GEOSGeom_getCoordSeq_r(handle, cast_geom(update_geom))
145
+ if n != update_ndim:
146
+ raise ValueError(
147
+ "Wrong coordinate dimensions; this geometry has dimensions: %d" \
148
+ % update_ndim)
149
+ else:
150
+ cs = GEOSCoordSeq_create_r(handle, <int>m, <int>n)
151
+
152
+ # add to coordinate sequence
153
+ for i in xrange(m):
154
+ coords = _coords(ob[i])
155
+ dx = coords[0]
156
+ dy = coords[1]
157
+ dz = 0
158
+ if n == 3:
159
+ if len(coords) != 3:
160
+ raise ValueError("Inconsistent coordinate dimensionality")
161
+ dz = coords[2]
162
+
163
+ # Because of a bug in the GEOS C API,
164
+ # always set X before Y
165
+ GEOSCoordSeq_setX_r(handle, cs, i, dx)
166
+ GEOSCoordSeq_setY_r(handle, cs, i, dy)
167
+ if n == 3:
168
+ GEOSCoordSeq_setZ_r(handle, cs, i, dz)
169
+
170
+ if update_geom is not None:
171
+ return None
172
+ else:
173
+ return <unsigned long>GEOSGeom_createLineString_r(handle, cs), n
174
+
175
+
176
+ def geos_linearring_from_py(ob, update_geom=None, update_ndim=0):
177
+ cdef double *cp
178
+ cdef GEOSContextHandle_t handle = cast_handle(lgeos.geos_handle)
179
+ cdef GEOSGeometry *g
180
+ cdef GEOSCoordSequence *cs
181
+ cdef double dx, dy, dz
182
+ cdef int i, n, m, M, sm, sn
183
+
184
+ # If a LinearRing is passed in, just clone it and return
185
+ # If a LineString is passed in, clone the coord seq and return a LinearRing
186
+ if isinstance(ob, LineString):
187
+ g = cast_geom(ob._geom)
188
+ if GEOSHasZ_r(handle, g):
189
+ n = 3
190
+ else:
191
+ n = 2
192
+
193
+ if type(ob) == LinearRing:
194
+ return <unsigned long>GEOSGeom_clone_r(handle, g), n
195
+ else:
196
+ cs = GEOSGeom_getCoordSeq_r(handle, g)
197
+ GEOSCoordSeq_getSize_r(handle, cs, &m)
198
+ if GEOSisClosed_r(handle, g) and m >= 4:
199
+ cs = GEOSCoordSeq_clone_r(handle, cs)
200
+ return <unsigned long>GEOSGeom_createLinearRing_r(handle, cs), n
201
+
202
+ # If numpy is present, we use numpy.require to ensure that we have a
203
+ # C-continguous array that owns its data. View data will be copied.
204
+ ob = required(ob)
205
+ try:
206
+ # From array protocol
207
+ array = ob.__array_interface__
208
+ assert len(array['shape']) == 2
209
+ m = array['shape'][0]
210
+ n = array['shape'][1]
211
+ if m < 3:
212
+ raise ValueError(
213
+ "A LinearRing must have at least 3 coordinate tuples")
214
+ assert n == 2 or n == 3
215
+
216
+ # Make pointer to the coordinate array
217
+ if isinstance(array['data'], ctypes.Array):
218
+ cp = <double *><unsigned long>ctypes.addressof(array['data'])
219
+ else:
220
+ cp = <double *><unsigned long>array['data'][0]
221
+
222
+ # Use strides to properly index into cp
223
+ # ob[i, j] == cp[sm*i + sn*j]
224
+ dx = 0 # Just to avoid a referenced before assignment warning.
225
+ if array.get('strides', None):
226
+ sm = array['strides'][0]/sizeof(dx)
227
+ sn = array['strides'][1]/sizeof(dx)
228
+ else:
229
+ sm = n
230
+ sn = 1
231
+
232
+ # Add closing coordinates to sequence?
233
+ # Check whether the first set of coordinates matches the last.
234
+ # If not, we'll have to close the ring later
235
+ if (cp[0] != cp[sm*(m-1)] or cp[sn] != cp[sm*(m-1)+sn] or
236
+ (n == 3 and cp[2*sn] != cp[sm*(m-1)+2*sn])):
237
+ M = m + 1
238
+ else:
239
+ M = m
240
+
241
+ # Create a coordinate sequence
242
+ if update_geom is not None:
243
+ cs = GEOSGeom_getCoordSeq_r(handle, cast_geom(update_geom))
244
+ if n != update_ndim:
245
+ raise ValueError(
246
+ "Wrong coordinate dimensions; this geometry has dimensions: %d" \
247
+ % update_ndim)
248
+ else:
249
+ cs = GEOSCoordSeq_create_r(handle, M, n)
250
+
251
+ # add to coordinate sequence
252
+ for i in xrange(m):
253
+ dx = cp[sm*i]
254
+ dy = cp[sm*i+sn]
255
+ dz = 0
256
+ if n == 3:
257
+ dz = cp[sm*i+2*sn]
258
+
259
+ # Because of a bug in the GEOS C API,
260
+ # always set X before Y
261
+ GEOSCoordSeq_setX_r(handle, cs, i, dx)
262
+ GEOSCoordSeq_setY_r(handle, cs, i, dy)
263
+ if n == 3:
264
+ GEOSCoordSeq_setZ_r(handle, cs, i, dz)
265
+
266
+ # Add closing coordinates to sequence?
267
+ if M > m:
268
+ dx = cp[0]
269
+ dy = cp[sn]
270
+ dz = 0
271
+ if n == 3:
272
+ dz = cp[2*sn]
273
+
274
+ # Because of a bug in the GEOS C API,
275
+ # always set X before Y
276
+ GEOSCoordSeq_setX_r(handle, cs, M-1, dx)
277
+ GEOSCoordSeq_setY_r(handle, cs, M-1, dy)
278
+ if n == 3:
279
+ GEOSCoordSeq_setZ_r(handle, cs, M-1, dz)
280
+
281
+ except AttributeError:
282
+ # Fall back on list
283
+ try:
284
+ m = len(ob)
285
+ except TypeError: # Iterators, e.g. Python 3 zip
286
+ ob = list(ob)
287
+ m = len(ob)
288
+ n = len(ob[0])
289
+ if m < 3:
290
+ raise ValueError(
291
+ "A LinearRing must have at least 3 coordinate tuples")
292
+ assert (n == 2 or n == 3)
293
+
294
+ # Add closing coordinates if not provided
295
+ if m == 3 or ob[0][0] != ob[-1][0] or ob[0][1] != ob[-1][1]:
296
+ M = m + 1
297
+ else:
298
+ M = m
299
+
300
+ # Create a coordinate sequence
301
+ if update_geom is not None:
302
+ cs = GEOSGeom_getCoordSeq_r(handle, cast_geom(update_geom))
303
+ if n != update_ndim:
304
+ raise ValueError(
305
+ "Wrong coordinate dimensions; this geometry has dimensions: %d" \
306
+ % update_ndim)
307
+ else:
308
+ cs = GEOSCoordSeq_create_r(handle, M, n)
309
+
310
+ # add to coordinate sequence
311
+ for i in xrange(m):
312
+ coords = ob[i]
313
+ dx = coords[0]
314
+ dy = coords[1]
315
+ dz = 0
316
+ if n == 3:
317
+ dz = coords[2]
318
+
319
+ # Because of a bug in the GEOS C API,
320
+ # always set X before Y
321
+ GEOSCoordSeq_setX_r(handle, cs, i, dx)
322
+ GEOSCoordSeq_setY_r(handle, cs, i, dy)
323
+ if n == 3:
324
+ GEOSCoordSeq_setZ_r(handle, cs, i, dz)
325
+
326
+ # Add closing coordinates to sequence?
327
+ if M > m:
328
+ coords = ob[0]
329
+ dx = coords[0]
330
+ dy = coords[1]
331
+ dz = 0
332
+ if n == 3:
333
+ dz = coords[2]
334
+
335
+ # Because of a bug in the GEOS C API,
336
+ # always set X before Y
337
+ GEOSCoordSeq_setX_r(handle, cs, M-1, dx)
338
+ GEOSCoordSeq_setY_r(handle, cs, M-1, dy)
339
+ if n == 3:
340
+ GEOSCoordSeq_setZ_r(handle, cs, M-1, dz)
341
+
342
+ if update_geom is not None:
343
+ return None
344
+ else:
345
+ return <unsigned long>GEOSGeom_createLinearRing_r(handle, cs), n
346
+
347
+
348
+ def coordseq_ctypes(self):
349
+ cdef int i, n, m
350
+ cdef double temp = 0
351
+ cdef GEOSContextHandle_t handle = cast_handle(lgeos.geos_handle)
352
+ cdef GEOSCoordSequence *cs
353
+ cdef double *data_p
354
+ self._update()
355
+ n = self._ndim
356
+ m = self.__len__()
357
+ array_type = ctypes.c_double * (m * n)
358
+ data = array_type()
359
+
360
+ cs = cast_seq(self._cseq)
361
+ data_p = <double *><unsigned long>ctypes.addressof(data)
362
+
363
+ for i in xrange(m):
364
+ GEOSCoordSeq_getX_r(handle, cs, i, &temp)
365
+ data_p[n*i] = temp
366
+ GEOSCoordSeq_getY_r(handle, cs, i, &temp)
367
+ data_p[n*i+1] = temp
368
+ if n == 3: # TODO: use hasz
369
+ GEOSCoordSeq_getZ_r(handle, cs, i, &temp)
370
+ data_p[n*i+2] = temp
371
+ return data
372
+
373
+ def coordseq_iter(self):
374
+ cdef int i
375
+ cdef double dx
376
+ cdef double dy
377
+ cdef double dz
378
+ cdef int has_z
379
+
380
+ self._update()
381
+
382
+ cdef GEOSContextHandle_t handle = cast_handle(lgeos.geos_handle)
383
+ cdef GEOSCoordSequence *cs
384
+ cs = cast_seq(self._cseq)
385
+
386
+ has_z = self._ndim == 3
387
+ for i in range(self.__len__()):
388
+ GEOSCoordSeq_getX_r(handle, cs, i, &dx)
389
+ GEOSCoordSeq_getY_r(handle, cs, i, &dy)
390
+ if has_z == 1:
391
+ GEOSCoordSeq_getZ_r(handle, cs, i, &dz)
392
+ yield (dx, dy, dz)
393
+ else:
394
+ yield (dx, dy)
395
+
396
+ cdef GEOSCoordSequence* transform(GEOSCoordSequence* cs,
397
+ int ndim,
398
+ double a,
399
+ double b,
400
+ double c,
401
+ double d,
402
+ double e,
403
+ double f,
404
+ double g,
405
+ double h,
406
+ double i,
407
+ double xoff,
408
+ double yoff,
409
+ double zoff):
410
+ """Performs an affine transformation on a GEOSCoordSequence
411
+
412
+ Returns the transformed coordinate sequence
413
+ """
414
+ cdef GEOSContextHandle_t handle = cast_handle(lgeos.geos_handle)
415
+ cdef int m
416
+ cdef GEOSCoordSequence *cs_t
417
+ cdef double x, y, z
418
+ cdef double x_t, y_t, z_t
419
+
420
+ # create a new coordinate sequence with the same size and dimensions
421
+ GEOSCoordSeq_getSize_r(handle, cs, &m)
422
+ cs_t = GEOSCoordSeq_create_r(handle, m, ndim)
423
+
424
+ # perform the transform
425
+ for n in range(0, m):
426
+ GEOSCoordSeq_getX_r(handle, cs, n, &x)
427
+ GEOSCoordSeq_getY_r(handle, cs, n, &y)
428
+ x_t = a * x + b * y + xoff
429
+ y_t = d * x + e * y + yoff
430
+ GEOSCoordSeq_setX_r(handle, cs_t, n, x_t)
431
+ GEOSCoordSeq_setY_r(handle, cs_t, n, y_t)
432
+ if ndim == 3:
433
+ for n in range(0, m):
434
+ GEOSCoordSeq_getZ_r(handle, cs, n, &z)
435
+ z_t = g * x + h * y + i * z + zoff
436
+ GEOSCoordSeq_setZ_r(handle, cs_t, n, z_t)
437
+
438
+ return cs_t
439
+
440
+ cpdef affine_transform(geom, matrix):
441
+ cdef double a, b, c, d, e, f, g, h, i, xoff, yoff, zoff
442
+ if geom.is_empty:
443
+ return geom
444
+ if len(matrix) == 6:
445
+ ndim = 2
446
+ a, b, d, e, xoff, yoff = matrix
447
+ if geom.has_z:
448
+ ndim = 3
449
+ i = 1.0
450
+ c = f = g = h = zoff = 0.0
451
+ matrix = a, b, c, d, e, f, g, h, i, xoff, yoff, zoff
452
+ elif len(matrix) == 12:
453
+ ndim = 3
454
+ a, b, c, d, e, f, g, h, i, xoff, yoff, zoff = matrix
455
+ if not geom.has_z:
456
+ ndim = 2
457
+ matrix = a, b, d, e, xoff, yoff
458
+ else:
459
+ raise ValueError("'matrix' expects either 6 or 12 coefficients")
460
+
461
+ cdef GEOSContextHandle_t handle = cast_handle(lgeos.geos_handle)
462
+ cdef GEOSCoordSequence *cs
463
+ cdef GEOSCoordSequence *cs_t
464
+ cdef GEOSGeometry *the_geom
465
+ cdef GEOSGeometry *the_geom_t
466
+ cdef int m, n
467
+ cdef double x, y, z
468
+ cdef double x_t, y_t, z_t
469
+
470
+ # Process coordinates from each supported geometry type
471
+ if geom.type in ('Point', 'LineString', 'LinearRing'):
472
+ the_geom = cast_geom(geom._geom)
473
+ cs = GEOSGeom_getCoordSeq_r(handle, the_geom)
474
+
475
+ # perform the transformation
476
+ cs_t = transform(cs, ndim, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff)
477
+
478
+ # create a new geometry from the coordinate sequence
479
+ if geom.type == 'Point':
480
+ the_geom_t = GEOSGeom_createPoint_r(handle, cs_t)
481
+ elif geom.type == 'LineString':
482
+ the_geom_t = GEOSGeom_createLineString_r(handle, cs_t)
483
+ elif geom.type == 'LinearRing':
484
+ the_geom_t = GEOSGeom_createLinearRing_r(handle, cs_t)
485
+
486
+ # return the geometry as a Python object
487
+ return geom_factory(<unsigned long>the_geom_t)
488
+ elif geom.type == 'Polygon':
489
+ ring = geom.exterior
490
+ shell = affine_transform(ring, matrix)
491
+ holes = list(geom.interiors)
492
+ for pos, ring in enumerate(holes):
493
+ holes[pos] = affine_transform(ring, matrix)
494
+ return type(geom)(shell, holes)
495
+ elif geom.type.startswith('Multi') or geom.type == 'GeometryCollection':
496
+ return type(geom)([affine_transform(part, matrix) for part in geom.geoms])
497
+ else:
498
+ raise ValueError('Type %r not recognized' % geom.type)
Shapely-1.5.4/VERSION.txt DELETED
@@ -1 +0,0 @@
1
- 1.5.4
@@ -1 +0,0 @@
1
- __version__ = "1.5.4"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  [egg_info]
2
+ tag_build =
2
3
  tag_date = 0
3
4
  tag_svn_revision = 0
4
- tag_build =
5
5
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes