Skip to content

Commit

Permalink
Fixed #15533 -- Now use 3857 as spherical mercator projection instead…
Browse files Browse the repository at this point in the history
… of deprecated 900913 on platforms that support it. Thanks to cnorthwood for bug report and Christopher Schmidt for OpenLayers JavaScript workaround.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15845 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jbronn committed Mar 16, 2011
1 parent 10e1f5d commit ebd5682
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion django/contrib/gis/admin/options.py
Expand Up @@ -113,11 +113,18 @@ class OLMap(self.widget):


from django.contrib.gis import gdal from django.contrib.gis import gdal
if gdal.HAS_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): class OSMGeoAdmin(GeoModelAdmin):
map_template = 'gis/admin/osm.html' map_template = 'gis/admin/osm.html'
extra_js = ['http://www.openstreetmap.org/openlayers/OpenStreetMap.js'] extra_js = ['http://www.openstreetmap.org/openlayers/OpenStreetMap.js']
num_zoom = 20 num_zoom = 20
map_srid = 900913 map_srid = spherical_mercator_srid
max_extent = '-20037508,-20037508,20037508,20037508' max_extent = '-20037508,-20037508,20037508,20037508'
max_resolution = '156543.0339' max_resolution = '156543.0339'
point_zoom = num_zoom - 6 point_zoom = num_zoom - 6
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/templates/gis/admin/openlayers.js
@@ -1,4 +1,5 @@
{# Author: Justin Bronn, Travis Pinney & Dane Springmeyer #} {# Author: Justin Bronn, Travis Pinney & Dane Springmeyer #}
OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857", OpenLayers.Layer.SphericalMercator.projectForward);
{% block vars %}var {{ module }} = {}; {% block vars %}var {{ module }} = {};
{{ module }}.map = null; {{ module }}.controls = null; {{ module }}.panel = null; {{ module }}.re = new RegExp("^SRID=\d+;(.+)", "i"); {{ module }}.layers = {}; {{ module }}.map = null; {{ module }}.controls = null; {{ module }}.panel = null; {{ module }}.re = new RegExp("^SRID=\d+;(.+)", "i"); {{ module }}.layers = {};
{{ module }}.modifiable = {{ modifiable|yesno:"true,false" }}; {{ module }}.modifiable = {{ modifiable|yesno:"true,false" }};
Expand Down

0 comments on commit ebd5682

Please sign in to comment.