query-ed5b38764dc8bfe3a316899d08a672ac

rq turtle/ttl

مجمعة حسب نطاق المسافة، مرمزة بالألوان grouped by dist range, color-coded grouped by dist range, color-coded seskupené podle vzdálenosti, barevně označené grouped by dist range, color-coded gruppiert in Abstandsbereiche, farbkodiert grouped by dist range, color-coded grouped by dist range, color-coded grouped by dist range, color-coded grouped by dist range, color-coded grouped by dist range, color-coded groupées par niveau de distance, la couleur dépendant de la distance grouped by dist range, color-coded grouped by dist range, color-coded grouped by dist range, color-coded raggruppati per distanza, codificati per colore grouped by dist range, color-coded grouped by dist range, color-coded grouped by dist range, color-coded grouped by dist range, color-coded grouped by dist range, color-coded gegroepeerd op afstand, kleurgecodeerd grouped by dist range, color-coded grouped by dist range, color-coded grouped by dist range, color-coded grouped by dist range, color-coded grouped by dist range, color-coded grupperade efter distans, färgade grouped by dist range, color-coded grouped by dist range, color-coded згруповані за діапазонами відстаней, позначені кольором grouped by dist range, color-coded grouped by dist range, color-coded

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:BarChart
PREFIX var_muntype: <http://www.wikidata.org/entity/Q15284>
PREFIX var_area: <http://www.wikidata.org/entity/Q6308>
SELECT ?from ?to ?distGrp WHERE {
  {
    SELECT ?from ?to ?distNum ?mun ?mun2 WHERE {
      { SELECT ?mun (SAMPLE(?loc) AS ?loc)
        WHERE { ?mun wdt:P31/wdt:P279* var_muntype:;
                     wdt:P131 var_area:;
                     wdt:P625 ?loc. }
        GROUP BY ?mun
      }
      OPTIONAL {
        { SELECT (?mun AS ?mun2) (SAMPLE(?loc) AS ?loc2)
          WHERE { ?mun wdt:P31/wdt:P279* var_muntype:;
                       wdt:P131 var_area:;
                       wdt:P625 ?loc. }
          GROUP BY ?mun
        }
      }
      BIND(geof:distance(?loc, ?loc2) AS ?distNum).

      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en".
        ?mun rdfs:label ?from.
        ?mun2 rdfs:label ?to.
      }
    }
  }
  FILTER(CONCAT(?from,STR(?mun)) <= CONCAT(?to,STR(?mun2))).
  #BIND(IF(STR(?from) < STR(?to),CONCAT(?from," <--> ",?to),
  # CONCAT(?to," <--> ",?from)) AS ?distLabel).

  BIND(COALESCE(
    IF(?distNum >= 40, "40 - .. km", 1/0),
    IF(?distNum >= 30, "30 - 40 km", 1/0),
    IF(?distNum >= 20, "20 - 30 km", 1/0),
    IF(?distNum >= 10, "10 - 20 km", 1/0),
    IF(?distNum >= 5, "05 - 10 km", 1/0),
    IF(?distNum >= 1, "01 - 05 km", "00 - 01 km")) AS ?distGrp).
}
ORDER BY ?from ?distGrp

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?distGrp"):::projected v8("?distNum") v1("?from"):::projected v7("?loc") v7("?loc2") v3("?mun") v7("?mun2") v4("?to"):::projected a1((" ")) a2((" ")) c5([http://www.wikidata.org/entity/Q6308]):::iri c8(["bd:serviceParam"]):::iri c3([http://www.wikidata.org/entity/Q15284]):::iri c10(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal f0[["concat(?from,str(?mun)) <= concat(?to,str(?mun2))"]] f0 --> v1 f0 --> v3 f0 --> v4 f0 --> v7 v3 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 v3 --"wdt:P131"--> c5 v3 --"wdt:P625"--> v7 bind2[/"sample(?loc)"/] v7 --o bind2 bind2 --as--o v7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P31".-> a2 a2 --"wdt:P279"--> c3 v3 --"wdt:P131"--> c5 v3 --"wdt:P625"--> v7 bind4[/"?mun"/] v3 --o bind4 bind4 --as--o v7 bind5[/"sample(?loc)"/] v7 --o bind5 bind5 --as--o v7 end bind6[/"http://www.opengis.net/def/function/geosparql/distance(?loc,?loc2)"/] v7 --o bind6 v7 --o bind6 bind6 --as--o v8 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 v3 --"rdfs:label"--> v1 v7 --"rdfs:label"--> v4 end bind7[/"if(?distNum >= '40^^xsd:integer','40 - .. km','1^^xsd:integer' / '0^^xsd:integer')if(?distNum >= '30^^xsd:integer','30 - 40 km','1^^xsd:integer' / '0^^xsd:integer')if(?distNum >= '20^^xsd:integer','20 - 30 km','1^^xsd:integer' / '0^^xsd:integer')if(?distNum >= '10^^xsd:integer','10 - 20 km','1^^xsd:integer' / '0^^xsd:integer')if(?distNum >= '5^^xsd:integer','05 - 10 km','1^^xsd:integer' / '0^^xsd:integer')if(?distNum >= '1^^xsd:integer','01 - 05 km','00 - 01 km')"/] v8 --o bind7 bind7 --as--o v9