query-25c266f828343c93ba3f693f186fe29a
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 geo: <http://www.opengis.net/ont/geosparql#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?build ?buildLabel ?countryLabel ?placeLabel ?heritLabel ?location (COUNT(DISTINCT ?article) as ?count) WHERE
{
SERVICE wikibase:box {
?build wdt:P625 ?location .
bd:serviceParam wikibase:cornerWest "Point(-7.6 38.1)"^^geo:wktLiteral .
bd:serviceParam wikibase:cornerEast "Point(-4.5 40.75)"^^geo:wktLiteral .
} # bbox for Vettonia map
?build wdt:P31/wdt:P279* wd:Q41176 . # a building
?build wdt:P17 wd:Q29 . # must be in Spain
?build wdt:P1435 wd:Q23712 . # must be cultural heritage
OPTIONAL { ?build wdt:P17 ?country. }
OPTIONAL { ?build wdt:P131 ?place. }
OPTIONAL { ?build wdt:P1435 ?herit. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "es". }
OPTIONAL { ?article schema:name ?sitelink ;
schema:about ?build ;
schema:isPartOf ?part .
filter(contains(str(?part),"wikipedia.org"))
}
} group by ?build ?buildLabel ?countryLabel ?placeLabel ?heritLabel ?location
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?article"):::projected
v2("?build"):::projected
v9("?count")
v4("?country")
v6("?herit")
v3("?location"):::projected
v1("?part")
v5("?place")
v8("?sitelink")
a1((" "))
c11(["wd:Q41176"]):::iri
c15(["wd:Q23712"]):::iri
c19(["es"]):::literal
c4(["bd:serviceParam"]):::iri
c13(["wd:Q29"]):::iri
c6([sPoint(-7.6 38.1)^^<http://www.opengis.net/ont/geosparql#wktLiteral>"]):::literal
c8([sPoint(-4.5 40.75)^^<http://www.opengis.net/ont/geosparql#wktLiteral>"]):::literal
subgraph s1["http://wikiba.se/ontology#box"]
style s1 stroke-width:4px;
v2 --"wdt:P625"--> v3
c4 --"wikibase:cornerWest"--> c6
c4 --"wikibase:cornerEast"--> c8
end
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c11
v2 --"wdt:P17"--> c13
v2 --"wdt:P1435"--> c15
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P17".-> v4
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P131".-> v5
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P1435".-> v6
end
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c4 --"wikibase:language"--> c19
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v7 -."schema:name".-> v8
v7 --"schema:about"--> v2
v7 --"schema:isPartOf"--> v1
end
bind1[/"count(?article)"/]
v7 --o bind1
bind1 --as--o v9