From 9fcc6c305a562b2e622049d4ce8b6148a2c617ca Mon Sep 17 00:00:00 2001 From: Justin Bronn Date: Thu, 26 Jun 2008 14:31:03 +0000 Subject: [PATCH] gis: Fixed #7540 -- fixed the GeoJSON regex to accept minus signs. Thanks, Kenichi Ueda. git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7767 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/gis/gdal/geometries.py | 2 +- django/contrib/gis/tests/geometries.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py index 39cc4f8023..e76a5add5f 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -62,7 +62,7 @@ from django.contrib.gis.gdal.prototypes.srs import clone_srs # Regular expressions for recognizing HEXEWKB and WKT. hex_regex = re.compile(r'^[0-9A-F]+$', re.I) wkt_regex = re.compile(r'^(?PPOINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)[ACEGIMLONPSRUTY\d,\.\-\(\) ]+$', re.I) -json_regex = re.compile(r'^\{[\s\w,\.\"\'\:\[\]]+\}$') +json_regex = re.compile(r'^\{[\s\w,\-\.\"\'\:\[\]]+\}$') #### OGRGeometry Class #### class OGRGeometry(object): diff --git a/django/contrib/gis/tests/geometries.py b/django/contrib/gis/tests/geometries.py index 0001a765a1..e9bc6f618b 100644 --- a/django/contrib/gis/tests/geometries.py +++ b/django/contrib/gis/tests/geometries.py @@ -152,5 +152,6 @@ buffer_geoms = ( (TestGeom('POINT(0 0)'), ) json_geoms = (TestGeom('POINT(100 0)', json='{ "type": "Point", "coordinates": [ 100.000000, 0.000000 ] }'), + 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 ] ] ] }'), 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 ] ] ] ] }'), )