query-4392b7889ea7814ea9724c7cac9dd786

rq turtle/ttl

Propertiescoordinate location (P625)instance of (P31)located in the administrative territorial entity (P131)country (P17)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
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 ?place ?dist ?placeLabel ?placeDescription ?istEinLabel ?liegtInLabel
WHERE
{
  wd:Q494631 wdt:P625 ?loc . # Objekt mit Geokoordinaten
  #BIND ( "Point(-79.71 15.8)"^^geo:wktLiteral AS ?loc ) . # Beliebige Position. Erst Ost/West. keine Blanks vor oder nach den Koordinaten!
  SERVICE wikibase:around {
      ?place wdt:P625 ?location .
      bd:serviceParam wikibase:center ?loc .
      bd:serviceParam wikibase:radius "20" .
  }
  OPTIONAL { ?place wdt:P31 ?istEin }
  OPTIONAL { ?place wdt:P131 ?liegtIn }
  OPTIONAL { ?place wdt:P17 ?staat }
  FILTER ( ! (BOUND(?istEin ) && BOUND(?staat )) ) # nur wenn kein P31 oder P17 angegeben
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de" }
  BIND(geof:distance(?loc, ?location) as ?dist)
} ORDER BY ?dist
LIMIT 50

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?dist"):::projected v2("?istEin") v7("?liegtIn") v4("?loc") v6("?location") v5("?place"):::projected v3("?staat") c13(["de"]):::literal c4(["bd:serviceParam"]):::iri c1(["wd:Q494631"]):::iri c7(["20"]):::literal f0[["not bound(?istEin)bound(?staat)"]] f0 --> v2 f0 --> v3 c1 --"wdt:P625"--> v4 subgraph s1["http://wikiba.se/ontology#around"] style s1 stroke-width:4px; v5 --"wdt:P625"--> v6 c4 --"wikibase:center"--> v4 c4 --"wikibase:radius"--> c7 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P31".-> v2 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P131".-> v7 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P17".-> v3 end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c4 --"wikibase:language"--> c13 end bind1[/"http://www.opengis.net/def/function/geosparql/distance(?loc,?location)"/] v4 --o bind1 v6 --o bind1 bind1 --as--o v8