query-dccb85291f0f0698da681382c0230c3f
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
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 ?ville1 ?ville1Label ?dir1Label ?ddy1 ?dfy1 ?ville2 ?ville2Label ?dir2Label ?ddy2 ?dfy2 ?ddym ?dfym WHERE {
VALUES ?route { wd:Q1624187 } .
?route p:P609 ?s1 .
?s1 ps:P609 ?ville1 .
OPTIONAL { ?s1 pq:P560 ?dir1 } .
OPTIONAL { ?s1 pq:P580 ?dd1 } .
BIND (year(?dd1) AS ?ddy1)
OPTIONAL { ?s1 pq:P582 ?df1 } .
BIND (year(?df1) AS ?dfy1)
?route p:P609 ?s2 .
?s2 ps:P609 ?ville2 .
OPTIONAL { ?s2 pq:P560 ?dir2 } .
OPTIONAL { ?s2 pq:P580 ?dd2 } .
BIND (year(?dd2) AS ?ddy2)
OPTIONAL { ?s2 pq:P582 ?df2 } .
BIND (year(?df2) AS ?dfy2)
BIND(IF(BOUND(?ddy1) && !BOUND(?ddy2),?ddy1,IF(!BOUND(?ddy1) && BOUND(?ddy2),?ddy2,IF(!BOUND(?ddy1) && !BOUND(?ddy2),0,IF(?ddy1 >= ?ddy2,?ddy1,?ddy2)))) AS ?ddym)
BIND(IF(BOUND(?dfy1) && !BOUND(?dfy2),?dfy1,IF(!BOUND(?dfy1) && BOUND(?dfy2),?dfy2,IF(!BOUND(?dfy1) && !BOUND(?dfy2),YEAR(NOW()),IF(?dfy1 <= ?dfy2,?dfy1,?dfy2)))) AS ?dfym)
FILTER (?dir1 != ?dir2) .
FILTER (?ddym != ?dfym) .
FILTER (?ddy1 < ?dfy2 || ?ddy2 < ?dfy1 || (!BOUND(?ddy1) && !BOUND(?dfy1) && !BOUND(?ddy2) && !BOUND(?dfy2)) || (!BOUND(?ddy1) && BOUND(?dfy1) && !BOUND(?ddy2) && BOUND(?dfy2)) || (BOUND(?ddy1) && !BOUND(?dfy1) && BOUND(?ddy2) && !BOUND(?dfy2)) || (!BOUND(?ddy1) && !BOUND(?dfy1) && BOUND(?ddy2) && !BOUND(?dfy2)) || (BOUND(?ddy1) && !BOUND(?dfy1) && !BOUND(?ddy2) && !BOUND(?dfy2)) || (!BOUND(?ddy1) && !BOUND(?dfy1) && !BOUND(?ddy2) && BOUND(?dfy2)) || (!BOUND(?ddy1) && BOUND(?dfy1) && !BOUND(?ddy2) && !BOUND(?dfy2)) || (!BOUND(?ddy1) && !BOUND(?dfy1) && BOUND(?ddy2) && BOUND(?dfy2)) || (BOUND(?ddy1) && BOUND(?dfy1) && !BOUND(?ddy2) && !BOUND(?dfy2))) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" . }
} ORDER BY ?ddym
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v12("?dd1")
v16("?dd2")
v13("?ddy1"):::projected
v17("?ddy2"):::projected
v18("?ddym"):::projected
v13("?df1")
v17("?df2")
v14("?dfy1"):::projected
v18("?dfy2"):::projected
v18("?dfym"):::projected
v7("?dir1")
v8("?dir2")
v9("?route")
v10("?s1")
v14("?s2")
v11("?ville1"):::projected
v15("?ville2"):::projected
c7(["bd:serviceParam"]):::iri
c9(["fr"]):::literal
f0[["(?ddy1 < ?dfy2 || (?ddy2 < ?dfy1 || (not bound(?ddy1)not bound(?dfy1)not bound(?ddy2)not bound(?dfy2) || (not bound(?ddy1)bound(?dfy1)not bound(?ddy2)bound(?dfy2) || (bound(?ddy1)not bound(?dfy1)bound(?ddy2)not bound(?dfy2) || (not bound(?ddy1)not bound(?dfy1)bound(?ddy2)not bound(?dfy2) || (bound(?ddy1)not bound(?dfy1)not bound(?ddy2)not bound(?dfy2) || (not bound(?ddy1)not bound(?dfy1)not bound(?ddy2)bound(?dfy2) || (not bound(?ddy1)bound(?dfy1)not bound(?ddy2)not bound(?dfy2) || (not bound(?ddy1)not bound(?dfy1)bound(?ddy2)bound(?dfy2) || bound(?ddy1)bound(?dfy1)not bound(?ddy2)not bound(?dfy2)))))))))))"]]
f0 --> v13
f0 --> v18
f0 --> v17
f0 --> v14
f1[["?ddym != ?dfym"]]
f1 --> v18
f1 --> v18
f2[["?dir1 != ?dir2"]]
f2 --> v7
f2 --> v8
bind3[/VALUES ?route/]
bind3-->v9
bind30(["wd:Q1624187"])
bind30 --> bind3
v9 --"p:P609"--> v10
v10 --"p:statement/P609"--> v11
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v10 -."p:qualifier/P560".-> v7
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v10 -."p:qualifier/P580".-> v12
end
bind4[/"year-from-dateTime(?dd1)"/]
v12 --o bind4
bind4 --as--o v13
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v10 -."p:qualifier/P582".-> v13
end
bind5[/"year-from-dateTime(?df1)"/]
v13 --o bind5
bind5 --as--o v14
v9 --"p:P609"--> v14
v14 --"p:statement/P609"--> v15
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v14 -."p:qualifier/P560".-> v8
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v14 -."p:qualifier/P580".-> v16
end
bind6[/"year-from-dateTime(?dd2)"/]
v16 --o bind6
bind6 --as--o v17
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v14 -."p:qualifier/P582".-> v17
end
bind7[/"year-from-dateTime(?df2)"/]
v17 --o bind7
bind7 --as--o v18
bind8[/"if(bound(?ddy1)not bound(?ddy2),?ddy1,if(not bound(?ddy1)bound(?ddy2),?ddy2,if(not bound(?ddy1)not bound(?ddy2),'0^^xsd:integer',if(?ddy1 >= ?ddy2,?ddy1,?ddy2))))"/]
v13 --o bind8
v17 --o bind8
bind8 --as--o v18
bind9[/"if(bound(?dfy1)not bound(?dfy2),?dfy1,if(not bound(?dfy1)bound(?dfy2),?dfy2,if(not bound(?dfy1)not bound(?dfy2),year-from-dateTime(NOW()),if(?dfy1 <= ?dfy2,?dfy1,?dfy2))))"/]
v14 --o bind9
v18 --o bind9
bind9 --as--o v18
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end