mirror of
https://github.com/django/django.git
synced 2025-07-04 01:39:20 +00:00
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
This commit is contained in:
parent
7d915d5589
commit
858ae54a11
@ -25,7 +25,7 @@ class Field(object):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"Returns the string representation of the Field."
|
"Returns the string representation of the Field."
|
||||||
return '%s (%s)' % (self.name, self.__class__.__name__)
|
return '%s (%s)' % (self.name, self.value)
|
||||||
|
|
||||||
#### Field Properties ####
|
#### Field Properties ####
|
||||||
@property
|
@property
|
||||||
|
@ -158,7 +158,7 @@ def check_feature(feat, model_fields, mapping):
|
|||||||
geom = feat.geom
|
geom = feat.geom
|
||||||
gtype = geom.geom_type
|
gtype = geom.geom_type
|
||||||
gname = geom.geom_name
|
gname = geom.geom_name
|
||||||
|
|
||||||
if make_multi(gname, model_type):
|
if make_multi(gname, model_type):
|
||||||
# Do we have to 'upsample' into a Geometry Collection?
|
# Do we have to 'upsample' into a Geometry Collection?
|
||||||
pass
|
pass
|
||||||
@ -166,7 +166,7 @@ def check_feature(feat, model_fields, mapping):
|
|||||||
# The geometry type otherwise was expected
|
# The geometry type otherwise was expected
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise Exception, 'Invalid mapping geometry!'
|
raise Exception, 'Invalid mapping geometry; model has %s, feature has %s' % (model_type, gtype)
|
||||||
|
|
||||||
## Handling other fields
|
## Handling other fields
|
||||||
else:
|
else:
|
||||||
@ -237,10 +237,10 @@ class LayerMapping:
|
|||||||
if ogr_field in ogc_types:
|
if ogr_field in ogc_types:
|
||||||
## Getting the OGR geometry from the field
|
## Getting the OGR geometry from the field
|
||||||
geom = feat.geom
|
geom = feat.geom
|
||||||
|
|
||||||
if make_multi(geom.geom_name, model_type):
|
if make_multi(geom.geom_name, model_type):
|
||||||
# Constructing a multi-geometry type to contain the single geometry
|
# 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 = OGRGeometry(multi_type)
|
||||||
g.add(geom)
|
g.add(geom)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user