Fixed #9278, #9694 -- Geographic overlays now display in admin with right to left langauges; simplified transformation process in `OpenLayersWidget` to fix Ubuntu 8.10/Apache 2.2.9 crash; updated OpenLayers version to 2.7.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9733 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ffeb1d0465
commit
6c4e5f0f0e
|
@ -28,12 +28,11 @@ class GeoModelAdmin(ModelAdmin):
|
||||||
scale_text = True
|
scale_text = True
|
||||||
layerswitcher = True
|
layerswitcher = True
|
||||||
scrollable = True
|
scrollable = True
|
||||||
admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
|
|
||||||
map_width = 600
|
map_width = 600
|
||||||
map_height = 400
|
map_height = 400
|
||||||
map_srid = 4326
|
map_srid = 4326
|
||||||
map_template = 'gis/admin/openlayers.html'
|
map_template = 'gis/admin/openlayers.html'
|
||||||
openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js'
|
openlayers_url = 'http://openlayers.org/api/2.7/OpenLayers.js'
|
||||||
wms_url = 'http://labs.metacarta.com/wms/vmap0'
|
wms_url = 'http://labs.metacarta.com/wms/vmap0'
|
||||||
wms_layer = 'basic'
|
wms_layer = 'basic'
|
||||||
wms_name = 'OpenLayers WMS'
|
wms_name = 'OpenLayers WMS'
|
||||||
|
@ -76,8 +75,7 @@ class GeoModelAdmin(ModelAdmin):
|
||||||
class OLMap(self.widget):
|
class OLMap(self.widget):
|
||||||
template = self.map_template
|
template = self.map_template
|
||||||
geom_type = db_field._geom
|
geom_type = db_field._geom
|
||||||
params = {'admin_media_prefix' : self.admin_media_prefix,
|
params = {'default_lon' : self.default_lon,
|
||||||
'default_lon' : self.default_lon,
|
|
||||||
'default_lat' : self.default_lat,
|
'default_lat' : self.default_lat,
|
||||||
'default_zoom' : self.default_zoom,
|
'default_zoom' : self.default_zoom,
|
||||||
'display_wkt' : self.debug or self.display_wkt,
|
'display_wkt' : self.debug or self.display_wkt,
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.gis.gdal import OGRException
|
from django.contrib.gis.gdal import OGRException
|
||||||
from django.contrib.gis.geos import GEOSGeometry, GEOSException
|
from django.contrib.gis.geos import GEOSGeometry, GEOSException
|
||||||
from django.forms.widgets import Textarea
|
from django.forms.widgets import Textarea
|
||||||
from django.template.loader import render_to_string
|
from django.template import loader, Context
|
||||||
|
from django.utils import translation
|
||||||
|
|
||||||
|
# Creating a template context that contains Django settings
|
||||||
|
# values needed by admin map templates.
|
||||||
|
geo_context = Context({'ADMIN_MEDIA_PREFIX' : settings.ADMIN_MEDIA_PREFIX,
|
||||||
|
'LANGUAGE_BIDI' : translation.get_language_bidi(),
|
||||||
|
})
|
||||||
|
|
||||||
class OpenLayersWidget(Textarea):
|
class OpenLayersWidget(Textarea):
|
||||||
"""
|
"""
|
||||||
|
@ -40,8 +48,9 @@ class OpenLayersWidget(Textarea):
|
||||||
srid = self.params['srid']
|
srid = self.params['srid']
|
||||||
if value.srid != srid:
|
if value.srid != srid:
|
||||||
try:
|
try:
|
||||||
value.transform(srid)
|
ogr = value.ogr
|
||||||
wkt = value.wkt
|
ogr.transform(srid)
|
||||||
|
wkt = ogr.wkt
|
||||||
except OGRException:
|
except OGRException:
|
||||||
wkt = ''
|
wkt = ''
|
||||||
else:
|
else:
|
||||||
|
@ -51,7 +60,8 @@ class OpenLayersWidget(Textarea):
|
||||||
# geometry.
|
# geometry.
|
||||||
self.params['wkt'] = wkt
|
self.params['wkt'] = wkt
|
||||||
|
|
||||||
return render_to_string(self.template, self.params)
|
return loader.render_to_string(self.template, self.params,
|
||||||
|
context_instance=geo_context)
|
||||||
|
|
||||||
def map_options(self):
|
def map_options(self):
|
||||||
"Builds the map options hash for the OpenLayers template."
|
"Builds the map options hash for the OpenLayers template."
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#{{ id }}_map { width: {{ map_width }}px; height: {{ map_height }}px; }
|
#{{ id }}_map { width: {{ map_width }}px; height: {{ map_height }}px; }
|
||||||
#{{ id }}_map .aligned label { float:inherit; }
|
#{{ id }}_map .aligned label { float:inherit; }
|
||||||
#{{ id }}_admin_map { position: relative; vertical-align: top; float: left; }
|
#{{ id }}_admin_map { position: relative; vertical-align: top; float: {{ LANGUAGE_BIDI|yesno:"right,left" }}; }
|
||||||
{% if not display_wkt %}#{{ id }} { display: none; }{% endif %}
|
{% if not display_wkt %}#{{ id }} { display: none; }{% endif %}
|
||||||
.olControlEditingToolbar .olControlModifyFeatureItemActive {
|
.olControlEditingToolbar .olControlModifyFeatureItemActive {
|
||||||
background-image: url("{{ admin_media_prefix }}img/gis/move_vertex_on.png");
|
background-image: url("{{ ADMIN_MEDIA_PREFIX }}img/gis/move_vertex_on.png");
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
.olControlEditingToolbar .olControlModifyFeatureItemInactive {
|
.olControlEditingToolbar .olControlModifyFeatureItemInactive {
|
||||||
background-image: url("{{ admin_media_prefix }}img/gis/move_vertex_off.png");
|
background-image: url("{{ ADMIN_MEDIA_PREFIX }}img/gis/move_vertex_off.png");
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
{% block openlayers %}{% include "gis/admin/openlayers.js" %}{% endblock %}
|
{% block openlayers %}{% include "gis/admin/openlayers.js" %}{% endblock %}
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
<div id="{{ id }}_map"></div>
|
<div id="{{ id }}_map"{% if LANGUAGE_BIDI %} dir="ltr"{% endif %}></div>
|
||||||
<a href="javascript:{{ module }}.clearFeatures()">Delete all Features</a>
|
<a href="javascript:{{ module }}.clearFeatures()">Delete all Features</a>
|
||||||
{% if display_wkt %}<p> WKT debugging window:</p>{% endif %}
|
{% if display_wkt %}<p> WKT debugging window:</p>{% endif %}
|
||||||
<textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ field_name }}">{{ wkt }}</textarea>
|
<textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ field_name }}">{{ wkt }}</textarea>
|
||||||
|
|
Loading…
Reference in New Issue