shapely 1.0__py2.4.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.
- EGG-INFO/PKG-INFO +173 -0
- EGG-INFO/SOURCES.txt +52 -0
- EGG-INFO/dependency_links.txt +1 -0
- EGG-INFO/not-zip-safe +1 -0
- EGG-INFO/requires.txt +2 -0
- EGG-INFO/top_level.txt +1 -0
- shapely/__init__.py +1 -0
- shapely/__init__.pyc +0 -0
- shapely/geometry/__init__.py +9 -0
- shapely/geometry/__init__.pyc +0 -0
- shapely/geometry/base.py +415 -0
- shapely/geometry/base.pyc +0 -0
- shapely/geometry/collection.py +24 -0
- shapely/geometry/collection.pyc +0 -0
- shapely/geometry/geo.py +35 -0
- shapely/geometry/geo.pyc +0 -0
- shapely/geometry/linestring.py +234 -0
- shapely/geometry/linestring.pyc +0 -0
- shapely/geometry/multilinestring.py +157 -0
- shapely/geometry/multilinestring.pyc +0 -0
- shapely/geometry/multipoint.py +187 -0
- shapely/geometry/multipoint.pyc +0 -0
- shapely/geometry/multipolygon.py +143 -0
- shapely/geometry/multipolygon.pyc +0 -0
- shapely/geometry/point.py +259 -0
- shapely/geometry/point.pyc +0 -0
- shapely/geometry/polygon.py +429 -0
- shapely/geometry/polygon.pyc +0 -0
- shapely/geos.py +80 -0
- shapely/geos.pyc +0 -0
- shapely/iterops.py +56 -0
- shapely/iterops.pyc +0 -0
- shapely/kml.py +0 -0
- shapely/kml.pyc +0 -0
- shapely/predicates.py +58 -0
- shapely/predicates.pyc +0 -0
- shapely/topology.py +66 -0
- shapely/topology.pyc +0 -0
- shapely/wkb.py +40 -0
- shapely/wkb.pyc +0 -0
- shapely/wkt.py +40 -0
- shapely/wkt.pyc +0 -0
shapely/wkb.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Load/dump geometries using the well-known binary (WKB) format.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from ctypes import byref, c_int, c_size_t, c_char_p, string_at
|
|
6
|
+
|
|
7
|
+
from shapely.geos import lgeos, free, ReadingError
|
|
8
|
+
from shapely.geometry.base import geom_factory
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# Pickle-like convenience functions
|
|
12
|
+
|
|
13
|
+
def loads(data):
|
|
14
|
+
"""Load a geometry from a WKB string."""
|
|
15
|
+
geom = lgeos.GEOSGeomFromWKB_buf(c_char_p(data), c_size_t(len(data)));
|
|
16
|
+
if not geom:
|
|
17
|
+
raise ReadingError, \
|
|
18
|
+
"Could not create geometry because of errors while reading input."
|
|
19
|
+
return geom_factory(geom)
|
|
20
|
+
|
|
21
|
+
def load(fp):
|
|
22
|
+
"""Load a geometry from an open file."""
|
|
23
|
+
data = fp.read()
|
|
24
|
+
return loads(data)
|
|
25
|
+
|
|
26
|
+
def dumps(ob):
|
|
27
|
+
"""Dump a WKB representation of a geometry to a byte string."""
|
|
28
|
+
func = lgeos.GEOSGeomToWKB_buf
|
|
29
|
+
size = c_int()
|
|
30
|
+
def errcheck(result, func, argtuple):
|
|
31
|
+
retval = string_at(result, size.value)[:]
|
|
32
|
+
free(result)
|
|
33
|
+
return retval
|
|
34
|
+
func.errcheck = errcheck
|
|
35
|
+
return func(ob._geom, byref(size))
|
|
36
|
+
|
|
37
|
+
def dump(ob, fp):
|
|
38
|
+
"""Dump a geometry to an open file."""
|
|
39
|
+
fp.write(dumps(ob))
|
|
40
|
+
|
shapely/wkb.pyc
ADDED
|
Binary file
|
shapely/wkt.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Load/dump geometries using the well-known text (WKT) format.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from ctypes import byref, c_int, c_size_t, c_char_p, string_at
|
|
6
|
+
|
|
7
|
+
from shapely.geos import lgeos, free, allocated_c_char_p, ReadingError
|
|
8
|
+
from shapely.geometry.base import geom_factory
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# Pickle-like convenience functions
|
|
12
|
+
|
|
13
|
+
def loads(data):
|
|
14
|
+
"""Load a geometry from a WKT string."""
|
|
15
|
+
geom = lgeos.GEOSGeomFromWKT(c_char_p(data))
|
|
16
|
+
if not geom:
|
|
17
|
+
raise ReadingError, \
|
|
18
|
+
"Could not create geometry because of errors while reading input."
|
|
19
|
+
return geom_factory(geom)
|
|
20
|
+
|
|
21
|
+
def load(fp):
|
|
22
|
+
"""Load a geometry from an open file."""
|
|
23
|
+
data = fp.read()
|
|
24
|
+
return loads(data)
|
|
25
|
+
|
|
26
|
+
def dumps(ob):
|
|
27
|
+
"""Dump a WKB representation of a geometry to a byte string."""
|
|
28
|
+
func = lgeos.GEOSGeomToWKT
|
|
29
|
+
def errcheck(result, func, argtuple):
|
|
30
|
+
retval = result.value
|
|
31
|
+
free(result)
|
|
32
|
+
return retval
|
|
33
|
+
func.restype = allocated_c_char_p
|
|
34
|
+
func.errcheck = errcheck
|
|
35
|
+
return lgeos.GEOSGeomToWKT(ob._geom)
|
|
36
|
+
|
|
37
|
+
def dump(ob, fp):
|
|
38
|
+
"""Dump a geometry to an open file."""
|
|
39
|
+
fp.write(dumps(ob))
|
|
40
|
+
|
shapely/wkt.pyc
ADDED
|
Binary file
|