#8881 closed (fixed)
LayerMapping Error with more than two fields geometry
Reported by: | 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 )
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)
follow-up: 2 comment:1 by , 16 years ago
comment:2 by , 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 , 16 years ago
Description: | modified (diff) |
---|---|
Keywords: | gis layermapping added |
Owner: | changed from | to
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in r8994. Dunno why trac didn't catch it in the commit message.
Note:
See TracTickets
for help on using tickets.
posible fixed
@@ -513,7 +513,7 @@
+ gc_kwargs = {GeometryColumns.table_name_col() : db_table, 'f_geometry_columnin':self.mapping}