query-35156caf46920418b5a427a2d8506571
WDQS being weird (railway junctions)Can anybody spot what's going on here ?
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?coords (GROUP_CONCAT(DISTINCT(?elr); separator = ' / ') AS ?elrs) (COUNT(DISTINCT(?desc_stmt)) AS ?count)
(COUNT(DISTINCT(?desc_stmt_b)) AS ?count_b) (GROUP_CONCAT(DISTINCT(?elr_b); separator = ' / ') AS ?elrs_b)
?better ?betterLabel ?stmt WHERE {
?item p:P12928 ?stmt .
?stmt pq:P2241 [] .
# ?stmt a wikibase:BestRank .
OPTIONAL {?item wdt:P625 ?coords} .
OPTIONAL {
?item wdt:P795 ?line .
?line wdt:P10271 ?elr .
OPTIONAL {
?line p:P1343 ?desc_stmt .
?desc_stmt ps:P1343 wd:Q129485508 .
}
}
OPTIONAL {
?stmt pq:P8327 ?better .
OPTIONAL {
?better wdt:P795 ?line_b .
# ?better wdt:P10271 ?elr_b .
OPTIONAL {
?line_b p:P1343 ?desc_stmt_b .
?desc_stmt_b ps:P1343 wd:Q129485508 .
}
}
} .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
} GROUP BY ?item ?itemLabel ?coords ?better ?betterLabel ?stmt
ORDER BY ?itemLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v8("?better"):::projected
v4("?coords"):::projected
v13("?count")
v14("?count_b")
v7("?desc_stmt"):::projected
v10("?desc_stmt_b"):::projected
v6("?elr"):::projected
v11("?elr_b"):::projected
v12("?elrs")
v15("?elrs_b")
v2("?item"):::projected
v1("?itemLabel"):::projected
v5("?line")
v9("?line_b")
v3("?stmt"):::projected
a1((" "))
c13(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal
c11(["bd:serviceParam"]):::iri
c8(["wd:Q129485508"]):::iri
v2 --"p:P12928"--> v3
v3 --"p:qualifier/P2241"--> a1
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P625".-> v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:direct/P795".-> v5
v5 --"p:direct/P10271"--> v6
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:P1343".-> v7
v7 --"p:statement/P1343"--> c8
end
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:qualifier/P8327".-> v8
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v8 -."p:direct/P795".-> v9
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v9 -."p:P1343".-> v10
v10 --"p:statement/P1343"--> c8
end
end
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end
bind4[/"?elr"/]
v6 --o bind4
bind4 --as--o v12
bind5[/"count(?desc_stmt)"/]
v7 --o bind5
bind5 --as--o v13
bind6[/"count(?desc_stmt_b)"/]
v10 --o bind6
bind6 --as--o v14
bind7[/"?elr_b"/]
v11 --o bind7
bind7 --as--o v15