Opened 8 years ago

Last modified 6 months ago

#11094 new Bug

default_lon and default_lat have no effect for OSMGeoAdmin

Reported by: stuartk Owned by: stuartk
Component: GIS Version: master
Severity: Normal Keywords: OSMGeoAdmin, gis
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using the default_lon and default_lat options with OSMGeoAdmin, no changes are made to the presented map. The options work when using GeoModelAdmin.

Using the examples given on the Open Street Map wiki for using OpenLayers, I have created a small patch to the openlayers.js file. I have tested it, and it doesn't effect the use of GeoModelAdmin.

Attachments (1)

openlayers.diff (771 bytes) - added by stuartk 8 years ago.
Open Layers javascript file patch

Download all attachments as: .zip

Change History (8)

Changed 8 years ago by stuartk

Attachment: openlayers.diff added

Open Layers javascript file patch

comment:1 Changed 8 years ago by stuartk

Owner: changed from nobody to stuartk
Status: newassigned

comment:2 Changed 8 years ago by stuartk

When using the default_lon and default_lat options with OSMGeoAdmin, no changes are made to the presented map. The options work when using GeoModelAdmin.

Using the examples given on the Open Street Map wiki for using OpenLayers, I have created a small patch to the openlayers.js file. I have tested it, and it doesn't effect the use of GeoModelAdmin.

comment:3 Changed 8 years ago by stuartk

Version: 1.1-beta-1SVN

comment:4 Changed 8 years ago by jbronn

Resolution: invalid
Status: assignedclosed

The default_lon and default_lat are not working for you because OSMGeoAdmin uses a different projection system than GeoModelAdmin. Specifically, OSMGeoAdmin uses the so-called "Google" projection (SRID=900913) and GeoModelAdmin uses WGS84 (SRID=4326). As such, just transform your default_lon and default_lat values to 900913:

>>> from django.contrib.gis.geos import Point
>>> pnt = Point(lon, lat, srid=4326)
>>> pnt.transform(900913)
>>> default_lon, default_lat = pnt.coords

comment:5 Changed 6 months ago by Krzysztof Jurewicz

Easy pickings: unset
Has patch: unset
Resolution: invalid
Severity: Normal
Status: closednew
Type: Bug
UI/UX: unset

The comment above actually describes why this bug exists and how to make a workaround, not why it is not a bug. If I’m not mistaken, coordinates in the Web Mercator projection cannot be named “latitude” and “longitude”. Two ways to fix this (not excluding each other):

Ⓐ Assuming that default_lon and default_lat are always given using WGS84 projection and converting them automatically. (Though it would not break any documented behavior, such a change should be probably mentioned in release notes in the section which lists backwards incompatible changes).
Ⓑ Adding a field named default_center which would allow specifying an arbitrary django.contrib.gis.geos.Point object as map center. If no SRID is given, it can possibly be assumed that SRID is the same as the map_srid attribute of the model admin class. As this mechanism is more generic, it would be probably wise to deprecate default_lon and default_lat.

comment:6 Changed 6 months ago by Tim Graham

Summary: OSMGeoAdmin not accepting default_lon and default_latdefault_lon and default_lat have no effect for OSMGeoAdmin
Triage Stage: UnreviewedAccepted

I'm not too knowledgeable about GIS, so I can't comment on the appropriate solution.

comment:7 Changed 6 months ago by Claude Paroz

Option B is interesting. Patch welcome!

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