Closed adonm closed 14 years ago
It should in fact use collection_wkt, not get_wkt. Geodjango supports multi-geometry types, where a single model field is a collection of geometries. collection_wkt supports that case as well as the case where one is using just a single geometry, and since InfoMap is a read-only map, it doesn't matter if we make it a collection type.
I think my issue is related with this:
TemplateSyntaxError at /resource/poi/1/
Caught an exception while rendering: 'float' object has no attribute 'ogr'
File "contrib/olwidget/widgets.py", line 283, in get_wkt ogr = value.ogr AttributeError: 'float' object has no attribute 'ogr'
This is my view code, p.geom is a PointField
def poi_view(request, object_id): p = get_object_or_404(Poi, pk=object_id)
map = InfoMap([
[ p.geom, p.name + p.description ],
], options = { 'layers': ['ve.hybrid'], 'default_zoom ' : 5 })
return render_to_response('resource/poi_detail.html', {
'object': p,
'map': map,
})
I dont' understand the line:
# convert fields to wkt
for geom, html in self.info:
wkt_array = [[add_srid(collection_wkt(geom)), html] for geom, html in self.info]
Is seems like it's looping two times over the same collection...
Thanks elpaso, you (and adonm) are correct. The former code works properly only in the case where "geom" is a collection type, and thus iterable. This is fixed in 4f361c323ab932e9ecae97edb4583efde62d4a4c .
Oops, introduced a regression there for changelist maps. Fixed in latest master.
In olwidget/widgets.py under InfoMap this line (198): wkt_array = [[add_srid(collection_wkt(geom)), html] for geom, html in self.info] should be wkt_array = [[add_srid(get_wkt(geom)), html] for geom, html in self.info]
because each geom is a single spatial feature not an array?
I'm new to the whole submitting patches thing so I just made an issue.