2 # -*- coding: iso-8859-15 -*-
3 import wrpylib.wrmwmarkup
4 import wrpylib.mwmarkup
9 def test_rodelbahnbox_to_sledrun():
10 wikitext = u'''== Allgemeines ==
12 | Position = 47.309820 N 9.986508 E
19 | Lawinen = gelegentlich
21 | Öffentliche Anreise = Ja
23 | Aufstieg getrennt = Nein
24 | Aufstiegshilfe = Nein
25 | Beleuchtungsanlage = Nein
30 | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
31 | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
32 | In Übersichtskarte = Ja
35 Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
36 start, end, sledrun = wrpylib.wrmwmarkup.rodelbahnbox_to_sledrun(wikitext)
37 wrpylib.wrmwmarkup.sledrun_to_rodelbahnbox(sledrun, '1.3')
41 def test_gasthausbox_to_inn():
42 wikitext = u'''{{Gasthausbox
43 | Position = 47.295549 N 9.986970 E
50 | Handyempfang = A1; T-Mobile/Telering
51 | Homepage = http://www.bergkristallhuette.com/
52 | E-Mail = bergkristallhuette@gmx.at
53 | Telefon = +43-664-1808482
54 | Bild = Bergkritsallhütte 2009-02-07.JPG
55 | Rodelbahnen = [[Bergkristallhütte]]
57 Die Bergkristallhütte ist Teil des Boden-Vorsäß.'''
58 start, end, inn = wrpylib.wrmwmarkup.gasthausbox_to_inn(wikitext)
59 wrpylib.wrmwmarkup.inn_to_gasthausbox(inn)
62 def test_googlemap_to_wrmap():
64 <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15">
65 (Parkplatz)47.114958,11.266026
68 (Gasthaus) 47.114715, 11.266262, Alt Bärnbad (Gasthaus)
77 center, zoom, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
78 json = wrpylib.wrmwmarkup.googlemap_to_wrmap(center, zoom, coords, paths)
79 assert json['properties']['lon'] == 11.272337
80 assert json['properties']['lat'] == 47.113291
81 assert json['properties']['zoom'] == 15
82 assert json['features'][0]['properties']['type'] == 'parkplatz'
83 assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
84 assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
85 assert json['features'][1]['properties']['type'] == 'gasthaus'
86 assert json['features'][1]['properties']['name'] == u'Alt Bärnbad (Gasthaus)'
87 assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
88 assert json['features'][2]['properties']['type'] == 'rodelbahn'
89 assert json['features'][2]['geometry']['coordinates'] == [
90 [11.266262, 47.114715],
91 [11.268381, 47.114135],
92 [11.269322, 47.113421],
93 [11.269979, 47.11277],
94 [11.271119, 47.112408]]
97 def test_parse_wrmap():
99 <wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
100 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
101 <parkplatz>47.245789 11.238971</parkplatz>
102 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>
110 json = wrpylib.wrmwmarkup.parse_wrmap(wikitext)
111 assert json['properties']['lon'] == 11.21408895
112 assert json['properties']['lat'] == 47.2417134
113 assert json['properties']['zoom'] == 14
114 assert json['properties']['width'] == 700
115 assert json['properties']['height'] == 400
116 assert json['features'][0]['properties']['type'] == 'gasthaus'
117 assert json['features'][0]['properties']['name'] == u'Rosskogelhütte'
118 assert json['features'][0]['properties']['wiki'] == u'Rosskogelhütte'
119 assert json['features'][0]['geometry']['coordinates'] == [11.190454, 47.240689]
120 assert json['features'][1]['properties']['type'] == 'parkplatz'
121 assert json['features'][1]['geometry']['coordinates'] == [11.238971, 47.245789]
122 assert json['features'][2]['properties']['type'] == 'haltestelle'
123 assert json['features'][2]['properties']['name'] == u'Oberperfuss Rangger Köpfl Lift'
124 assert json['features'][2]['geometry']['coordinates'] == [11.238283, 47.245711]
125 assert json['features'][3]['properties']['type'] == 'rodelbahn'
126 assert json['features'][3]['geometry']['coordinates'] == [
127 [11.203360, 47.238587],
128 [11.230868, 47.244951],
129 [11.237853, 47.245470]]
132 def test_create_wrmap():
134 'type': 'FeatureCollection',
140 'coordinates': [11.190454, 47.240689]},
141 'properties': {'type': 'gasthaus', 'name': u'Rosskogelhütte', 'wiki': u'Rosskogelhütte'}
146 'coordinates': [11.238971, 47.245789]},
147 'properties': {'type': 'parkplatz'}
152 'coordinates': [11.238283, 47.245711]},
153 'properties': {'type': 'haltestelle', 'name': u'Oberperfuss Rangger Köpfl Lift'}
157 'type': 'LineString',
159 [11.203360, 47.238587],
160 [11.230868, 47.244951],
161 [11.237853, 47.245470]]},
162 'properties': {'type': 'rodelbahn'}
172 wikitext = wrpylib.wrmwmarkup.create_wrmap(geojson)
173 assert wikitext == textwrap.dedent(u'''\
174 <wrmap height="400" lat="47.2417134" lon="11.21408895" width="700" zoom="14">
176 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 N 11.190454 E</gasthaus>
177 <parkplatz>47.245789 N 11.238971 E</parkplatz>
178 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 N 11.238283 E</haltestelle>
181 47.238587 N 11.203360 E
182 47.244951 N 11.230868 E
183 47.245470 N 11.237853 E