query-bd0007b9bd8f1a81929238ccbd099cc0
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?codice_aeroportuale_IATA ?Paese ?PaeseLabel ?coordinate_geografiche ?continent ?continentLabel
WHERE
{
{
SELECT ?item ?codice_aeroportuale_IATA (SAMPLE(?coord) AS ?coordinate_geografiche) ?Paese
WHERE
{
?item wdt:P238 ?codice_aeroportuale_IATA.
OPTIONAL { ?item wdt:P625 ?coord. }
OPTIONAL { ?item wdt:P17 ?Paese. }
}
GROUP BY ?item ?codice_aeroportuale_IATA ?Paese
LIMIT 10
}
OPTIONAL
{
# Find continent for the country
?Paese wdt:P30 ?continent_country.
}
OPTIONAL
{
# Find continent for the largest subunit in the country
?item wdt:P131+ ?subunit.
?subunit wdt:P131 ?Paese.
FILTER(?subunit != ?Paese)
?subunit wdt:P30 ?continent_subunit.
}
# Use continent for subunit if present, otherwise for country
BIND(COALESCE(?continent_subunit,?continent_country) AS ?continent)
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;
v2("?Paese"):::projected
v4("?codice_aeroportuale_IATA"):::projected
v9("?continent"):::projected
v7("?continent_country")
v8("?continent_subunit")
v5("?coord")
v6("?coordinate_geografiche"):::projected
v3("?item"):::projected
v1("?subunit")
c7(["bd:serviceParam"]):::iri
c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v3 --"wdt:P238"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P625".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P17".-> v2
end
bind1[/"sample(?coord)"/]
v5 --o bind1
bind1 --as--o v6
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P30".-> v7
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P131".-> v1
v1 --"wdt:P131"--> v2
v1 --"wdt:P30"--> v8
end
bind2[/"?continent_subunit?continent_country"/]
v8 --o bind2
v7 --o bind2
bind2 --as--o v9
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end