summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Dunck <jdunck@gmail.com>2007-07-02 15:45:46 +0000
committerJeremy Dunck <jdunck@gmail.com>2007-07-02 15:45:46 +0000
commit858ae54a111f55b8d07e9cb53bf480c48f28bede (patch)
tree7ac9d880d5b779968f4d13697d8e6115c9ecd624
parent7d915d5589c4aa9327b80f0e107e2231f5daf630 (diff)
gis: Improved LayerMapping error message when model field doesn't match feature geom type.
Tweaked Field.__str__. Fixed geom_name aliasing bug. git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@5586 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/gis/gdal/Field.py2
-rw-r--r--django/contrib/gis/utils/LayerMapping.py8
2 files changed, 5 insertions, 5 deletions
diff --git a/django/contrib/gis/gdal/Field.py b/django/contrib/gis/gdal/Field.py
index ce183990bc..340c9bfa1b 100644
--- a/django/contrib/gis/gdal/Field.py
+++ b/django/contrib/gis/gdal/Field.py
@@ -25,7 +25,7 @@ class Field(object):
def __str__(self):
"Returns the string representation of the Field."
- return '%s (%s)' % (self.name, self.__class__.__name__)
+ return '%s (%s)' % (self.name, self.value)
#### Field Properties ####
@property
diff --git a/django/contrib/gis/utils/LayerMapping.py b/django/contrib/gis/utils/LayerMapping.py
index 9f154f8b06..b768c52a07 100644
--- a/django/contrib/gis/utils/LayerMapping.py
+++ b/django/contrib/gis/utils/LayerMapping.py
@@ -158,7 +158,7 @@ def check_feature(feat, model_fields, mapping):
geom = feat.geom
gtype = geom.geom_type
gname = geom.geom_name
-
+
if make_multi(gname, model_type):
# Do we have to 'upsample' into a Geometry Collection?
pass
@@ -166,7 +166,7 @@ def check_feature(feat, model_fields, mapping):
# The geometry type otherwise was expected
pass
else:
- raise Exception, 'Invalid mapping geometry!'
+ raise Exception, 'Invalid mapping geometry; model has %s, feature has %s' % (model_type, gtype)
## Handling other fields
else:
@@ -237,10 +237,10 @@ class LayerMapping:
if ogr_field in ogc_types:
## Getting the OGR geometry from the field
geom = feat.geom
-
+
if make_multi(geom.geom_name, model_type):
# Constructing a multi-geometry type to contain the single geometry
- multi_type = multi_types[gname]
+ multi_type = multi_types[geom.geom_name]
g = OGRGeometry(multi_type)
g.add(geom)
else: