Changeset 1120
- Timestamp:
- 07/09/08 13:50:57
- Files:
-
- Shapely/trunk/setup.py (modified) (1 diff)
- Shapely/trunk/setup_windows.py (modified) (1 diff)
- Shapely/trunk/shapely/geometry/geo.py (modified) (3 diffs)
- Shapely/trunk/shapely/geometry/multipolygon.py (modified) (5 diffs)
- Shapely/trunk/tests/GeoInterface.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Shapely/trunk/setup.py
r1106 r1120 12 12 13 13 setup(name = 'Shapely', 14 version = '1.0. 5',14 version = '1.0.6', 15 15 description = 'Geospatial geometries, predicates, and operations', 16 16 license = 'BSD', Shapely/trunk/setup_windows.py
r1106 r1120 12 12 13 13 setup(name = 'Shapely', 14 version = '1.0. 5',14 version = '1.0.6', 15 15 description = 'Geospatial geometries, predicates, and operations', 16 16 license = 'BSD', Shapely/trunk/shapely/geometry/geo.py
r1108 r1120 8 8 from multipoint import MultiPoint, asMultiPoint 9 9 from multilinestring import MultiLineString, asMultiLineString 10 from multipolygon import MultiPolygon, asMultiPolygon10 from multipolygon import MultiPolygon, MultiPolygonAdapter, asMultiPolygon 11 11 12 12 … … 31 31 return MultiLineString(ob["coordinates"]) 32 32 elif geom_type == "multipolygon": 33 return MultiPolygon(ob["coordinates"] )33 return MultiPolygon(ob["coordinates"], context_type='geojson') 34 34 else: 35 35 raise ValueError, "Unknown geometry type: %s" % geom_type … … 60 60 return asMultiLineString(ob["coordinates"]) 61 61 elif geom_type == "multipolygon": 62 return asMultiPolygon(ob["coordinates"])62 return MultiPolygonAdapter(ob["coordinates"], context_type='geojson') 63 63 else: 64 64 raise ValueError, "Unknown geometry type: %s" % geom_type Shapely/trunk/shapely/geometry/multipolygon.py
r1089 r1120 12 12 13 13 def geos_multipolygon_from_py(ob): 14 """ob must provide Python geo interface coordinates.""" 15 L = len(ob) 16 N = len(ob[0][0][0]) 17 assert L >= 1 18 assert N == 2 or N == 3 19 20 subs = (c_void_p * L)() 21 for l in xrange(L): 22 geom, ndims = geos_polygon_from_py(ob[l][0], ob[l][1:]) 23 subs[l] = cast(geom, c_void_p) 24 25 return (lgeos.GEOSGeom_createCollection(6, subs, L), N) 26 27 def geos_multipolygon_from_polygons(ob): 14 28 """ob must be either a sequence or array of sequences or arrays.""" 15 29 L = len(ob) … … 26 40 27 41 42 28 43 class MultiPolygon(BaseGeometry): 29 44 … … 31 46 """ 32 47 33 def __init__(self, polygons=None ):48 def __init__(self, polygons=None, context_type='polygons'): 34 49 """Initialize. 35 50 … … 56 71 # allow creation of null collections, to support unpickling 57 72 pass 58 else: 73 elif context_type == 'polygons': 74 self._geom, self._ndim = geos_multipolygon_from_polygons(polygons) 75 elif context_type == 'geojson': 59 76 self._geom, self._ndim = geos_multipolygon_from_py(polygons) 60 77 … … 112 129 _owned = False 113 130 114 def __init__(self, context ):131 def __init__(self, context, context_type='polygons'): 115 132 self.context = context 116 self.factory = geos_multipolygon_from_py 133 if context_type == 'geojson': 134 self.factory = geos_multipolygon_from_py 135 elif context_type == 'polygons': 136 self.factory = geos_multipolygon_from_polygons 117 137 118 138 @property Shapely/trunk/tests/GeoInterface.txt
r863 r1120 62 62 multi polygon 63 63 64 >>> shape = asShape({'type': 'MultiPolygon', 'coordinates': [(((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)), [((0.10000000000000001, 0.10000000000000001), (0.10000000000000001, 0.20000000000000001), (0.20000000000000001, 0.20000000000000001), (0.20000000000000001, 0.10000000000000001), (0.10000000000000001, 0.10000000000000001))])]})64 >>> shape = asShape({'type': 'MultiPolygon', 'coordinates': [(((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)), ((0.10000000000000001, 0.10000000000000001), (0.10000000000000001, 0.20000000000000001), (0.20000000000000001, 0.20000000000000001), (0.20000000000000001, 0.10000000000000001), (0.10000000000000001, 0.10000000000000001)))]}) 65 65 >>> shape # doctest: +ELLIPSIS 66 66 <shapely.geometry.multipolygon.MultiPolygonAdapter object at ...>
