2 # -*- coding: iso-8859-15 -*-
6 from pylons import request, response, session, url, tmpl_context as c
7 from pylons.controllers.util import abort, redirect
10 from wradmin.lib.base import BaseController, render
11 import wradmin.model.validators
13 log = logging.getLogger(__name__)
15 class CoordtoolController(BaseController):
19 return render('coordtool.html')
23 input = request.POST['input']
24 no_elevation = request.POST.has_key('no_elevation')
25 simplify = request.POST.has_key('simplify')
26 swap_latlon = request.POST.has_key('swap_latlon')
27 c.no_geoformat = request.POST.has_key('no_geoformat')
28 c.no_gpxformat = request.POST.has_key('no_gpxformat')
29 c.no_gmapsformat = request.POST.has_key('no_gmapsformat')
30 c.no_geocachingformat = request.POST.has_key('no_geocachingformat')
32 if input is None or len(input.strip()) == 0:
34 return redirect(url(controller='coordtool', action='index'))
36 geo = wradmin.model.validators.MultiGeo()
37 try: c.result = geo.to_python(input)
38 except formencode.Invalid, e:
39 session['flash'] = unicode(e)
41 return redirect(url(controller='coordtool', action='index'))
44 c.result = [(latitude, longitude, elevation) for (longitude, latitude, elevation) in c.result]
47 c.result = [(longitude, latitude, None) for (longitude, latitude, elevation) in c.result]
49 c.geo_winterrodeln = wradmin.model.validators.MultiGeo(output_format = geo.FORMAT_WINTERRODELN)
50 c.geo_gmapplugin = wradmin.model.validators.MultiGeo(output_format = geo.FORMAT_GMAPPLUGIN)
51 c.geo_gpx = wradmin.model.validators.MultiGeo(output_format = geo.FORMAT_GPX)
52 c.geo_geocaching = wradmin.model.validators.MultiGeo(output_format = geo.FORMAT_GEOCACHING)
54 return render('coordtool.html')