Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#8881 closed (fixed)

LayerMapping Error with more than two fields geometry

Reported by: woakas@… Owned by: jbronn
Component: GIS Version: 1.0-beta
Severity: Keywords: gis layermapping
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by jbronn)

If my models have two or more geometry fields:

class Lugares(models.Model) :
    nombre = models.CharField(max_length=80)
    punto = models.MultiPointField(null=True, blank=True, srid=4326)
    poligono = models.MultiPolygonField(null=True, blank=True, srid=4326)
    objects =models.GeoManager()


lm=LayerMapping(Lugares,'/home/woakas/nuevo.shp', mapping,unique={'poligono':'POLYGON','tipolugar':'Ciudad'})

LayerMapError                             Traceback (most recent call last)

/home/woakas/mig/Migtrace/trunk/src/<ipython console> in <module>()

/usr/lib/python2.5/site-packages/django/contrib/gis/utils/layermapping.py in __init__(self, model, data, mapping, layer, source_srs, encoding, transaction_mode, transform, unique)
    186         # geometry column).
    187         self.model = model
--> 188         self.geo_col = self.geometry_column()
    189 
    190         # Checking the source spatial reference system, and getting

/usr/lib/python2.5/site-packages/django/contrib/gis/utils/layermapping.py in geometry_column(self)
    516             return GeometryColumns.objects.get(**gc_kwargs)
    517         except Exception, msg:
--> 518             raise LayerMapError('Geometry column does not exist for model. (did you run syncdb?):\n %s' % msg)
    519 
    520     def make_multi(self, geom_type, model_field):

LayerMapError: Geometry column does not exist for model. (did you run syncdb?):
 get() returned more than one GeometryColumns -- it returned 2! Lookup parameters were {'f_table_name': 'migtrace_lugares'}

Change History (5)

comment:1 by woakas@…, 16 years ago

posible fixed

@@ -513,7 +513,7 @@

try:

db_table = self.model._meta.db_table
if SpatialBackend.name == 'oracle': db_table = db_table.upper()

  • gc_kwargs = {GeometryColumns.table_name_col() : db_table}

+ gc_kwargs = {GeometryColumns.table_name_col() : db_table, 'f_geometry_columnin':self.mapping}

return GeometryColumns.objects.get(gc_kwargs)

except Exception, msg:

raise LayerMapError('Geometry column does not exist for model. (did you run syncdb?):\n %s' % msg)

in reply to:  1 comment:2 by anonymous, 16 years ago

Replying to woakas@gmail.com:

posible fixed

--- django/contrib/gis/utils/layermapping.py	(revisión: 8965)
+++ django/contrib/gis/utils/layermapping.py	(copia de trabajo)
@@ -513,7 +513,7 @@
         try:
             db_table = self.model._meta.db_table
             if SpatialBackend.name == 'oracle': db_table = db_table.upper()
-            gc_kwargs = {GeometryColumns.table_name_col() : db_table}
+            gc_kwargs = {GeometryColumns.table_name_col() : db_table, 'f_geometry_column__in':self.mapping}
             return GeometryColumns.objects.get(**gc_kwargs)
         except Exception, msg:
             raise LayerMapError('Geometry column does not exist for model. (did you run syncdb?):\n %s' % msg)

comment:3 by jbronn, 16 years ago

Description: modified (diff)
Keywords: gis layermapping added
Owner: changed from nobody to jbronn

comment:4 by jbronn, 16 years ago

Resolution: fixed
Status: newclosed

Fixed in r8994. Dunno why trac didn't catch it in the commit message.

comment:5 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top