query-713bad91fa500770b2390ae9e65611ad

rq turtle/ttl

Grenzlage Gemeinde Molln

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"hide":"?rgb"}
#title: Border check on municipality level
SELECT ?item ?itemLabel ?itemDescription ?coord ?anz ?rgb ?layer WHERE {
   {
  SELECT DISTINCT ?item (COUNT(DISTINCT ?unit) as ?anz) WHERE {

    ?item wdt:P17 wd:Q40 . #16
    ?item wdt:P131*/wdt:P279* wd:Q684847.
    ?item wdt:P31 ?isA .
    #VALUES ?isA {wd:Q8502 wd:Q16887036 wd:Q2231510 wd:Q10862618 wd:Q35666 wd:Q23397 wd:Q133056} # distinct border related types
    ?item wdt:P625 [] .
    ?item wdt:P131 ?unit .
  }
  GROUP BY ?item
}.
  ?item wdt:P31 [] .
  ?item p:P625 ?coordStatement .
  ?coordStatement ps:P625 ?coord .
  BIND(IF(?anz = 1, '60ff60', 'ff0000') AS ?rgb) .
  BIND(IF(?anz = 1, 'inside (single P17)', 'border (multiple P17)') AS ?layer) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language '[AUTO_LANGUAGE,de,en]' }
} GROUP BY ?item ?itemLabel ?itemDescription ?coord ?anz ?rgb ?layer # ORDER BY ASC(?item)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?anz"):::projected v6("?coord"):::projected v5("?coordStatement") v2("?isA") v1("?item"):::projected v8("?layer"):::projected v7("?rgb"):::projected v3("?unit") a2((" ")) a3((" ")) a1((" ")) c2(["wd:Q40"]):::iri c5(["wd:Q684847"]):::iri c11(["bd:serviceParam"]):::iri c13(["#91;AUTO_LANGUAGE,de,en#93;"]):::literal v1 --"p:direct/P17"--> c2 v1 --"p:direct/P131"--> a1 a1 --"p:direct/P279"--> c5 v1 --"p:direct/P31"--> v2 v1 --"p:direct/P625"--> a2 v1 --"p:direct/P131"--> v3 bind1[/"count(?unit)"/] v3 --o bind1 bind1 --as--o v4 v1 --"p:direct/P31"--> a3 v1 --"p:P625"--> v5 v5 --"p:statement/P625"--> v6 bind2[/"if(?anz = '1^^xsd:integer','60ff60','ff0000')"/] v4 --o bind2 bind2 --as--o v7 bind3[/"if(?anz = '1^^xsd:integer','inside (single P17)','border (multiple P17)')"/] v4 --o bind3 bind3 --as--o v8 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end