2 # -*- coding: iso-8859-15 -*-
3 import wrpylib.wrmwmarkup
7 def test_rodelbahnbox_to_sledrun():
8 wikitext = u'''== Allgemeines ==
10 | Position = 47.309820 N 9.986508 E
17 | Lawinen = gelegentlich
19 | Öffentliche Anreise = Ja
21 | Aufstieg getrennt = Nein
22 | Aufstiegshilfe = Nein
23 | Beleuchtungsanlage = Nein
28 | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
29 | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
30 | In Übersichtskarte = Ja
33 Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
34 start, end, sledrun = wrpylib.wrmwmarkup.rodelbahnbox_to_sledrun(wikitext)
35 wrpylib.wrmwmarkup.sledrun_to_rodelbahnbox(sledrun, '1.3')
39 def test_gasthausbox_to_inn():
40 wikitext = u'''{{Gasthausbox
41 | Position = 47.295549 N 9.986970 E
48 | Handyempfang = A1; T-Mobile/Telering
49 | Homepage = http://www.bergkristallhuette.com/
50 | E-Mail = bergkristallhuette@gmx.at
51 | Telefon = +43-664-1808482
52 | Bild = Bergkritsallhütte 2009-02-07.JPG
53 | Rodelbahnen = [[Bergkristallhütte]]
55 Die Bergkristallhütte ist Teil des Boden-Vorsäß.'''
56 start, end, inn = wrpylib.wrmwmarkup.gasthausbox_to_inn(wikitext)
57 wrpylib.wrmwmarkup.inn_to_gasthausbox(inn)
60 def test_parse_googlemap():
62 <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15">
63 (Parkplatz)47.114958,11.266026
66 (Gasthaus) 47.114715, 11.266262, Alt Bärnbad (Gasthaus)
75 json = wrpylib.wrmwmarkup.parse_googlemap(wikitext)
76 assert json['properties']['lon'] == 11.272337
77 assert json['properties']['lat'] == 47.113291
78 assert json['properties']['zoom'] == 15
79 assert json['features'][0]['properties']['type'] == 'parkplatz'
80 assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
81 assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
82 assert json['features'][1]['properties']['type'] == 'gasthaus'
83 assert json['features'][1]['properties']['name'] == u'Alt Bärnbad (Gasthaus)'
84 assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
85 assert json['features'][2]['properties']['type'] == 'rodelbahn'
86 assert json['features'][2]['geometry']['coordinates'] == [
87 [11.266262, 47.114715],
88 [11.268381, 47.114135],
89 [11.269322, 47.113421],
90 [11.269979, 47.11277],
91 [11.271119, 47.112408]]
94 def test_parse_wrmap():
96 <wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
97 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
98 <parkplatz>47.245789 11.238971</parkplatz>
99 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>
107 json = wrpylib.wrmwmarkup.parse_wrmap(wikitext)
108 assert json['properties']['lon'] == 11.21408895
109 assert json['properties']['lat'] == 47.2417134
110 assert json['properties']['zoom'] == 14
111 assert json['properties']['width'] == 700
112 assert json['properties']['height'] == 400
113 assert json['features'][0]['properties']['type'] == 'gasthaus'
114 assert json['features'][0]['properties']['name'] == u'Rosskogelhütte'
115 assert json['features'][0]['properties']['wiki'] == u'Rosskogelhütte'
116 assert json['features'][0]['geometry']['coordinates'] == [11.190454, 47.240689]
117 assert json['features'][1]['properties']['type'] == 'parkplatz'
118 assert json['features'][1]['geometry']['coordinates'] == [11.238971, 47.245789]
119 assert json['features'][2]['properties']['type'] == 'haltestelle'
120 assert json['features'][2]['properties']['name'] == u'Oberperfuss Rangger Köpfl Lift'
121 assert json['features'][2]['geometry']['coordinates'] == [11.238283, 47.245711]
122 assert json['features'][3]['properties']['type'] == 'rodelbahn'
123 assert json['features'][3]['geometry']['coordinates'] == [
124 [11.203360, 47.238587],
125 [11.230868, 47.244951],
126 [11.237853, 47.245470]]
129 def test_create_wrmap():
130 attributes = {'lon': 11.21408895, 'lat': 47.2417134, 'zoom': 14, 'width': 700, 'height': 400}
132 'type': 'FeatureCollection',
138 'coordinates': [11.190454, 47.240689]},
139 'properties': {'type': 'inn', 'name': u'Rosskogelhütte', 'wiki': u'Rosskogelhütte'}
144 'coordinates': [11.238971, 47.245789]},
145 'properties': {'type': 'carpark'}
150 'coordinates': [11.238283, 47.245711]},
151 'properties': {'type': 'busstop', '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': 'sledrun'}
164 wikitext = wrpylib.wrmwmarkup.create_wrmap(attributes, geojson)
165 assert wikitext == u'''
166 <wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
167 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
168 <parkplatz>47.245789 11.238971</parkplatz>
169 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>