Opened 15 years ago
Closed 15 years ago
#11785 closed (fixed)
Invalid error reporting when importing MapInfo layer with Unknown type
Reported by: | Evgeny Sizikov | Owned by: | nobody |
---|---|---|---|
Component: | GIS | Version: | 1.1 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When going to import a spatial data from an MapInfo file I've stacked with an error message like following:
... File "../django/contrib/gis/utils/layermapping.py", line 293, in check_layer raise LayerMapError('Invalid mapping geometry; model has %s, feature has %s.' % (fld_name, ltype)) django.contrib.gis.utils.layermapping.LayerMapError: Invalid mapping geometry; model has PolygonField, feature has Polygon.
It took about 2 hours to figure out what could be wrong here, as the error message looks like a nonsense (Polygon != Polygon)
Looking through the code I've found a possible reason of such a misunderstanding:
-
layermapping.py
old new 290 290 # Making sure that the OGR Layer's Geometry is compatible. 291 291 ltype = self.layer.geom_type 292 292 if not (gtype == ltype or self.make_multi(ltype, model_field)): 293 raise LayerMapError('Invalid mapping geometry; model has %s, feature has %s.' % (fld_name, gtype))293 raise LayerMapError('Invalid mapping geometry; model has %s, feature has %s.' % (fld_name, ltype)) 294 294 295 295 # Setting the `geom_field` attribute w/the name of the model field 296 296 # that is a Geometry.
After that been done I've got a meaningful error like this one:
File "../django/contrib/gis/utils/layermapping.py", line 293, in check_layer raise LayerMapError('Invalid mapping geometry; model has %s, feature has %s.' % (fld_name, ltype)) django.contrib.gis.utils.layermapping.LayerMapError: Invalid mapping geometry; model has PolygonField, feature has Unknown.
It became clear to me that LayerMapping complains to import from a MapInfo layer with Unknown geometry type. That's what I was looking for 2 hours!
However, that "... model has PolygonField, feature has Unknown." doesn't looks polished too. Could someone provide a better fix?
Change History (2)
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [12880]) Fixed #11785 -- Clarified error message when the layer geometry type doesn't match the model field. Thanks, esizikov for bug report and initial patch.