4 from pylons import request, response, session, url, tmpl_context as c
5 from pylons.controllers.util import abort, redirect
8 from wradmin.lib.base import BaseController, render
9 import wrpylib.wrvalidators
11 log = logging.getLogger(__name__)
13 class CoordtoolController(BaseController):
17 return render('coordtool.html')
21 input = request.POST['input']
22 no_elevation = 'no_elevation' in request.POST
23 simplify = 'simplify' in request.POST
24 swap_latlon = 'swap_latlon' in request.POST
25 c.no_geoformat = 'no_geoformat' in request.POST
26 c.no_gpxformat = 'no_gpxformat' in request.POST
27 c.no_gmapsformat = 'no_gmapsformat' in request.POST
28 c.no_geocachingformat = 'no_geocachingformat' in request.POST
30 if input is None or len(input.strip()) == 0:
32 return redirect(url(controller='coordtool', action='index'))
34 geo = wrpylib.wrvalidators.MultiGeo()
35 try: c.result = geo.to_python(input)
36 except formencode.Invalid as e:
37 session['flash'] = str(e)
39 return redirect(url(controller='coordtool', action='index'))
42 c.result = [(latitude, longitude, elevation) for (longitude, latitude, elevation) in c.result]
45 c.result = [(longitude, latitude, None) for (longitude, latitude, elevation) in c.result]
47 c.geo_winterrodeln = wrpylib.wrvalidators.MultiGeo(output_format = geo.FORMAT_WINTERRODELN)
48 c.geo_gmapplugin = wrpylib.wrvalidators.MultiGeo(output_format = geo.FORMAT_GMAPPLUGIN)
49 c.geo_gpx = wrpylib.wrvalidators.MultiGeo(output_format = geo.FORMAT_GPX)
50 c.geo_geocaching = wrpylib.wrvalidators.MultiGeo(output_format = geo.FORMAT_GEOCACHING)
52 return render('coordtool.html')