query-48f77dd1450487394d162851735695d5
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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title:Buildings that are not a part of a bounding box covering the mainland of a country
#defaultView:Map
SELECT ?item ?itemLabel ?coords WHERE { { SELECT * WHERE {
VALUES ?country { wd:Q38 } # change your country here, check that the bounding box only covers its mainland
?country p:P1332 [ a wikibase:BestRank; psv:P1332 [ wikibase:geoLatitude ?nmp_lat ] ].
?country p:P1333 [ a wikibase:BestRank; psv:P1333 [ wikibase:geoLatitude ?smp_lat ] ].
?country p:P1334 [ a wikibase:BestRank; psv:P1334 [ wikibase:geoLongitude ?emp_long ] ].
?country p:P1335 [ a wikibase:BestRank; psv:P1335 [ wikibase:geoLongitude ?wmp_long ] ].
} } { SELECT distinct ?item ?coords
WHERE {
{ SELECT * WHERE {
VALUES ?country { wd:Q38 } # change your country here, check that the bounding box only covers its mainland
?country p:P1332 [ a wikibase:BestRank; psv:P1332 [ wikibase:geoLatitude ?nmp_lat ] ].
?country p:P1333 [ a wikibase:BestRank; psv:P1333 [ wikibase:geoLatitude ?smp_lat ] ].
?country p:P1334 [ a wikibase:BestRank; psv:P1334 [ wikibase:geoLongitude ?emp_long ] ].
?country p:P1335 [ a wikibase:BestRank; psv:P1335 [ wikibase:geoLongitude ?wmp_long ] ].
} } ?item wdt:P17 ?country;
wdt:P31/wdt:P279* wd:Q811979#architectural thing
;wdt:P625 ?coords;#its coordinates
p:P625 [ a wikibase:BestRank; psv:P625 ?coord_vn ] .
?coord_vn wikibase:geoLatitude ?lat.
?coord_vn wikibase:geoLongitude ?long.
FILTER(?lat > ?nmp_lat || ?lat < ?smp_lat || ?long > ?emp_long || ?long < ?wmp_long)
}
LIMIT 10000#change values here, small value if big country eg 250, bigger value if medium country, huge value if very small country
}
# Try to remove things here to ensure it runs after named subquery b
FILTER NOT EXISTS { ?item wdt:P17 ?country2. FILTER(?country2 != ?country ) }
MINUS { ?item wdt:P5816 wd:Q19860854. } MINUS { ?item (wdt:P576|wdt:P3999) ?dispar. }#on ne veut pas les disparus
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .} }
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v11("?coord_vn")
v10("?coords"):::projected
v10("?country")
v1("?country2")
v12("?dispar")
v6("?emp_long")
v3("?item"):::projected
v8("?lat")
v9("?long")
v4("?nmp_lat")
v5("?smp_lat")
v7("?wmp_long")
a1((" "))
a2((" "))
a3((" "))
a4((" "))
a5((" "))
a6((" "))
a7((" "))
a8((" "))
a9((" "))
a10((" "))
a11((" "))
a12((" "))
a13((" "))
a14((" "))
a15((" "))
a16((" "))
a17((" "))
a18((" "))
c25(["bd:serviceParam"]):::iri
c21(["wd:Q19860854"]):::iri
c16(["wd:Q811979"]):::iri
c3(["wikibase:BestRank"]):::iri
c27(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0f0[["?country2 != ?country"]]
e0f0 --> e0v1
e0f0 --> e0v2
e0v3 --"p:direct/P17"--> e0v1
e0v2("?country"):::projected
e0v1("?country2"):::projected
e0v3("?item"):::projected
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> v10
f0 --> v3
f0 --> c1
f1[["?country2 != ?country"]]
f1 --> v1
f1 --> v10
v3 --"p:direct/P17"--> v1
bind2[/VALUES ?country/]
bind2-->v10
bind20(["wd:Q38"])
bind20 --> bind2
a1 --"a"--> c3
a2 --"wikibase:geoLatitude"--> v4
a1 --"p:statement/value/P1332"--> a2
v10 --"p:P1332"--> a1
a3 --"a"--> c3
a4 --"wikibase:geoLatitude"--> v5
a3 --"p:statement/value/P1333"--> a4
v10 --"p:P1333"--> a3
a5 --"a"--> c3
a6 --"wikibase:geoLongitude"--> v6
a5 --"p:statement/value/P1334"--> a6
v10 --"p:P1334"--> a5
a7 --"a"--> c3
a8 --"wikibase:geoLongitude"--> v7
a7 --"p:statement/value/P1335"--> a8
v10 --"p:P1335"--> a7
f3[["(?lat > ?nmp_lat || (?lat < ?smp_lat || (?long > ?emp_long || ?long < ?wmp_long)))"]]
f3 --> v8
f3 --> v4
f3 --> v5
f3 --> v9
f3 --> v6
f3 --> v7
bind4[/VALUES ?country/]
bind4-->v10
bind40(["wd:Q38"])
bind40 --> bind4
a9 --"a"--> c3
a10 --"wikibase:geoLatitude"--> v4
a9 --"p:statement/value/P1332"--> a10
v10 --"p:P1332"--> a9
a11 --"a"--> c3
a12 --"wikibase:geoLatitude"--> v5
a11 --"p:statement/value/P1333"--> a12
v10 --"p:P1333"--> a11
a13 --"a"--> c3
a14 --"wikibase:geoLongitude"--> v6
a13 --"p:statement/value/P1334"--> a14
v10 --"p:P1334"--> a13
a15 --"a"--> c3
a16 --"wikibase:geoLongitude"--> v7
a15 --"p:statement/value/P1335"--> a16
v10 --"p:P1335"--> a15
v3 --"p:direct/P17"--> v10
v3 --"p:direct/P31"--> a17
a17 --"p:direct/P279"--> c16
v3 --"p:direct/P625"--> v10
a18 --"a"--> c3
a18 --"p:statement/value/P625"--> v11
v3 --"p:P625"--> a18
v11 --"wikibase:geoLatitude"--> v8
v11 --"wikibase:geoLongitude"--> v9
subgraph minus5["MINUS"]
style minus5 stroke-width:6px,fill:pink,stroke:red;
v3 --"p:direct/P5816"--> c21
end
subgraph minus6["MINUS"]
style minus6 stroke-width:6px,fill:pink,stroke:red;
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v3 --"p:direct/P3999"--> v12
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v3 --"p:direct/P576"--> v12
end
union0r <== or ==> union0l
end
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c25 --"wikibase:language"--> c27
end