﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
11785	Invalid error reporting when importing MapInfo layer with Unknown type	Evgeny Sizikov	nobody	"When going to import a spatial data from an !MapInfo file I've stacked with an error message like following:

{{{
#!python
...
  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:
{{{
#!diff
--- layermapping.py.orig	2009-08-26 09:36:12.438952459 +0700
+++ layermapping.py	2009-08-26 09:36:21.979827357 +0700
@@ -290,7 +290,7 @@
                 # Making sure that the OGR Layer's Geometry is compatible.
                 ltype = self.layer.geom_type
                 if not (gtype == ltype or self.make_multi(ltype, model_field)):
-                    raise LayerMapError('Invalid mapping geometry; model has %s, feature has %s.' % (fld_name, gtype))
+                    raise LayerMapError('Invalid mapping geometry; model has %s, feature has %s.' % (fld_name, ltype))
 
                 # Setting the `geom_field` attribute w/the name of the model field
                 # that is a Geometry.

}}}

After that been done I've got a meaningful error like this one:
{{{
#!python
  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?"		closed	GIS	1.1		fixed			Design decision needed	0	0	0	0	0	0
