Changeset 9392
- Timestamp:
- 11/11/08 11:21:43 (2 months ago)
- Files:
-
- django/trunk/django/contrib/gis/gdal/geometries.py (modified) (1 diff)
- django/trunk/django/contrib/gis/geos/base.py (modified) (2 diffs)
- django/trunk/django/contrib/gis/tests/geometries.py (modified) (1 diff)
- django/trunk/django/contrib/gis/tests/test_gdal_geom.py (modified) (1 diff)
- django/trunk/django/contrib/gis/tests/test_geos.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/contrib/gis/gdal/geometries.py
r9237 r9392 62 62 hex_regex = re.compile(r'^[0-9A-F]+$', re.I) 63 63 wkt_regex = re.compile(r'^(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)[ACEGIMLONPSRUTY\d,\.\-\(\) ]+$', re.I) 64 json_regex = re.compile(r'^ \{[\s\w,\-\.\"\'\:\[\]]+\}$')64 json_regex = re.compile(r'^(\s+)?\{[\s\w,\[\]\{\}\-\."\':]+\}(\s+)?$') 65 65 66 66 #### OGRGeometry Class #### django/trunk/django/contrib/gis/geos/base.py
r8219 r9392 22 22 try: 23 23 from django.contrib.gis.gdal import OGRGeometry, SpatialReference, GEOJSON 24 from django.contrib.gis.gdal.geometries import json_regex 24 25 HAS_GDAL = True 25 26 except: … … 31 32 hex_regex = re.compile(r'^[0-9A-F]+$', re.I) 32 33 wkt_regex = re.compile(r'^(SRID=(?P<srid>\d+);)?(?P<wkt>(POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)[ACEGIMLONPSRUTY\d,\.\-\(\) ]+)$', re.I) 33 json_regex = re.compile(r'^\{.+\}$')34 34 35 35 class GEOSGeometry(object): django/trunk/django/contrib/gis/tests/geometries.py
r8219 r9392 155 155 TestGeom('POLYGON((0 0, -10 0, -10 -10, 0 -10, 0 0))', json='{ "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.000000 ], [ -10.000000, 0.000000 ], [ -10.000000, -10.000000 ], [ 0.000000, -10.000000 ], [ 0.000000, 0.000000 ] ] ] }'), 156 156 TestGeom('MULTIPOLYGON(((102 2, 103 2, 103 3, 102 3, 102 2)), ((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0, 100.0 0.0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2)))', json='{ "type": "MultiPolygon", "coordinates": [ [ [ [ 102.000000, 2.000000 ], [ 103.000000, 2.000000 ], [ 103.000000, 3.000000 ], [ 102.000000, 3.000000 ], [ 102.000000, 2.000000 ] ] ], [ [ [ 100.000000, 0.000000 ], [ 101.000000, 0.000000 ], [ 101.000000, 1.000000 ], [ 100.000000, 1.000000 ], [ 100.000000, 0.000000 ] ], [ [ 100.200000, 0.200000 ], [ 100.800000, 0.200000 ], [ 100.800000, 0.800000 ], [ 100.200000, 0.800000 ], [ 100.200000, 0.200000 ] ] ] ] }'), 157 TestGeom('GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101.0 0.0, 102.0 1.0))', 158 json='{ "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [ 100.000000, 0.000000 ] }, { "type": "LineString", "coordinates": [ [ 101.000000, 0.000000 ], [ 102.000000, 1.000000 ] ] } ] }', 159 ), 160 TestGeom('MULTILINESTRING((100.0 0.0, 101.0 1.0),(102.0 2.0, 103.0 3.0))', 161 json=""" 162 163 { "type": "MultiLineString", 164 "coordinates": [ 165 [ [100.0, 0.0], [101.0, 1.0] ], 166 [ [102.0, 2.0], [103.0, 3.0] ] 167 ] 168 } 169 170 """, 171 not_equal=True, 172 ), 157 173 ) django/trunk/django/contrib/gis/tests/test_gdal_geom.py
r8219 r9392 80 80 for g in json_geoms: 81 81 geom = OGRGeometry(g.wkt) 82 self.assertEqual(g.json, geom.json) 83 self.assertEqual(g.json, geom.geojson) 82 if not hasattr(g, 'not_equal'): 83 self.assertEqual(g.json, geom.json) 84 self.assertEqual(g.json, geom.geojson) 84 85 self.assertEqual(OGRGeometry(g.wkt), OGRGeometry(geom.json)) 85 86 django/trunk/django/contrib/gis/tests/test_geos.py
r8219 r9392 103 103 for g in json_geoms: 104 104 geom = GEOSGeometry(g.wkt) 105 self.assertEqual(g.json, geom.json) 106 self.assertEqual(g.json, geom.geojson) 105 if not hasattr(g, 'not_equal'): 106 self.assertEqual(g.json, geom.json) 107 self.assertEqual(g.json, geom.geojson) 107 108 self.assertEqual(GEOSGeometry(g.wkt), GEOSGeometry(geom.json)) 108 109
