query-5eb945a60c5d89feacaacd72a15bb8a7

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?place ?placeLabel ?distance WHERE {
  {
    SELECT ?item ?coord {
      BIND( (19 - 12) * RAND() + 12 AS ?rand ) .
      ?item wdt:P3003 []; p:P625 [ ps:P625 ?coord; psv:P625/wikibase:geoLongitude ?long ] .
      FILTER ( ABS( ?long - ?rand ) < 1 ) . # feel free to play with this...
      MINUS { ?item ^schema:about/schema:IsPartOf <https://cs.wikipedia.org/> } .
    } LIMIT 50 # or this
  } .
  SERVICE wikibase:around {
    ?place wdt:P625 ?location .
    bd:serviceParam wikibase:center ?coord .
    bd:serviceParam wikibase:radius "1" . # or this value
    bd:serviceParam wikibase:distance ?distance .
  } .
  FILTER ( ?item != ?place ) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "cs" } .
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?coord") v7("?distance"):::projected v1("?item"):::projected v6("?location") v3("?long") v2("?place"):::projected v5("?rand") a1((" ")) a2((" ")) a3((" ")) a4((" ")) c9([https://cs.wikipedia.org/]):::iri c19(["cs"]):::literal c15(["1"]):::literal c12(["bd:serviceParam"]):::iri f0[["?item != ?place"]] f0 --> v1 f0 --> v2 f1[["numeric-abs(?long - ?rand) < '1^^xsd:integer'"]] f1 --> v3 f1 --> v5 bind2[/"'19^^xsd:integer' - '12^^xsd:integer' * RAND() + '12^^xsd:integer'"/] bind2 --as--o v5 v1 --"p:direct/P3003"--> a1 a2 --"p:statement/P625"--> v5 a2 --"p:statement/value/P625"--> a3 a3 --"wikibase:geoLongitude"--> v3 v1 --"p:P625"--> a2 subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; a4 --"schema:about"--> v1 a4 --"schema:IsPartOf"--> c9 end subgraph s1["http://wikiba.se/ontology#around"] style s1 stroke-width:4px; v2 --"p:direct/P625"--> v6 c12 --"wikibase:center"--> v5 c12 --"wikibase:radius"--> c15 c12 --"wikibase:distance"--> v7 end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c12 --"wikibase:language"--> c19 end