query-a3e211274ef8a5f874f20b240ca8f24a

rq turtle/ttl

Fars de les Balears

PREFIX ofn: http://www.ontotext.com/sparql/functions/

SELECT DISTINCT ?item ?municipiLabel ?illa ?illaLabel ?lat ?lon ?lat_illa ?lon_illa ?atan2 WHERE { ?item wdt:P17 wd:Q29. ?item wdt:P31/wdt:P279 wd:Q39715. ?item wdt:P131 ?municipi. ?municipi wdt:P31 wd:Q2074737. ?municipi wdt:P131 wd:Q5765. ?item wdt:P131 ?illa. ?illa wdt:P31 wd:Q23442. ?illa p:P625 ?coord_illa. ?coord_illa psv:P625 ?coord_illa_node . ?coord_illa_node wikibase:geoLatitude ?lat_illa . ?coord_illa_node wikibase:geoLongitude ?lon_illa . SERVICE wikibase:label { bd:serviceParam wikibase:language "ca" . } OPTIONAL{?item p:P625 ?coordinate . ?coordinate psv:P625 ?coordinate_node . ?coordinate_node wikibase:geoLatitude ?lat . ?coordinate_node wikibase:geoLongitude ?lon . #BIND (ofn:atan2(?lon - ?lon_illa, ?lat - ?lat_illa) AS ?atan2) } }

ORDER BY DESC(?atan2)

Use at

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 bd: <http://www.bigdata.com/rdf#>
#Fars de les Balears
#PREFIX ofn: <http://www.ontotext.com/sparql/functions/>
SELECT DISTINCT ?item ?municipiLabel ?illa ?illaLabel ?lat ?lon ?lat_illa ?lon_illa ?atan2
  WHERE {
    ?item wdt:P17 wd:Q29.
    ?item wdt:P31/wdt:P279* wd:Q39715.
    ?item wdt:P131* ?municipi.
    ?municipi wdt:P31 wd:Q2074737.
    ?municipi wdt:P131* wd:Q5765.
    ?item wdt:P131* ?illa.
    ?illa wdt:P31 wd:Q23442.
    ?illa p:P625 ?coord_illa.
          ?coord_illa psv:P625 ?coord_illa_node .
          ?coord_illa_node wikibase:geoLatitude ?lat_illa .
          ?coord_illa_node wikibase:geoLongitude ?lon_illa .
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "ca" .
        }
  OPTIONAL{?item p:P625 ?coordinate .
          ?coordinate psv:P625 ?coordinate_node .
          ?coordinate_node wikibase:geoLatitude ?lat .
          ?coordinate_node wikibase:geoLongitude ?lon .
           #BIND (ofn:atan2(?lon - ?lon_illa, ?lat - ?lat_illa) AS ?atan2)
          }
  }
#ORDER BY DESC(?atan2)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?coord_illa") v5("?coord_illa_node") v8("?coordinate") v9("?coordinate_node") v3("?illa"):::projected v1("?item"):::projected v10("?lat"):::projected v6("?lat_illa"):::projected v11("?lon"):::projected v7("?lon_illa"):::projected v2("?municipi") a1((" ")) c7(["wd:Q2074737"]):::iri c9(["wd:Q23442"]):::iri c2(["wd:Q29"]):::iri c15(["bd:serviceParam"]):::iri c5(["wd:Q39715"]):::iri c17(["ca"]):::literal c8(["wd:Q5765"]):::iri v1 --"p:direct/P17"--> c2 v1 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c5 v1 --"p:direct/P131"--> v2 v2 --"p:direct/P31"--> c7 v2 --"p:direct/P131"--> c8 v1 --"p:direct/P131"--> v3 v3 --"p:direct/P31"--> c9 v3 --"p:P625"--> v4 v4 --"p:statement/value/P625"--> v5 v5 --"wikibase:geoLatitude"--> v6 v5 --"wikibase:geoLongitude"--> v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c15 --"wikibase:language"--> c17 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:P625".-> v8 v8 --"p:statement/value/P625"--> v9 v9 --"wikibase:geoLatitude"--> v10 v9 --"wikibase:geoLongitude"--> v11 end