diff options
| author | Justin Bronn <jbronn@gmail.com> | 2011-03-16 03:07:30 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2011-03-16 03:07:30 +0000 |
| commit | 1e2d896e336cb9461fb9e4d3ab1e7065f13f2ea0 (patch) | |
| tree | 4713466e3fa496772254c22d7f6c71c39ffbe5c8 | |
| parent | 1d628d7ecf9ae832894e54acf7757a62caf7b548 (diff) | |
[1.2.X] Fixed #15533 -- Now use 3857 as spherical mercator projection instead of deprecated 900913 on platforms that support it. Thanks to cnorthwood for bug report and Christopher Schmidt for OpenLayers JavaScript workaround.
Backport of r15845 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15846 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/gis/admin/options.py | 9 | ||||
| -rw-r--r-- | django/contrib/gis/templates/gis/admin/openlayers.js | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py index 1814933f7b..62c45e7220 100644 --- a/django/contrib/gis/admin/options.py +++ b/django/contrib/gis/admin/options.py @@ -113,11 +113,18 @@ class GeoModelAdmin(ModelAdmin): from django.contrib.gis import gdal if gdal.HAS_GDAL: + # Use the official spherical mercator projection SRID on versions + # of GDAL that support it; otherwise, fallback to 900913 + if gdal.GDAL_VERSION >= (1, 7): + spherical_mercator_srid = 3857 + else: + spherical_mercator_srid = 900913 + class OSMGeoAdmin(GeoModelAdmin): map_template = 'gis/admin/osm.html' extra_js = ['http://openstreetmap.org/openlayers/OpenStreetMap.js'] num_zoom = 20 - map_srid = 900913 + map_srid = spherical_mercator_srid max_extent = '-20037508,-20037508,20037508,20037508' max_resolution = '156543.0339' point_zoom = num_zoom - 6 diff --git a/django/contrib/gis/templates/gis/admin/openlayers.js b/django/contrib/gis/templates/gis/admin/openlayers.js index 4324693c78..c455bffd58 100644 --- a/django/contrib/gis/templates/gis/admin/openlayers.js +++ b/django/contrib/gis/templates/gis/admin/openlayers.js @@ -1,4 +1,5 @@ {# Author: Justin Bronn, Travis Pinney & Dane Springmeyer #} +OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857", OpenLayers.Layer.SphericalMercator.projectForward); {% block vars %}var {{ module }} = {}; {{ module }}.map = null; {{ module }}.controls = null; {{ module }}.panel = null; {{ module }}.re = new RegExp("^SRID=\d+;(.+)", "i"); {{ module }}.layers = {}; {{ module }}.modifiable = {{ modifiable|yesno:"true,false" }}; |
