This service receives by post either a (osmid, layout) or a (bbox, layout) and is responsible for asking OCitySMap what are the possible paper size for the given geographic area. As OCitySMap doesn't implement this feature yet, it is only a skeleton that returns a fixed set of paper sizes.
Signed-off-by: Thomas Petazzoni <[email protected]> --- www/maposmatic/views.py | 27 +++++++++++++++++++++++++++ www/urls.py | 2 ++ 2 files changed, 29 insertions(+), 0 deletions(-) diff --git a/www/maposmatic/views.py b/www/maposmatic/views.py index af6020d..996b6a8 100644 --- a/www/maposmatic/views.py +++ b/www/maposmatic/views.py @@ -32,6 +32,7 @@ from django.http import HttpResponseRedirect, HttpResponseBadRequest, HttpRespon 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 ocitysmap.coords import BoundingBox as OCMBoundingBox from www.maposmatic import helpers, forms, nominatim, models import www.settings @@ -197,6 +198,32 @@ def query_nominatim(request, format, squery): mimetype='text/json') # Support other formats here. +def query_papersize(request): + if request.method == 'POST': + osmid = request.POST.get('osmid', None) + layout = request.POST.get('layout', None) + lat_upper_left = request.POST.get('lat_upper_left', None) + lon_upper_left = request.POST.get('lon_upper_left', None) + lat_bottom_right = request.POST.get('lat_bottom_right', None) + lon_bottom_right = request.POST.get('lon_bottom_right', None) + assert layout is not None + if osmid is not None: + assert (lat_upper_left is None and lon_upper_left is None and + lat_bottom_right is None and lon_bottom_right is None) + bbox = helpers.get_bbox_from_osm_id(int(osmid)) + else: + bbox = OCMBoundingBox(lat_upper_left, lon_upper_left, + lat_bottom_right, lon_bottom_right) + + # Do something with bbox, layout + + print bbox, layout + + contents = [ "A4", "US Letter", "A3", "A2" ] + + return HttpResponse(content=json_encode(contents), + mimetype='text/json') + def recreate(request): if request.method == 'POST': form = forms.MapRecreateForm(request.POST) diff --git a/www/urls.py b/www/urls.py index 9dd5da2..b60783d 100644 --- a/www/urls.py +++ b/www/urls.py @@ -64,6 +64,8 @@ urlpatterns = patterns('', (r'^nominatim/([^/]*/)?(.*)$', maposmatic.views.query_nominatim), + (r'^papersize', maposmatic.views.query_papersize), + # Internationalization (r'^i18n/', include('django.conf.urls.i18n')), -- 1.7.0.4
