query-f2beec3db45ef57bbc5cfff87a0231d0
For those following along at home, the orthodox formulation would be BIND(strdt(concat("Point(",str(?long)," ",str(?lat),")") , geo:wktLiteral) as ?newcoord) as in
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 geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?coord ?lat ?long ?newcoord ?dist
WHERE
{
values ?item {wd:Q1199924}
?item wdt:P625 ?coord.
?item p:P625 ?statementnode.
?statementnode psv:P625 ?valuenode.
?valuenode wikibase:geoLatitude ?lat.
?valuenode wikibase:geoLongitude ?long.
BIND(strdt(concat("Point(",str(?long)," ",str(?lat),")") , geo:wktLiteral) as ?newcoord)
BIND(geof:distance("Point(0 0)"^^geo:wktLiteral, ?newcoord) as ?dist)
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("?coord"):::projected
v8("?dist"):::projected
v1("?item"):::projected
v5("?lat"):::projected
v6("?long"):::projected
v7("?newcoord"):::projected
v3("?statementnode")
v4("?valuenode")
c7(["bd:serviceParam"]):::iri
c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal
bind0[/VALUES ?item/]
bind0-->v1
bind00(["wd:Q1199924"])
bind00 --> bind0
v1 --"p:direct/P625"--> v2
v1 --"p:P625"--> v3
v3 --"p:statement/value/P625"--> v4
v4 --"wikibase:geoLatitude"--> v5
v4 --"wikibase:geoLongitude"--> v6
bind1[/"STRDT(concat('Point(',str(?long),' ',str(?lat),')'),'geo:wktLiteral')"/]
v6 --o bind1
v5 --o bind1
bind1 --as--o v7
bind2[/"http://www.opengis.net/def/function/geosparql/distance(sPoint(0 0)^^<http://www.opengis.net/ont/geosparql#wktLiteral>',?newcoord)"/]
v7 --o bind2
bind2 --as--o v8
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end