Skip to content

Commit

Permalink
gis: Improved LayerMapping error message when model field doesn't mat…
Browse files Browse the repository at this point in the history
…ch 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
  • Loading branch information
jdunck committed Jul 2, 2007
1 parent 7d915d5 commit 858ae54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion django/contrib/gis/gdal/Field.py
Expand Up @@ -25,7 +25,7 @@ def __init__(self, fld, val=''):

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
Expand Down
8 changes: 4 additions & 4 deletions django/contrib/gis/utils/LayerMapping.py
Expand Up @@ -158,15 +158,15 @@ 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
elif gtype == ogc_types[gis_fields[model_type]]:
# 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:
Expand Down Expand Up @@ -237,10 +237,10 @@ def save(self, verbose=False):
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:
Expand Down

0 comments on commit 858ae54

Please sign in to comment.