shapely 1.2.8__py2.7-win-amd64.egg

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 (58) hide show
  1. DLLs/geos.dll +0 -0
  2. DLLs/geos_c.dll +0 -0
  3. EGG-INFO/PKG-INFO +173 -0
  4. EGG-INFO/not-zip-safe +1 -0
  5. EGG-INFO/scripts/dissolve.py +53 -0
  6. EGG-INFO/scripts/intersect.py +81 -0
  7. shapely/__init__.py +1 -0
  8. shapely/__init__.pyc +0 -0
  9. shapely/coords.py +167 -0
  10. shapely/coords.pyc +0 -0
  11. shapely/ctypes_declarations.py +279 -0
  12. shapely/ctypes_declarations.pyc +0 -0
  13. shapely/ftools.py +78 -0
  14. shapely/ftools.pyc +0 -0
  15. shapely/geometry/__init__.py +20 -0
  16. shapely/geometry/__init__.pyc +0 -0
  17. shapely/geometry/base.py +595 -0
  18. shapely/geometry/base.pyc +0 -0
  19. shapely/geometry/collection.py +43 -0
  20. shapely/geometry/collection.pyc +0 -0
  21. shapely/geometry/geo.py +68 -0
  22. shapely/geometry/geo.pyc +0 -0
  23. shapely/geometry/linestring.py +259 -0
  24. shapely/geometry/linestring.pyc +0 -0
  25. shapely/geometry/multilinestring.py +133 -0
  26. shapely/geometry/multilinestring.pyc +0 -0
  27. shapely/geometry/multipoint.py +180 -0
  28. shapely/geometry/multipoint.pyc +0 -0
  29. shapely/geometry/multipolygon.py +154 -0
  30. shapely/geometry/multipolygon.pyc +0 -0
  31. shapely/geometry/point.py +241 -0
  32. shapely/geometry/point.pyc +0 -0
  33. shapely/geometry/polygon.py +449 -0
  34. shapely/geometry/polygon.pyc +0 -0
  35. shapely/geometry/proxy.py +54 -0
  36. shapely/geometry/proxy.pyc +0 -0
  37. shapely/geos.py +373 -0
  38. shapely/geos.pyc +0 -0
  39. shapely/impl.py +119 -0
  40. shapely/impl.pyc +0 -0
  41. shapely/iterops.py +53 -0
  42. shapely/iterops.pyc +0 -0
  43. shapely/linref.py +26 -0
  44. shapely/linref.pyc +0 -0
  45. shapely/ops.py +87 -0
  46. shapely/ops.pyc +0 -0
  47. shapely/predicates.py +24 -0
  48. shapely/predicates.pyc +0 -0
  49. shapely/prepared.py +58 -0
  50. shapely/prepared.pyc +0 -0
  51. shapely/topology.py +62 -0
  52. shapely/topology.pyc +0 -0
  53. shapely/validation.py +7 -0
  54. shapely/validation.pyc +0 -0
  55. shapely/wkb.py +39 -0
  56. shapely/wkb.pyc +0 -0
  57. shapely/wkt.py +34 -0
  58. shapely/wkt.pyc +0 -0
shapely/predicates.pyc ADDED
Binary file
shapely/prepared.py ADDED
@@ -0,0 +1,58 @@
1
+ """
2
+ Support for GEOS prepared geometry operations.
3
+ """
4
+
5
+ from shapely.geos import lgeos
6
+ from shapely.impl import DefaultImplementation, delegated
7
+
8
+
9
+ class PreparedGeometry(object):
10
+ """
11
+ A geometry prepared for efficient comparison to a set of other geometries.
12
+
13
+ Example:
14
+
15
+ >>> from shapely.geometry import Point, Polygon
16
+ >>> triangle = Polygon(((0.0, 0.0), (1.0, 1.0), (1.0, -1.0)))
17
+ >>> p = prep(triangle)
18
+ >>> p.intersects(Point(0.5, 0.5))
19
+ True
20
+ """
21
+
22
+ impl = DefaultImplementation
23
+
24
+ def __init__(self, context):
25
+ self.context = context
26
+ self.__geom__ = lgeos.GEOSPrepare(self.context._geom)
27
+
28
+ def __del__(self):
29
+ if self.__geom__ is not None:
30
+ lgeos.GEOSPreparedGeom_destroy(self.__geom__)
31
+ self.__geom__ = None
32
+ self.context = None
33
+
34
+ @property
35
+ def _geom(self):
36
+ return self.__geom__
37
+
38
+ @delegated
39
+ def intersects(self, other):
40
+ return bool(self.impl['prepared_intersects'](self, other))
41
+
42
+ @delegated
43
+ def contains(self, other):
44
+ return bool(self.impl['prepared_contains'](self, other))
45
+
46
+ @delegated
47
+ def contains_properly(self, other):
48
+ return bool(self.impl['prepared_contains_properly'](self, other))
49
+
50
+ @delegated
51
+ def covers(self, other):
52
+ return bool(self.impl['prepared_covers'](self, other))
53
+
54
+
55
+ def prep(ob):
56
+ """Creates and returns a prepared geometric object."""
57
+ return PreparedGeometry(ob)
58
+
shapely/prepared.pyc ADDED
Binary file
shapely/topology.py ADDED
@@ -0,0 +1,62 @@
1
+ """
2
+ Intermediaries supporting GEOS topological operations
3
+
4
+ These methods all take Shapely geometries and other Python objects and delegate
5
+ to GEOS functions via ctypes.
6
+
7
+ These methods return ctypes objects that should be recast by the caller.
8
+ """
9
+
10
+ from ctypes import byref, c_double
11
+ from shapely.geos import TopologicalError, lgeos
12
+
13
+
14
+ class Validating(object):
15
+ def _validate(self, ob):
16
+ try:
17
+ assert ob is not None
18
+ assert ob._geom is not None
19
+ except AssertionError:
20
+ raise ValueError("Null geometry supports no operations")
21
+
22
+ class Delegating(Validating):
23
+ def __init__(self, name):
24
+ self.fn = lgeos.methods[name]
25
+
26
+ class BinaryRealProperty(Delegating):
27
+ def __call__(self, this, other):
28
+ self._validate(this)
29
+ self._validate(other)
30
+ d = c_double()
31
+ retval = self.fn(this._geom, other._geom, byref(d))
32
+ return d.value
33
+
34
+ class UnaryRealProperty(Delegating):
35
+ def __call__(self, this):
36
+ self._validate(this)
37
+ d = c_double()
38
+ retval = self.fn(this._geom, byref(d))
39
+ return d.value
40
+
41
+ class BinaryTopologicalOp(Delegating):
42
+ def __call__(self, this, other, *args):
43
+ self._validate(this)
44
+ self._validate(other)
45
+ product = self.fn(this._geom, other._geom, *args)
46
+ if product is None:
47
+ if not this.is_valid:
48
+ raise TopologicalError(
49
+ "The operation '%s' produced a null geometry. Likely cause is invalidity of the geometry %s" % (self.fn.__name__, repr(this)))
50
+ elif not other.is_valid:
51
+ raise TopologicalError(
52
+ "The operation '%s' produced a null geometry. Likely cause is invalidity of the 'other' geometry %s" % (self.fn.__name__, repr(other)))
53
+ else:
54
+ raise TopologicalError(
55
+ "This operation produced a null geometry. Reason: unknown")
56
+ return product
57
+
58
+ class UnaryTopologicalOp(Delegating):
59
+ def __call__(self, this, *args):
60
+ self._validate(this)
61
+ return self.fn(this._geom, *args)
62
+
shapely/topology.pyc ADDED
Binary file
shapely/validation.py ADDED
@@ -0,0 +1,7 @@
1
+ # TODO: allow for implementations using other than GEOS
2
+
3
+ from shapely.geos import lgeos
4
+
5
+ def explain_validity(ob):
6
+ return lgeos.GEOSisValidReason(ob._geom)
7
+
shapely/validation.pyc ADDED
Binary file
shapely/wkb.py ADDED
@@ -0,0 +1,39 @@
1
+ """Load/dump geometries using the well-known binary (WKB) format
2
+ """
3
+
4
+ from ctypes import byref, c_size_t, c_char_p, string_at
5
+ from ctypes import c_void_p, c_size_t
6
+
7
+ from shapely.geos import lgeos, ReadingError
8
+
9
+
10
+ # Pickle-like convenience functions
11
+
12
+ def deserialize(data):
13
+ geom = lgeos.GEOSGeomFromWKB_buf(c_char_p(data), c_size_t(len(data)));
14
+ if not geom:
15
+ raise ReadingError(
16
+ "Could not create geometry because of errors while reading input.")
17
+ return geom
18
+
19
+ def loads(data):
20
+ """Load a geometry from a WKB string."""
21
+ from shapely.geometry.base import geom_factory
22
+ return geom_factory(deserialize(data))
23
+
24
+ def load(fp):
25
+ """Load a geometry from an open file."""
26
+ data = fp.read()
27
+ return loads(data)
28
+
29
+ def dumps(ob):
30
+ """Dump a WKB representation of a geometry to a byte string."""
31
+ if ob is None or ob._geom is None:
32
+ raise ValueError("Null geometry supports no operations")
33
+ size = c_size_t()
34
+ return lgeos.GEOSGeomToWKB_buf(c_void_p(ob._geom), byref(size))
35
+
36
+ def dump(ob, fp):
37
+ """Dump a geometry to an open file."""
38
+ fp.write(dumps(ob))
39
+
shapely/wkb.pyc ADDED
Binary file
shapely/wkt.py ADDED
@@ -0,0 +1,34 @@
1
+ """Load/dump geometries using the well-known text (WKT) format
2
+ """
3
+
4
+ from ctypes import c_char_p
5
+
6
+ from shapely.geos import lgeos, ReadingError
7
+
8
+
9
+ # Pickle-like convenience functions
10
+
11
+ def loads(data):
12
+ """Load a geometry from a WKT string."""
13
+ from shapely.geometry.base import geom_factory
14
+ geom = lgeos.GEOSGeomFromWKT(c_char_p(data))
15
+ if not geom:
16
+ raise ReadingError, \
17
+ "Could not create geometry because of errors while reading input."
18
+ return geom_factory(geom)
19
+
20
+ def load(fp):
21
+ """Load a geometry from an open file."""
22
+ data = fp.read()
23
+ return loads(data)
24
+
25
+ def dumps(ob):
26
+ """Dump a WKB representation of a geometry to a byte string."""
27
+ if ob is None or ob._geom is None:
28
+ raise ValueError("Null geometry supports no operations")
29
+ return lgeos.GEOSGeomToWKT(ob._geom)
30
+
31
+ def dump(ob, fp):
32
+ """Dump a geometry to an open file."""
33
+ fp.write(dumps(ob))
34
+
shapely/wkt.pyc ADDED
Binary file