maposmatic-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] [PATCH maposmatic 3/4] OCitySMap python module renamed


From: Maxime Petazzoni
Subject: [Maposmatic-dev] [PATCH maposmatic 3/4] OCitySMap python module renamed from ocitysmap2 to ocitysmap
Date: Mon, 7 May 2012 19:13:27 -0700

Signed-off-by: Maxime Petazzoni <address@hidden>
---
 scripts/render.py           |   13 ++++++-------
 www/maposmatic/forms.py     |   13 ++++++-------
 www/maposmatic/helpers.py   |    1 -
 www/maposmatic/nominatim.py |    4 ++--
 www/maposmatic/views.py     |   21 +++++++++++----------
 5 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/scripts/render.py b/scripts/render.py
index 0094b33..021d63b 100755
--- a/scripts/render.py
+++ b/scripts/render.py
@@ -34,9 +34,8 @@ import threading
 import traceback
 import subprocess
 
-import ocitysmap2
-import ocitysmap2.coords
-from ocitysmap2 import renderers
+import ocitysmap
+from ocitysmap import renderers
 from www.maposmatic.models import MapRenderingJob
 from www.settings import ADMINS, OCITYSMAP_CFG_PATH
 from www.settings import RENDERING_RESULT_PATH, RENDERING_RESULT_FORMATS
@@ -289,18 +288,18 @@ class JobRenderer(threading.Thread):
         l.info("Rendering job #%d '%s'..." % (self.job.id, self.job.maptitle))
 
         try:
-            renderer = ocitysmap2.OCitySMap(OCITYSMAP_CFG_PATH)
-            config = ocitysmap2.RenderingConfiguration()
+            renderer = ocitysmap.OCitySMap(OCITYSMAP_CFG_PATH)
+            config = ocitysmap.RenderingConfiguration()
             config.title = self.job.maptitle
             config.osmid = self.job.administrative_osmid
 
             if config.osmid:
                 bbox_wkt, area_wkt \
                     = renderer.get_geographic_info(config.osmid)
-                config.bounding_box = ocitysmap2.coords.BoundingBox.parse_wkt(
+                config.bounding_box = ocitysmap.coords.BoundingBox.parse_wkt(
                     bbox_wkt)
             else:
-                config.bounding_box = ocitysmap2.coords.BoundingBox(
+                config.bounding_box = ocitysmap.coords.BoundingBox(
                         self.job.lat_upper_left,
                         self.job.lon_upper_left,
                         self.job.lat_bottom_right,
diff --git a/www/maposmatic/forms.py b/www/maposmatic/forms.py
index 91e378c..b89ad4f 100644
--- a/www/maposmatic/forms.py
+++ b/www/maposmatic/forms.py
@@ -28,7 +28,7 @@ from django import forms
 from django.utils.safestring import mark_safe
 from django.utils.translation import ugettext_lazy as _
 
-from ocitysmap2 import OCitySMap, coords
+import ocitysmap
 from www.maposmatic import models, widgets
 import www.settings
 
@@ -82,7 +82,7 @@ class MapRenderingJobForm(forms.ModelForm):
     def __init__(self, *args, **kwargs):
         super(MapRenderingJobForm, self).__init__(*args, **kwargs)
 
-        self._ocitysmap = OCitySMap(www.settings.OCITYSMAP_CFG_PATH)
+        self._ocitysmap = ocitysmap.OCitySMap(www.settings.OCITYSMAP_CFG_PATH)
 
         layout_renderers = self._ocitysmap.get_all_renderers()
         stylesheets = self._ocitysmap.get_all_style_configurations()
@@ -226,10 +226,9 @@ class MapRenderingJobForm(forms.ModelForm):
             lat_bottom_right = cleaned_data.get("lat_bottom_right")
             lon_bottom_right = cleaned_data.get("lon_bottom_right")
 
-            boundingbox = coords.BoundingBox(lat_upper_left,
-                                             lon_upper_left,
-                                             lat_bottom_right,
-                                             lon_bottom_right)
+            boundingbox = ocitysmap.coords.BoundingBox(
+                lat_upper_left, lon_upper_left,
+                lat_bottom_right, lon_bottom_right)
             (metric_size_lat, metric_size_long) = boundingbox.spheric_sizes()
             if (metric_size_lat > www.settings.BBOX_MAXIMUM_LENGTH_IN_METERS
                 or metric_size_long > 
www.settings.BBOX_MAXIMUM_LENGTH_IN_METERS):
@@ -243,7 +242,7 @@ class MapRenderingJobForm(forms.ModelForm):
         rendering (bounding box not too large, etc.). Raise an exception in
         case of error."""
         bbox_wkt, area_wkt = self._ocitysmap.get_geographic_info(osm_id)
-        bbox = coords.BoundingBox.parse_wkt(bbox_wkt)
+        bbox = ocitysmap.coords.BoundingBox.parse_wkt(bbox_wkt)
         (metric_size_lat, metric_size_long) = bbox.spheric_sizes()
         if metric_size_lat > www.settings.BBOX_MAXIMUM_LENGTH_IN_METERS or \
                 metric_size_long > www.settings.BBOX_MAXIMUM_LENGTH_IN_METERS:
diff --git a/www/maposmatic/helpers.py b/www/maposmatic/helpers.py
index 85f2389..6cb2520 100644
--- a/www/maposmatic/helpers.py
+++ b/www/maposmatic/helpers.py
@@ -27,7 +27,6 @@ import psycopg2
 import random
 import string
 
-from ocitysmap2 import coords
 from www.maposmatic.models import MapRenderingJob
 import www.settings
 
diff --git a/www/maposmatic/nominatim.py b/www/maposmatic/nominatim.py
index 485c4a1..b72a24e 100644
--- a/www/maposmatic/nominatim.py
+++ b/www/maposmatic/nominatim.py
@@ -40,7 +40,7 @@ from urllib import urlencode
 import urllib2
 from xml.etree.ElementTree import parse as XMLTree
 
-from ocitysmap2 import coords
+import ocitysmap
 import www.settings
 from www.maposmatic import gisdb
 
@@ -235,7 +235,7 @@ def _get_admin_boundary_info_from_GIS(cursor, osm_id):
             continue
 
         osm_id, admin_level, bboxtxt = result[0]
-        bbox = coords.BoundingBox.parse_wkt(bboxtxt)
+        bbox = ocitysmap.coords.BoundingBox.parse_wkt(bboxtxt)
         (metric_size_lat, metric_size_lon) = bbox.spheric_sizes()
         if (metric_size_lat > www.settings.BBOX_MAXIMUM_LENGTH_IN_METERS
             or metric_size_lon > www.settings.BBOX_MAXIMUM_LENGTH_IN_METERS):
diff --git a/www/maposmatic/views.py b/www/maposmatic/views.py
index 9c4cae6..6a1f3ca 100644
--- a/www/maposmatic/views.py
+++ b/www/maposmatic/views.py
@@ -34,7 +34,7 @@ from django.shortcuts import get_object_or_404, 
render_to_response
 from django.template import RequestContext
 from django.utils.translation import ugettext_lazy as _
 
-from ocitysmap2 import OCitySMap, coords, renderers
+import ocitysmap
 from www.maposmatic import helpers, forms, nominatim, models
 import www.settings
 
@@ -224,20 +224,20 @@ def query_papersize(request):
     if request.method == 'POST':
         f = forms.MapPaperSizeForm(request.POST)
         if f.is_valid():
-            ocitysmap  = OCitySMap(www.settings.OCITYSMAP_CFG_PATH)
-            osmid      = f.cleaned_data.get('osmid')
-            layout     = f.cleaned_data.get('layout')
-            stylesheet = ocitysmap.get_stylesheet_by_name(
+            renderer = ocitysmap.OCitySMap(www.settings.OCITYSMAP_CFG_PATH)
+            osmid = f.cleaned_data.get('osmid')
+            layout = f.cleaned_data.get('layout')
+            stylesheet = renderer.get_stylesheet_by_name(
                 f.cleaned_data.get('stylesheet'))
 
             # Determine geographic area
             if osmid is not None:
                 try:
-                    bbox_wkt, area_wkt = ocitysmap.get_geographic_info(osmid)
+                    bbox_wkt, area_wkt = renderer.get_geographic_info(osmid)
                 except ValueError:
                     LOG.exception("Error determining compatible paper sizes")
                     raise
-                bbox = coords.BoundingBox.parse_wkt(bbox_wkt)
+                bbox = ocitysmap.coords.BoundingBox.parse_wkt(bbox_wkt)
             else:
                 lat_upper_left = f.cleaned_data.get("lat_upper_left")
                 lon_upper_left = f.cleaned_data.get("lon_upper_left")
@@ -249,10 +249,11 @@ def query_papersize(request):
                     or lat_bottom_right == None or lon_bottom_right == None):
                    return HttpResponseBadRequest("ERROR: Invalid arguments")
 
-                bbox = coords.BoundingBox(lat_upper_left, lon_upper_left,
-                                          lat_bottom_right, lon_bottom_right)
+                bbox = ocitysmap.coords.BoundingBox(
+                    lat_upper_left, lon_upper_left,
+                    lat_bottom_right, lon_bottom_right)
 
-            renderer_cls = renderers.get_renderer_class_by_name(layout)
+            renderer_cls = 
ocitysmap.renderers.get_renderer_class_by_name(layout)
             paper_sizes = sorted(renderer_cls.get_compatible_paper_sizes(bbox),
                                  key = lambda p: p[1])
 
-- 
1.7.10




reply via email to

[Prev in Thread] Current Thread [Next in Thread]