Module:OSM
[voir] [modifier] [historique] [purger]
Utilisation
modifier{{#invoke:OSM|overpass}}
- Rechercher Openstreetmap indépendamment des tags wikidata
{{#invoke:OSM|wd}}
- Rechercher des objets ayant le tag wikidata=Q.... en Openstreetmap
{{#invoke:OSM|etym}}
- Rechercher des objets ayant le tag name:etymology:wikidata=Q....= en Openstreetmap
{{#invoke:OSM|subject}}
- Rechercher des objets ayant le tag subject:wikidata=Q....= en Openstreetmap
{{#invoke:OSM|artist}} {{#invoke:OSM|architect}} {{#invoke:OSM|subject}} {{#invoke:OSM|operator}} {{#invoke:OSM|brand}}
Paramètres
modifier- display : Texte rendu
- timeout : par défaut: 15s
- link : par défaut: yes, mettre no, si on veut utiliser le uri dans d'autres sjablônes comme {{Citer web}}
- id : peut contenir 1 ou plusieurs items Q de wikidata, la valeur par défaut est l'identifiant wikidata de la page même
- query : il est possible de limiter la recherche pour n'avoir que des highway, par exemple
- prim : specifier pour limiter la recherche aux objets de type node, way et/ou relation
- coord : coördonnées et un facteur de zoom factor dans ce format: 47.0618984;15.4370248;17
- limitToBBOX: par défaut: yes, s'il y a de coordonnées la requête sera limité dans la zone affichée
- run : par défaut: yes, Utiliser no si c'est l'intention que l'utilisateur fait d'autres modifications à la requête ou pour qu'il puisse chercher dans une autre région sur la carte
Exemples
modifierPour des exemples, voir la page de test permettant de tester diverses modifications apportées. 3 tests failed.
Text | Expected | Actual | |
---|---|---|---|
{{#invoke:OSM|etym|display=Map|id=Q2360250}} | [http://overpass-turbo.eu/?Q=%28%0Anode%5B%22name%3Aetymology%3Awikidata%22%3D%22Q2360250%22%5D%3B%0Away%5B%22name%3Aetymology%3Awikidata%22%3D%22Q2360250%22%5D%3B%0Arelation%5B%22name%3Aetymology%3Awikidata%22%3D%22Q2360250%22%5D%3B%0A%29%3B%0Aout%3B%0A%3E%3B%0Aout%20meta%20qt%3B%0A&R Map] | [http://overpass-turbo.eu/?Q=%5Btimeout%3A20%5D%5Bout%3Ajson%5D%3B%0A%28%0Anode%5B%22name%3Aetymology%3Awikidata%22~%22%28%5E%7C%3B%29%28Q2360250%29%28%3B%7C%24%29%22%5D%3B%0Away%5B%22name%3Aetymology%3Awikidata%22~%22%28%5E%7C%3B%29%28Q2360250%29%28%3B%7C%24%29%22%5D%3B%0Arelation%5B%22name%3Aetymology%3Awikidata%22~%22%28%5E%7C%3B%29%28Q2360250%29%28%3B%7C%24%29%22%5D%3B%0A%3E%3E%3B%0A%29%3B%0Aout%20geom%3B%0A%7B%7Bstyle%3A%0Anode%20%5Bname%3Aetymology%3Awikidata%5D%7B%0A%20%20text%3A%20name%3B%0A%20%20icon-width%3A%2032%3B%7D%0A%7D%7D%0A&R Map] |
Text | Expected | Actual | |
---|---|---|---|
{{#invoke:OSM|wd|display=Vresse and Florenville|id=Q650206;Q713300}} | [http://overpass-turbo.eu/?Q=%28%0Anode%5B%22wikidata%22~%22%5BQ650206%7CQ713300%5D%22%5D%3B%0Away%5B%22wikidata%22~%22%5BQ650206%7CQ713300%5D%22%5D%3B%0Arelation%5B%22wikidata%22~%22%5BQ650206%7CQ713300%5D%22%5D%3B%0A%29%3B%0Aout%3B%0A%3E%3B%0Aout%20meta%20qt%3B%0A&R Vresse and Florenville] | [http://overpass-turbo.eu/?Q=%5Btimeout%3A20%5D%5Bout%3Ajson%5D%3B%0A%28%0Anode%5B%22wikidata%22~%22%28%5E%7C%3B%29%28Q650206%7CQ713300%29%28%3B%7C%24%29%22%5D%3B%0Away%5B%22wikidata%22~%22%28%5E%7C%3B%29%28Q650206%7CQ713300%29%28%3B%7C%24%29%22%5D%3B%0Arelation%5B%22wikidata%22~%22%28%5E%7C%3B%29%28Q650206%7CQ713300%29%28%3B%7C%24%29%22%5D%3B%0A%3E%3E%3B%0A%29%3B%0Aout%20geom%3B%0A%7B%7Bstyle%3A%0Anode%20%5Bwikidata%5D%7B%0A%20%20text%3A%20name%3B%0A%20%20icon-width%3A%2032%3B%7D%0A%7D%7D%0A&R Vresse and Florenville] | |
{{#invoke:OSM|wd|display=Church of Vresse|id=Q20748715|coord=49.71513;5.23446;14}} | [http://overpass-turbo.eu/?Q=%28%0Anode%5B%22wikidata%22%3D%22Q20748715%22%5D%28%7B%7Bbbox%7D%7D%29%3B%20%2F%2F%20remove%20the%20%28%7B%7Bbbox%7D%7D%29if%20you%20want%20the%20query%20to%20be%20executed%20globally%0Away%5B%22wikidata%22%3D%22Q20748715%22%5D%28%7B%7Bbbox%7D%7D%29%3B%0Arelation%5B%22wikidata%22%3D%22Q20748715%22%5D%28%7B%7Bbbox%7D%7D%29%3B%0A%29%3B%0Aout%3B%0A%3E%3B%0Aout%20meta%20qt%3B%0A&C=49.71513;5.23446;14&R Church of Vresse] | [http://overpass-turbo.eu/?Q=%5Btimeout%3A20%5D%5Bout%3Ajson%5D%3B%0A%28%0Anode%5B%22wikidata%22~%22%28%5E%7C%3B%29%28Q20748715%29%28%3B%7C%24%29%22%5D%28%7B%7Bbbox%7D%7D%29%3B%20%2F%2F%20remove%20the%20%28%7B%7Bbbox%7D%7D%29if%20you%20want%20the%20query%20to%20be%20executed%20globally%0Away%5B%22wikidata%22~%22%28%5E%7C%3B%29%28Q20748715%29%28%3B%7C%24%29%22%5D%28%7B%7Bbbox%7D%7D%29%3B%0Arelation%5B%22wikidata%22~%22%28%5E%7C%3B%29%28Q20748715%29%28%3B%7C%24%29%22%5D%28%7B%7Bbbox%7D%7D%29%3B%0A%3E%3E%3B%0A%29%3B%0Aout%20geom%3B%0A%7B%7Bstyle%3A%0Anode%20%5Bwikidata%5D%7B%0A%20%20text%3A%20name%3B%0A%20%20icon-width%3A%2032%3B%7D%0A%7D%7D%0A&C=49.71513;5.23446;14&R Church of Vresse] |
La documentation de ce module est générée par le modèle {{Documentation module}}.
Elle est incluse depuis sa sous-page de documentation. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local function buildquery(frame, target)
local textToDisplay, leftLink, rightLink, runQueryRightAway, itemObject, itemID, query, coord, bbox, remark, overpassUrl, primitives, timeout, style, logo
local args = frame.args
if args.display then
-- text to display on link
textToDisplay = ' ' .. args.display
else
textToDisplay = ''
end
if args.timeout then
timeout = '[timeout:' .. args.timeout .. '][out:json];\n'
else
timeout = '[timeout:20][out:json];\n'
end
if args.link and args.link == 'no' then
-- just return the url
leftLink = ''
rightLink = ''
textToDisplay = ''
else
leftLink = '['
rightLink = ']'
end
if args.run and args.run == 'no' then
-- don't run immediately
runQueryRightAway = ''
else
runQueryRightAway = '&R'
end
if args.id then
-- build query for specific Q-item(s)
itemID = args.id
pcall(function () itemObject = mw.wikibase.getEntityObject(mw.text.split(itemID,";")[1]) end)
else
itemObject = mw.wikibase.getEntityObject()
if itemObject == nil then
return "This page doesn't have a wikidata entry"
end
-- build query for current page
itemID = itemObject.id
end
-- Always perform a regular expression based search
-- It happens that multiple values are in the data
itemID = '"~"(^|;)(' .. itemID:gsub(";", "\|") .. ')(;|$)'
if args.query then
-- user can add their own tags to filter on
query = args.query
else
query = ''
end
if args.coord and not(args.limitToBBOX=='no') then
-- The user can provide coordinates and a zoom factor
coord = '&C=' .. args.coord
-- In that case we can limit the search to the area in view
bbox = '({{bbox}})'
-- and tell them how to search wider.
remark = ' // remove the ' .. bbox .. 'if you want the query to be executed globally'
else
coord = ''
bbox = ''
remark = ''
end
overpassUrl = timeout .. '(\n'
-- if the user specifies prim(itives), but then leaves the string empty, abort
if args.prim then
if args.prim == '' then
return "Please indicate which primitives you want to query for"
end
primitives = args.prim
else
primitives = 'nwr'
end
if primitives:find("n") then
-- Include nodes
overpassUrl = overpassUrl .. 'node["' .. target .. itemID ..'"]' .. query .. bbox .. ';' .. remark .. '\n'
end
if primitives:find("w") then
-- Include ways
overpassUrl = overpassUrl .. 'way["' .. target .. itemID .. '"]' .. query .. bbox .. ';\n'
end
if primitives:find("r") then
-- Include relations
overpassUrl = overpassUrl .. 'relation["' .. target .. itemID .. '"]' .. query .. bbox .. ';\n>>;\n'
end
overpassUrl = overpassUrl .. ');\n'
overpassUrl = overpassUrl .. 'out geom;\n'
if args.style then
style = args.style
else
if args.logo then
logo = " icon-image: url(" .. args.logo .. ');\n'
else
if itemObject then
logo = tostring(itemObject:formatPropertyValues('P154')['value']):gsub("'", "'")
end
if logo and not(logo == '') then
logo = ' icon-image: url("https://commons.wikimedia.org/wiki/Special:Redirect/file/'.. logo .. '");\n'
end
end
if logo then
style = "node [".. target .."]{\n text: name;\n".. logo .. " icon-width: 32;}"
end
end
if style then
overpassUrl = overpassUrl .. '{{style:\n' .. style .. '\n}}\n'
end
return leftLink .. 'http://overpass-turbo.eu/?Q=' .. mw.uri.encode(overpassUrl, "PATH" ) .. coord .. runQueryRightAway .. textToDisplay .. rightLink
end
local p = {}
function p.overpass( frame )
return buildquery(frame, '')
end
function p.wd( frame )
return buildquery(frame, 'wikidata')
end
function p.pt( frame )
frame.args.style = "node {\n opacity: 0;\n fill-opacity: 0;}\nnode[highway=bus_stop], way[highway=bus_stop]{\n text: name;\n icon-image: url('icons/maki/bus-18.png');\n icon-width: 18;}"
frame.args.prim = "r"
frame.args.timeout = 50
return buildquery(frame, 'wikidata')
end
function p.etym( frame )
return buildquery(frame, 'name:etymology:wikidata')
end
function p.subject( frame )
return buildquery(frame, 'subject:wikidata')
end
function p.artist( frame )
return buildquery(frame, 'artist:wikidata')
end
function p.architect( frame )
return buildquery(frame, 'architect:wikidata')
end
function p.operator( frame )
return buildquery(frame, 'operator:wikidata')
end
function p.brand( frame )
return buildquery(frame, 'brand:wikidata')
end
return p