]> ToastFreeware Gitweb - philipp/winterrodeln/mediawiki_extensions/wrmap.git/blob - readme.md
Updated versions of dependencies.
[philipp/winterrodeln/mediawiki_extensions/wrmap.git] / readme.md
1 # WrMap
2
3 This MediaWiki extension creates a map using OpenLayers to show sledrun details and sledrun overviews.
4 It is developed for https://www.winterrodeln.org/
5 This extension depends on no other extension.
6
7 There is a legacy tag `<wrmap>` to define maps. The new map format is GeoJSON.
8
9
10 ## Definition of `<wrmap`>
11
12 ### Example 1
13
14 ```xml
15 <wrgmap lat="47.267648" lon="11.40465" zoom="10"/>
16 ```
17
18 Shows icons for all sledruns. `lat`, `lon` and `zoom` are optional.
19
20
21
22 ### Example 2
23
24 ```xml
25 <wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
26
27 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
28 <gasthaus name="Stiglreith">47.238186 11.221940</gasthaus>
29 <gasthaus name="Sulzstich">47.240287 11.203006</gasthaus>
30 <parkplatz>47.245789 11.238971</parkplatz>
31 <parkplatz>47.237627 11.218886</parkplatz>
32 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>
33 <achtung name="Kreuzung mit Schipiste">47.2383200 11.2235592</achtung>
34
35 <gehweg>
36 47.238587 11.203360
37 47.239743 11.203522
38 47.240135 11.203247
39 </gehweg>
40
41 <gehweg>
42 47.238442 11.203263
43 47.237799 11.203511
44 47.237133 11.202988
45 47.238091 11.206642
46 47.237273 11.211675
47 47.237133 11.214466
48 47.237513 11.218199
49 </gehweg>
50
51 <alternative>
52 47.240487 11.190169
53 47.238996 11.188628
54 47.238987 11.188018
55 47.238267 11.187075
56 47.238461 11.190511
57 47.239751 11.191795
58 47.240037 11.192702
59 47.239525 11.193535
60 47.239688 11.194272
61 47.239017 11.193925
62 47.239536 11.195457
63 47.240063 11.196230
64 47.240747 11.196658
65 47.239734 11.198295
66 47.238857 11.198346
67 47.237743 11.199778
68 47.238250 11.202755
69 47.238587 11.203360
70 </alternative>
71
72 <rodelbahn>
73 47.238587 11.203360
74 47.238185 11.203982
75 47.238297 11.204381
76 47.239417 11.204972
77 47.239210 11.208772
78 47.238999 11.209523
79 47.239126 11.209839
80 47.238933 11.210641
81 47.239102 11.210739
82 47.238666 11.215042
83 47.238203 11.216089
84 47.238183 11.218151
85 47.237851 11.218599
86 47.238055 11.219755
87 47.237686 11.222441
88 47.238000 11.223367
89 47.238625 11.223687
90 47.239915 11.223118
91 47.240992 11.219781
92 47.243412 11.214141
93 47.243207 11.218331
94 47.243990 11.216205
95 47.243785 11.223251
96 47.242845 11.228510
97 47.242917 11.232501
98 47.242524 11.235001
99 47.244737 11.231791
100 47.244951 11.230868
101 47.245470 11.237853
102 </rodelbahn>
103
104 <lift>
105 47.245656 11.237286
106 47.238189 11.221344
107 </lift>
108
109 </wrmap>
110 ```
111
112
113 ### Definition of `<wrmap`>
114
115 * `<wrmap>...</wrmap>` has to be valid XML.
116 * All coordinates are in WGS84 coordinate system.
117 * Coordinates have the preferred format "latitude N longitude E", however for parsing the N and E can be omitted.
118 * <wrmap> has the following attributes:
119     * `lat` (float): latitude of map-center, WGS84, optional.
120     * `lon` (float): longitude of map-center, WGS84, optional.
121     * `zoom` (integer): zoom level of the map (google zoom levels). optional.
122     * `width` (integer): width of the map in pixel. optional (100% if omitted)
123     * `height` (integer): height of the map in pixel. optional.
124     * `<wrmap>` can have any number of the following sub-elements:
125         * `<gasthaus>`
126         * `<haltestelle>`
127         * `<parkplatz>`
128         * `<achtung>`
129         * `<foto>`
130         * `<verleih>`
131         * `<punkt>`
132         * `<rodelbahn>`
133         * `<alternative>`
134         * `<gehweg>`
135         * `<lift>`
136         * `<anfahrt>`
137         * `<linie>`
138         * The order may be used by the renderer to determine in which order the elements should be drawn: First mentioned elements are drawn first.
139 * `<gasthaus>`, `<haltestelle>`, `<parkplatz>`, `<achtung>`, `<foto>`, `<verleih>` and `<punkt>` define points
140     * The elements may have the following attributes:
141         * `name` (string): defines the name (not the label) of the element
142         * `wiki` (string): name of a MediaWiki page the point refers to
143     * The content is exactly one coordinate pair.
144 * `<rodelbahn>`, `<alternative>`, `<gehweg>`, `<lift>`, `<anfahrt>` and `<linie>` define non-closed polygons.
145     * They may have the following attributes:
146         * `farbe` (hex format, e.g. `#12a50f`): color of the line
147         * `dicke` (int): width of the line in pixel
148     * The content of the elements are a whitespace separated list of coordinates.
149
150
151 ### Transmitting `<wrmap>` with GeoJSON
152
153 For transmitting the map to javascript, GeoJSON is used in the `<div>` element of the map as described below.
154 This way, an extra request is avoided. The GeoJSON format used here consists of a single
155 "FeatureCollection" (representing the `<wrmap>`) containing the sub-elements of wrmap
156 as features.
157
158
159 ## GeoJSON
160
161 The GeoJSON format consists of a single "FeatureCollection" (representing the `<wrmap>` of the legacy format) containing the sub-elements of `<wrmap>` as features.
162
163 The features have a GeoJSON `properties` object with the properties corresonding to the XML subelements of the legacy `wrmap` as described above. Optional attributes/properties can be omitted.
164 One mandatory property entry is called `type` and has the sub-element's name
165 as value (like `Rodelbahn`.)
166 The featurecollection itself has an extra field called `wr_properties` containing the attributes of
167 the wrmap element.
168
169
170 ## Install build dependencies
171
172 The following command uses `package.json` to install all dependencies
173
174     npm install
175
176
177
178 ## Bundle JavaScript/Typescript
179
180 The TypeScript source files are below the src directory.
181 To bundle them, run
182
183     npm run build
184
185 Add `/*@nomin*/` close to the end of `dist/wrmap.mjs` to prevent minification bug: https://phabricator.wikimedia.org/T351610.