query-d5a25bf06adb9bf316c8158bb5de8e07
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"hide": ["?rgb", "?coord1","?coord2","?line"]}
SELECT DISTINCT ?station1 ?station1Label ?coord1 ?wiki ?rgb ?line
WHERE {
?station1 wdt:P31/wdt:P279* wd:Q928830;
wdt:P361 wd:Q50716;
wdt:P625 ?coord1.
OPTIONAL {
?station1 wdt:P197 ?station2.
?station2 wdt:P625 ?coord2.
?station1 p:P625 [ ps:P625 []; psv:P625 [ wikibase:geoLongitude ?coord1lon; wikibase:geoLatitude ?coord1lat; ] ] .
?station2 p:P625 [ ps:P625 []; psv:P625 [ wikibase:geoLongitude ?coord2lon; wikibase:geoLatitude ?coord2lat; ] ] .
BIND(CONCAT('LINESTRING (', STR(?coord1lon), ' ', STR(?coord1lat), ',', STR(?coord2lon), ' ', STR(?coord2lat), ')') AS ?str) .
BIND(STRDT(?str, geo:wktLiteral) AS ?line) .
}
OPTIONAL {
?frwiki schema:about ?station1 .
?frwiki schema:isPartOf <https://fr.wikipedia.org/> .
}
OPTIONAL {
?enwiki schema:about ?station1 .
?enwiki schema:isPartOf <https://en.wikipedia.org/> .
}
BIND (IF(BOUND(?frwiki), "006400", IF(BOUND(?enwiki), "F7E35F", "FF0000")) AS ?rgb)
BIND (COALESCE(?frwiki, ?enwiki) AS ?wiki)
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" . }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?coord1"):::projected
v6("?coord1lat")
v5("?coord1lon")
v4("?coord2")
v8("?coord2lat")
v7("?coord2lon")
v12("?enwiki")
v11("?frwiki")
v10("?line"):::projected
v13("?rgb"):::projected
v1("?station1"):::projected
v3("?station2")
v9("?str")
v14("?wiki"):::projected
a3((" "))
a1((" "))
a2((" "))
a4((" "))
a5((" "))
a7((" "))
a6((" "))
c15([https://fr.wikipedia.org/]):::iri
c3(["wd:Q928830"]):::iri
c16([https://en.wikipedia.org/]):::iri
c18(["bd:serviceParam"]):::iri
c5(["wd:Q50716"]):::iri
c20(["fr,en"]):::literal
v1 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> c3
v1 --"p:direct/P361"--> c5
v1 --"p:direct/P625"--> v2
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P197".-> v3
v3 --"p:direct/P625"--> v4
a2 --"p:statement/P625"--> a3
a4 --"wikibase:geoLongitude"--> v5
a4 --"wikibase:geoLatitude"--> v6
a2 --"p:statement/value/P625"--> a4
v1 --"p:P625"--> a2
a5 --"p:statement/P625"--> a6
a7 --"wikibase:geoLongitude"--> v7
a7 --"wikibase:geoLatitude"--> v8
a5 --"p:statement/value/P625"--> a7
v3 --"p:P625"--> a5
bind0[/"concat('LINESTRING (',str(?coord1lon),' ',str(?coord1lat),',',str(?coord2lon),' ',str(?coord2lat),')')"/]
v5 --o bind0
v6 --o bind0
v7 --o bind0
v8 --o bind0
bind0 --as--o v9
bind1[/"STRDT(?str,'geo:wktLiteral')"/]
v9 --o bind1
bind1 --as--o v10
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v11 -."schema:about".-> v1
v11 --"schema:isPartOf"--> c15
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v12 -."schema:about".-> v1
v12 --"schema:isPartOf"--> c16
end
bind2[/"if(bound(?frwiki),'006400',if(bound(?enwiki),'F7E35F','FF0000'))"/]
v11 --o bind2
v12 --o bind2
bind2 --as--o v13
bind3[/"?frwiki?enwiki"/]
v11 --o bind3
v12 --o bind3
bind3 --as--o v14
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c18 --"wikibase:language"--> c20
end