query-be8bb7a7dbd259ebe01c362b712162e3
Federated Query including variable from own Knowledge BaseDear everybody, I am workin on this query in which I would like to use positions stored on my own server. I would like to find out what is located around these positions using the power of wikidata. The query running on my server gives me the following result: ">POINT(8.3779196 49.0135909) [...]http://www.opengis.net/ont/geosparql#wktLiteral <literal datatype=" [...]
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#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX myNamespace:<http://myNamespace.com#>
SELECT ?place
WHERE {
{SERVICE <https://query.wikidata.org/sparql>
{ SERVICE wikibase:around {
?place wdt:P625 ?location .
bd:serviceParam wikibase:center ?wktLoc.
bd:serviceParam wikibase:radius "1" . }
{
SELECT (STRDT(CONCAT("POINT(",str(?lon)," ", str(?lat),")"),geo:wktLiteral) AS ?wktLoc)
WHERE {
?Report a myNamespace:Report .
?Report myNamespace:hasReportLocation ?location.
?location myNamespace:latitude ?lat.
?location myNamespace:longitude ?lon.
}
}
}
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?Report")
v5("?lat")
v2("?location")
v6("?lon")
v1("?place"):::projected
v7("?wktLoc")
c7(["1"]):::literal
c9([http://myNamespace.com#Report]):::iri
c4(["bd:serviceParam"]):::iri
subgraph s1["https://query.wikidata.org/sparql"]
style s1 stroke-width:4px;
subgraph s2["http://wikiba.se/ontology#around"]
style s2 stroke-width:4px;
v1 --"wdt:P625"--> v2
c4 --"wikibase:center"--> v7
c4 --"wikibase:radius"--> c7
end
v4 --"a"--> c9
v4 --http://myNamespace.com#hasReportLocation--> v2
v2 --http://myNamespace.com#latitude--> v5
v2 --http://myNamespace.com#longitude--> v6
bind0[/"STRDT(concat('POINT(',str(?lon),' ',str(?lat),')'),'geo:wktLiteral')"/]
v6 --o bind0
v5 --o bind0
bind0 --as--o v7
end