#11785: Invalid error reporting when importing MapInfo layer with Unknown type
----------------------+-----------------------------------------------------
 Reporter:  esizikov  |       Owner:  nobody    
   Status:  new       |   Milestone:            
Component:  GIS       |     Version:  1.1       
 Keywords:            |       Stage:  Unreviewed
Has_patch:  0         |  
----------------------+-----------------------------------------------------
 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?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11785>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to