2 # -*- coding: iso-8859-15 -*-
3 import wrpylib.wrmwmarkup
8 def test_rodelbahnbox_to_sledrun():
9 wikitext = u'''== Allgemeines ==
11 | Position = 47.309820 N 9.986508 E
18 | Lawinen = gelegentlich
20 | Öffentliche Anreise = Ja
22 | Aufstieg getrennt = Nein
23 | Aufstiegshilfe = Nein
24 | Beleuchtungsanlage = Nein
29 | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
30 | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
31 | In Übersichtskarte = Ja
34 Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
35 start, end, sledrun = wrpylib.wrmwmarkup.rodelbahnbox_to_sledrun(wikitext)
36 wrpylib.wrmwmarkup.sledrun_to_rodelbahnbox(sledrun, '1.3')
40 def test_gasthausbox_to_inn():
41 wikitext = u'''{{Gasthausbox
42 | Position = 47.295549 N 9.986970 E
49 | Handyempfang = A1; T-Mobile/Telering
50 | Homepage = http://www.bergkristallhuette.com/
51 | E-Mail = bergkristallhuette@gmx.at
52 | Telefon = +43-664-1808482
53 | Bild = Bergkritsallhütte 2009-02-07.JPG
54 | Rodelbahnen = [[Bergkristallhütte]]
56 Die Bergkristallhütte ist Teil des Boden-Vorsäß.'''
57 start, end, inn = wrpylib.wrmwmarkup.gasthausbox_to_inn(wikitext)
58 wrpylib.wrmwmarkup.inn_to_gasthausbox(inn)
61 def test_parse_googlemap():
63 <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15">
64 (Parkplatz)47.114958,11.266026
67 (Gasthaus) 47.114715, 11.266262, Alt Bärnbad (Gasthaus)
76 json = wrpylib.wrmwmarkup.parse_googlemap(wikitext)
77 assert json['properties']['lon'] == 11.272337
78 assert json['properties']['lat'] == 47.113291
79 assert json['properties']['zoom'] == 15
80 assert json['features'][0]['properties']['type'] == 'parkplatz'
81 assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
82 assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
83 assert json['features'][1]['properties']['type'] == 'gasthaus'
84 assert json['features'][1]['properties']['name'] == u'Alt Bärnbad (Gasthaus)'
85 assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
86 assert json['features'][2]['properties']['type'] == 'rodelbahn'
87 assert json['features'][2]['geometry']['coordinates'] == [
88 [11.266262, 47.114715],
89 [11.268381, 47.114135],
90 [11.269322, 47.113421],
91 [11.269979, 47.11277],
92 [11.271119, 47.112408]]
95 def test_parse_wrmap():
97 <wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
98 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
99 <parkplatz>47.245789 11.238971</parkplatz>
100 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>
108 json = wrpylib.wrmwmarkup.parse_wrmap(wikitext)
109 assert json['properties']['lon'] == 11.21408895
110 assert json['properties']['lat'] == 47.2417134
111 assert json['properties']['zoom'] == 14
112 assert json['properties']['width'] == 700
113 assert json['properties']['height'] == 400
114 assert json['features'][0]['properties']['type'] == 'gasthaus'
115 assert json['features'][0]['properties']['name'] == u'Rosskogelhütte'
116 assert json['features'][0]['properties']['wiki'] == u'Rosskogelhütte'
117 assert json['features'][0]['geometry']['coordinates'] == [11.190454, 47.240689]
118 assert json['features'][1]['properties']['type'] == 'parkplatz'
119 assert json['features'][1]['geometry']['coordinates'] == [11.238971, 47.245789]
120 assert json['features'][2]['properties']['type'] == 'haltestelle'
121 assert json['features'][2]['properties']['name'] == u'Oberperfuss Rangger Köpfl Lift'
122 assert json['features'][2]['geometry']['coordinates'] == [11.238283, 47.245711]
123 assert json['features'][3]['properties']['type'] == 'rodelbahn'
124 assert json['features'][3]['geometry']['coordinates'] == [
125 [11.203360, 47.238587],
126 [11.230868, 47.244951],
127 [11.237853, 47.245470]]
130 def test_create_wrmap():
132 'type': 'FeatureCollection',
138 'coordinates': [11.190454, 47.240689]},
139 'properties': {'type': 'gasthaus', 'name': u'Rosskogelhütte', 'wiki': u'Rosskogelhütte'}
144 'coordinates': [11.238971, 47.245789]},
145 'properties': {'type': 'parkplatz'}
150 'coordinates': [11.238283, 47.245711]},
151 'properties': {'type': 'haltestelle', 'name': u'Oberperfuss Rangger Köpfl Lift'}
155 'type': 'LineString',
157 [11.203360, 47.238587],
158 [11.230868, 47.244951],
159 [11.237853, 47.245470]]},
160 'properties': {'type': 'rodelbahn'}
170 wikitext = wrpylib.wrmwmarkup.create_wrmap(geojson)
171 assert wikitext == textwrap.dedent(u'''\
172 <wrmap height="400" lat="47.2417134" lon="11.21408895" width="700" zoom="14">
174 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 N 11.190454 E</gasthaus>
175 <parkplatz>47.245789 N 11.238971 E</parkplatz>
176 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 N 11.238283 E</haltestelle>
179 47.238587 N 11.203360 E
180 47.244951 N 11.230868 E
181 47.245470 N 11.237853 E