Opened 15 years ago
Closed 3 years ago
#11094 closed Bug (duplicate)
default_lon and default_lat have no effect for OSMGeoAdmin
Reported by: | stuartk | Owned by: | stuartk |
---|---|---|---|
Component: | GIS | Version: | dev |
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)
Change History (9)
by , 15 years ago
Attachment: | openlayers.diff added |
---|
comment:1 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 15 years ago
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 by , 15 years ago
Version: | 1.1-beta-1 → SVN |
---|
comment:4 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
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 by , 8 years ago
Easy pickings: | unset |
---|---|
Has patch: | unset |
Resolution: | invalid |
Severity: | → Normal |
Status: | closed → new |
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 by , 8 years ago
Summary: | OSMGeoAdmin not accepting default_lon and default_lat → default_lon and default_lat have no effect for OSMGeoAdmin |
---|---|
Triage Stage: | Unreviewed → Accepted |
I'm not too knowledgeable about GIS, so I can't comment on the appropriate solution.
comment:8 by , 3 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
#11634 has a very similar fix, but that one takes into account display_srid. That might be a reasonable way to settle the SRID of default_lat and default_lon. So I'm boldly marking this one as the duplicate, even though it came first.
Open Layers javascript file patch