--- /dev/null
+#!/usr/bin/python2.5
+# -*- coding: iso-8859-15 -*-
+
+import logging
+
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+
+from wradmin.lib.base import BaseController, render
+import wradmin.model.validators
+
+log = logging.getLogger(__name__)
+
+class CoordtoolController(BaseController):
+
+ def index(self):
+ c.result = None
+ return render('coordtool.html')
+
+
+ def convert(self):
+ input = request.POST['input']
+ no_height = request.POST.has_key('no_height')
+ simplify = request.POST.has_key('simplify')
+ swap_latlon = request.POST.has_key('swap_latlon')
+ no_geoformat = request.POST.has_key('no_geoformat')
+ no_gpxformat = request.POST.has_key('no_gpxformat')
+ no_gmapsformat = request.POST.has_key('no_gmapsformat')
+
+ if input is None or len(input.strip()) == 0:
+ c.result = None
+ return redirect_to(controller='coordtool', action='index')
+
+ geo = wradmin.model.validators.MultiGeo()
+ c.result = geo.to_python(input)
+ c.geo_winterrodeln = wradmin.model.validators.MultiGeo(output_format = geo.FORMAT_WINTERRODELN)
+ c.geo_geocaching = wradmin.model.validators.MultiGeo(output_format = geo.FORMAT_GEOCACHING)
+
+ return render('coordtool.html')
\ No newline at end of file
--- /dev/null
+#!/usr/bin/python2.5
+# -*- coding: iso-8859-15 -*-
+
+import logging
+
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+
+from wradmin.lib.base import BaseController, render
+
+log = logging.getLogger(__name__)
+
+class WrgpxtoolController(BaseController):
+
+ def index(self):
+ return render('wrgpxtool.html')
return u'%.6f N %.6f E' % (latitude, longitude)
+class MultiGeo(formencode.FancyValidator):
+ "Formats multiple coordinates, even in multiple lines to [(latitude, longitude, height), ...] or [(latitude, longitude, None), ...] tuplets."
+
+ # Valid for input_format
+ FORMAT_GUESS = 0 # guesses the input format; default for input_format
+ FORMAT_NONE = -1 # indicates missing formats
+
+ # Valid for input_format and output_format
+ FORMAT_GEOCACHING = 1 # e.g. "N 47° 13.692 E 011° 25.535"
+ FORMAT_WINTERRODELN = 2 # e.g. "47.222134 N 11.467211 E"
+ FORMAT_GMAPPLUGIN = 3 # e.g. "47.232922, 11.452239"
+ FORMAT_GPX = 4 # e.g. "<trkpt lat="47.181289" lon="11.408827"><ele>1090.57</ele></trkpt>"
+
+ input_format = FORMAT_GUESS
+ output_format = FORMAT_WINTERRODELN
+ last_input_format = FORMAT_NONE
+
+ def __init__(self, input_format = FORMAT_GUESS, output_format = FORMAT_WINTERRODELN, **keywords):
+ self.input_format = input_format
+ self.output_format = output_format
+ formencode.FancyValidator.__init__(self, if_empty = (None, None, None), **keywords)
+
+ def _to_python(self, value, state):
+ input_format = self.input_format
+ if not input_format in [self.FORMAT_GUESS, self.FORMAT_GEOCACHING, self.FORMAT_WINTERRODELN, self.FORMAT_GMAPPLUGIN, self.FORMAT_GPX]:
+ raise formencode.Invalid(u"input_format %d is not recognized" % input_format, value, state) # Shouldn't it be an other type of runtime error?
+ lines = [line.strip() for line in value.split("\n") if len(line.strip()) > 0]
+
+ result = []
+ for line in lines:
+ if input_format == self.FORMAT_GUESS or input_format == self.FORMAT_GEOCACHING:
+ pass
+
+ if input_format == self.FORMAT_GUESS or input_format == self.FORMAT_WINTERRODELN:
+ r = re.match(u'(\d+\.\d+) N (\d+\.\d+) E', line)
+ if not r is None:
+ result.append((float(r.groups()[0]), float(r.groups()[1]), None))
+ last_input_format = self.FORMAT_WINTERRODELN
+ continue
+
+ if input_format == self.FORMAT_GUESS or input_format == FORMAT_GMAPPLUGIN:
+ pass
+
+ if input_format == self.FORMAT_GUESS or input_format == self.FORMAT_GPX:
+ pass
+
+ raise formencode.Invalid(u"Coordinates '%s' have no valid format" % value, value, state)
+
+ return result
+
+ def _from_python(self, value, state):
+ output_format = self.output_format
+ result = []
+ for latitude, longitude, height in value:
+ if output_format == self.FORMAT_GEOCACHING:
+ degree = latitude
+ result.append(u'N %02d° %02.3f E %03d° %02.3f' % (latitude, latitude % 1 * 60, longitude, longitude % 1 * 60))
+
+ elif output_format == self.FORMAT_WINTERRODELN:
+ result.append(u'%.6f N %.6f E' % (latitude, longitude))
+
+ elif output_format == FORMAT_GMAPPLUGIN:
+ pass
+
+ elif output_format == self.FORMAT_GPX:
+ pass
+
+ else:
+ raise formencode.Invalid(u"output_format %d is not recognized" % output_format, value, state) # Shouldn't it be an other type of runtime error?
+
+ return "\n".join(result)
+
+
class AustrianPhoneNumber(formencode.FancyValidator):
"""
Validates and converts phone numbers to +##/###/####### or +##/###/#######-### (having an extension)
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+<xi:include href="master.html" />
+
+<head>
+ <title>Koordinaten-Rechner</title>
+</head>
+
+<body>
+
+<h2>Koordinaten-Rechner</h2>
+
+<p py:if="not c.result">Werkzeug für die Koordinatenumrechnung. Das Quellformat braucht nicht angegeben zu werden, es sollte automatisch erkannt werden. Wenn mehr als eine Koordinate gleichzeitig umgerechnet werden soll, dann bitte pro Zeile eine Koordinate angeben.</p>
+
+<h3 py:if="c.result">Winterrodeln-Format</h3>
+<p py:if="c.result">
+ <py:for each="line in c.result">${c.geo_winterrodeln.from_python([line])}<br/></py:for>
+</p>
+
+<h3 py:if="c.result">Geocaching-Format</h3>
+<p py:if="c.result">
+ <py:for each="line in c.result">${c.geo_geocaching.from_python([line])}<br/></py:for>
+</p>
+
+<form action="${h.url_for(controller='coordtool', action='convert')}" method="post">
+<table>
+ <tr><th></th><th>Beispiel</th></tr>
+ <tr><td><textarea name="input" cols="70" rows="10"/></td>
+ <td>
+ <p>47.222134 N 11.467211 E<br/>
+ 47.222143 N 11.467209 E<br/>
+ 47.222153 N 11.467210 E</p>
+ <p>N 47° 14.912 E 011° 27.432<br/>
+ N 47° 14.925 E 011° 27.439<br/>
+ N 47° 14.936 E 011° 27.440</p>
+ </td></tr>
+ <tr><td><input type="checkbox" name="no_height" />Höhe weglassen</td><td></td></tr>
+ <tr><td><input type="checkbox" name="simplify" /> Weg vereinfachen</td><td></td></tr>
+ <tr><td><input type="checkbox" name="swap_latlon" />Geogr. Länge und Breite vertauschen</td><td></td></tr>
+ <tr><td><input type="checkbox" name="no_geoformat" /> Zielformat <strong><geo></strong> auslassen</td><td>47.222134 N 11.467211 E</td></tr>
+ <tr><td><input type="checkbox" name="no_gpxformat" /> Zielformat <strong><GPX></strong> auslassen</td><td><trkpt lat="47.181289" lon="11.408827"><ele>1090.57</ele></trkpt></td></tr>
+ <tr><td><input type="checkbox" name="no_gmapsformat" /> Zielformat <strong>Google Maps Plugin</strong> auslassen</td><td>47.232922, 11.452239</td></tr>
+ <tr><td><input type="submit" value="Konvertieren"/></td><td></td></tr>
+</table>
+</form>
+
+</body>
+</html>
<li><a href="${h.url_for(controller='rodelbahn', action='list')}">Rodelbahnen</a></li>
<li><a href="${h.url_for(controller='bericht', action='list')}">Rodelbahnberichte</a></li>
<li><a href="${h.url_for(controller='gasthaus', action='list')}">Gasthäuser</a></li>
+ <li><a href="${h.url_for(controller='maptool', action='index')}">Maptool</a></li>
+ <li><a href="${h.url_for(controller='coordtool', action='index')}">Koordinaten-Rechner</a></li>
+ <li><a href="${h.url_for(controller='wrgpxtool', action='index')}">Winterrodeln-GPX Datei Werkzeuge</a></li>
</ul>
<ul>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+<xi:include href="master.html" />
+
+<head>
+ <title>WRGPX-Werkzeug</title>
+</head>
+
+<body>
+
+<h2>WRGPX-Werkzeug</h2>
+
+<p>WRGPX steht für "Winterrodeln GPX".</p>
+
+
+</body>
+</html>
--- /dev/null
+from wradmin.tests import *
+
+class TestCoordtoolController(TestController):
+
+ def test_index(self):
+ response = self.app.get(url(controller='coordtool', action='index'))
+ # Test response...
--- /dev/null
+from wradmin.tests import *
+
+class TestWrgpxtoolController(TestController):
+
+ def test_index(self):
+ response = self.app.get(url(controller='wrgpxtool', action='index'))
+ # Test response...