Template:Rapid transit OSM map/doc
| This is a documentation subpage for Template:Rapid transit OSM map. It may contain usage information, categories and other content that is not part of the original template page. |
The template generally works if the lines that make up the system have their own Wikidata entries (e.g. Lua error in Module:Wd at line 633: attempt to index field 'wikibase' (a nil value). (Q7388350) for Zürich S-Bahn), and the entries are connected to an OpenStreetMap line child feature.
Each Wikidata line entity's (P5817) should be Lua error in Module:Wd at line 633: attempt to index field 'wikibase' (a nil value). (Q55654238) and should include the (P16) property (for instance on the Lua error in Module:Wd at line 633: attempt to index field 'wikibase' (a nil value). (Q7388350) entity, (P16) -> Lua error in Module:Wd at line 633: attempt to index field 'wikibase' (a nil value). (Q636091)).
This is a wrapper for Template:Maplink. It fetches `geoline` features and shows them within the template. The template works through a SPARQL Wikidata query. The vital field is `system_qid`, which determines the central item from which all other data is pulled.
First, try this on the Wikipedia page of an item that is supposed to show up on the map (e.g. a metro line):
{{mapframe|frame = yes | type = line | stroke-width = 2}}
If it's not displayed, the item might not yet be linked to an OSM feature.
Usage
[edit source]{{Rapid transit OSM map
| system_qid = <!-- Optional. By default It'll assume the wikidata id linked to the page it is being used on. -->
| system_qid[2-5] = <!-- use upto 4 additional systems -->
| frame-lat =
| frame-long =
| frame-width =
| frame-height =
| frame-align =
| stroke-width = <!-- Default is 3, use 2 for dense networks -->
| plain =
| text =
| zoom =
| display =
| single_line = <!-- Useful to show a specific transit line. See examples below -->
| stations = <!-- Any value will show the stations of a line/system. -->
| stations_qid = <!-- Optional. By default It'll assume the wikidata id linked to the page it is being used on. -->
|rail-colour=<!-- Optional. Use this hex colo(u)r instead of the official Wikidata colour without the #. Eg 000000 for black -->
| marker-symbol = <!-- If stations is set; Default is rail-metro -->
| marker-colo(u)r = <!-- If stations is set. -->
| marker-size = <!-- If stations is set; Default is medium. -->
}}
Examples
[edit source]Rapid transit system
[edit source]Frankfurt
[edit source]<mapframe zoom="10" align="left" text="Frankfurt" height="440" width="500">[ { "type": "ExternalData", "service": "geoline", "properties": { "stroke-width": 4 }, "query": "SELECT ?id (if(BOUND(?idhexcolor), concat('#', str(?idhexcolor)), if(BOUND(?hexcolor), concat('#', str(?hexcolor)), '#07c63e')) as ?stroke) (concat('Line length: ', str(?length), ' km') as ?description) (if(BOUND(?link), concat('', ?idLabel, ''), ?idLabel) as ?title) WHERE { VALUES ?sys { wd:Q705684 } { ?id p:P5817/ps:P5817 wd:Q55654238. ?id wdt:P16/wdt:P361* ?sys. } MINUS { VALUES ?rem { wd:Q548662 wd:Q55697304 } ?id wdt:P31/wdt:P279* ?rem. } OPTIONAL { ?id wdt:P465 ?idhexcolor. } OPTIONAL { ?id wdt:P462 ?color. ?color wdt:P465 ?hexcolor.} SERVICE wikibase:label { bd:serviceParam wikibase:language 'en,mul' . ?id rdfs:label ?idLabel . } OPTIONAL {?link schema:about ?id. ?link schema:isPartOf <https://en.wikipedia.org/> . } } GROUP BY ?id ?link ?idLabel ?length ?hexcolor ?idhexcolor "}, ]</mapframe>
Moscow
[edit source]<mapframe text="Moscow" align="left" longitude="37.6" latitude="55.75" height="440" width="500">[ { "type": "ExternalData", "service": "geoline", "properties": { "stroke-width": 4 }, "query": "SELECT ?id (if(BOUND(?idhexcolor), concat('#', str(?idhexcolor)), if(BOUND(?hexcolor), concat('#', str(?hexcolor)), '#07c63e')) as ?stroke) (concat('Line length: ', str(?length), ' km') as ?description) (if(BOUND(?link), concat('', ?idLabel, ''), ?idLabel) as ?title) WHERE { VALUES ?sys { wd:Q5499 } { ?id p:P5817/ps:P5817 wd:Q55654238. ?id wdt:P16/wdt:P361* ?sys. } MINUS { VALUES ?rem { wd:Q548662 wd:Q55697304 } ?id wdt:P31/wdt:P279* ?rem. } OPTIONAL { ?id wdt:P465 ?idhexcolor. } OPTIONAL { ?id wdt:P462 ?color. ?color wdt:P465 ?hexcolor.} SERVICE wikibase:label { bd:serviceParam wikibase:language 'en,mul' . ?id rdfs:label ?idLabel . } OPTIONAL {?link schema:about ?id. ?link schema:isPartOf <https://en.wikipedia.org/> . } } GROUP BY ?id ?link ?idLabel ?length ?hexcolor ?idhexcolor "}, ]</mapframe>
A specific line of a system
[edit source]<mapframe zoom="11" text="Zurich S6" align="left" height="440" latitude="47.34" longitude="8.57" width="400">[ { "type": "ExternalData", "service": "geoline", "properties": { "stroke-width": 4 }, "query": "SELECT ?id (if(BOUND(?idhexcolor), concat('#', str(?idhexcolor)), if(BOUND(?hexcolor), concat('#', str(?hexcolor)), '#07c63e')) as ?stroke) (concat('Line length: ', str(?length), ' km') as ?description) (if(BOUND(?link), concat('', ?idLabel, ''), ?idLabel) as ?title) WHERE { VALUES ?sys { wd:Q7388350 } { ?id p:P5817/ps:P5817 wd:Q55654238. ?id wdt:P16 */wdt:P361* ?sys. } MINUS { VALUES ?rem { wd:Q548662 wd:Q55697304 } ?id wdt:P31/wdt:P279* ?rem. } OPTIONAL { ?id wdt:P465 ?idhexcolor. } OPTIONAL { ?id wdt:P462 ?color. ?color wdt:P465 ?hexcolor.} SERVICE wikibase:label { bd:serviceParam wikibase:language 'en,mul' . ?id rdfs:label ?idLabel . } OPTIONAL {?link schema:about ?id. ?link schema:isPartOf <https://en.wikipedia.org/> . } } GROUP BY ?id ?link ?idLabel ?length ?hexcolor ?idhexcolor "}, { "type": "ExternalData", "service": "geopoint", "properties": { "marker-symbol": "rail-metro", "marker-size" : "small"}, "query": "SELECT DISTINCT ?id ?geo ?marker_color (if(BOUND(?image), concat('File:', substr(str(?image), 52, 400), ''), ?typeLabel) as ?description) (if(BOUND(?link), concat('', ?idLabel, ''), ?idLabel) as ?title) WHERE { VALUES ?sqid { wd:Q7388350 } { ?id p:P5817/ps:P5817 wd:Q55654238; wdt:P81/wdt:P16*|wdt:P1192/wdt:P16* ?sqid; wdt:P625 ?geo. } MINUS { VALUES ?not { wd:Q6501349 } ?id wdt:P31/wdt:P279* ?not. } OPTIONAL { ?id wdt:P18 ?image. } OPTIONAL { ?sqid wdt:P465 ?idhexcolor. } OPTIONAL { ?sqid wdt:P462/wdt:P465 ?hexcolor. } BIND(COALESCE(?idhexcolor,?hexcolor,'5c72f2') as ?marker_color) SERVICE wikibase:label { bd:serviceParam wikibase:language 'en,mul' . ?id rdfs:label ?idLabel . } OPTIONAL {?link schema:about ?id. ?link schema:isPartOf <https://en.wikipedia.org/> . } }" }]</mapframe>
Rapid transit network of a region
[edit source]<mapframe zoom="10" text="Athens" align="left" height="440" latitude="37.99" longitude="23.73" width="500">[ { "type": "ExternalData", "service": "geoline", "properties": { "stroke-width": 4 }, "query": "SELECT ?id (if(BOUND(?idhexcolor), concat('#', str(?idhexcolor)), if(BOUND(?hexcolor), concat('#', str(?hexcolor)), '#07c63e')) as ?stroke) (concat('Line length: ', str(?length), ' km') as ?description) (if(BOUND(?link), concat('', ?idLabel, ''), ?idLabel) as ?title) WHERE { VALUES ?sys { wd:Q1814382 } { ?id p:P5817/ps:P5817 wd:Q55654238. ?id wdt:P16/wdt:P361* ?sys. } MINUS { VALUES ?rem { wd:Q548662 wd:Q55697304 } ?id wdt:P31/wdt:P279* ?rem. } OPTIONAL { ?id wdt:P465 ?idhexcolor. } OPTIONAL { ?id wdt:P462 ?color. ?color wdt:P465 ?hexcolor.} SERVICE wikibase:label { bd:serviceParam wikibase:language 'en,mul' . ?id rdfs:label ?idLabel . } OPTIONAL {?link schema:about ?id. ?link schema:isPartOf <https://en.wikipedia.org/> . } } GROUP BY ?id ?link ?idLabel ?length ?hexcolor ?idhexcolor "}, ]</mapframe>
See also
[edit source]