query-9a12e7a5f896033181188ee87d64e75d

rq turtle/ttl

Battles within a certain radius of a certain point without place and/or date SELECT DISTINCT ?item (SAMPLE(?itemLabel) AS ?itemLabel) (SAMPLE(?place) AS ?place) (SAMPLE(?placeLabel) AS ?placeLabel) (SAMPLE(?date) AS ?date) (SAMPLE(?coords) AS ?coords) WHERE { ?item wdt:P31 wd:Q178561 .

# wd:Q1133467 wdt:P625 ?MidPointCoords . # European Midpoint, including the european part of Russia. # wd:Q509320 wdt:P625 ?MidPointCoords . # EU Midpoint wd:Q1524 wdt:P625 ?MidPointCoords . # Athens # wd:Q994 wdt:P625 ?MidPointCoords . # Tbilissi # wd:Q3640 wdt:P625 ?MidPointCoords . # Ankara # DoneĀ : Paris, Isle of Man, Oslo, Finland, Madrid, Rome, EU Midpoint, Varsovie, Berlin, Yalta

SERVICE wikibase:around { ?item wdt:P625 ?coords . bd:serviceParam wikibase:center ?MidPointCoords . bd:serviceParam wikibase:radius "600" . }

OPTIONAL { ?item wdt:P276 ?place . OPTIONAL { ?place rdfs:label ?placeLabel . FILTER(LANG(?placeLabel) IN ("fr","en")) . } } OPTIONAL { ?item (wdt:P585|wdt:P580|wdt:P582) ?date . } FILTER(!BOUND(?place) || !BOUND(?date) ) .

OPTIONAL { ?item rdfs:label ?itemLabelFr . FILTER(LANG(?itemLabelFr) = "fr") . } OPTIONAL { ?item rdfs:label ?itemLabelEn . FILTER(LANG(?itemLabelEn) = "en") . } OPTIONAL { ?item rdfs:label ?itemLabelEs . FILTER(LANG(?itemLabelEs) = "es") . } OPTIONAL { ?item rdfs:label ?itemLabelCa . FILTER(LANG(?itemLabelCa) = "ca") . } OPTIONAL { ?item rdfs:label ?itemLabelDe . FILTER(LANG(?itemLabelDe) = "de") . } OPTIONAL { ?item rdfs:label ?itemLabelIt . FILTER(LANG(?itemLabelIt) = "it") . } BIND(COALESCE(?itemLabelFr, ?itemLabelEn, ?itemLabelEs, ?itemLabelCa, ?itemLabelDe, ?itemLabelIt) AS ?itemLabel) . } GROUP BY ?item ORDER BY ?coords

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Battles within a certain radius of a certain point without place and/or date
SELECT DISTINCT ?item 
(SAMPLE(?itemLabel) AS ?itemLabel)
(SAMPLE(?place) AS ?place) 
(SAMPLE(?placeLabel) AS ?placeLabel)
(SAMPLE(?date) AS ?date)
(SAMPLE(?coords) AS ?coords) WHERE {
  ?item wdt:P31 wd:Q178561 .

  # wd:Q1133467 wdt:P625 ?MidPointCoords . # European Midpoint, including the european part of Russia.
  # wd:Q509320 wdt:P625 ?MidPointCoords . # EU Midpoint
  wd:Q1524 wdt:P625 ?MidPointCoords . # Athens
  # wd:Q994 wdt:P625 ?MidPointCoords . # Tbilissi
  # wd:Q3640 wdt:P625 ?MidPointCoords . # Ankara
  # DoneĀ : Paris, Isle of Man, Oslo, Finland, Madrid, Rome, EU Midpoint, Varsovie, Berlin, Yalta


  SERVICE wikibase:around {
    ?item wdt:P625 ?coords . 
    bd:serviceParam wikibase:center ?MidPointCoords .
    bd:serviceParam wikibase:radius "600" . 
  }

  OPTIONAL {
    ?item wdt:P276 ?place . 
    OPTIONAL { 
      ?place rdfs:label ?placeLabel .
      FILTER(LANG(?placeLabel) IN ("fr","en")) .
    }
  }
  OPTIONAL { ?item (wdt:P585|wdt:P580|wdt:P582)  ?date . }
  FILTER(!BOUND(?place) || !BOUND(?date) ) .

  OPTIONAL { ?item rdfs:label ?itemLabelFr . FILTER(LANG(?itemLabelFr) = "fr") . }
  OPTIONAL { ?item rdfs:label ?itemLabelEn . FILTER(LANG(?itemLabelEn) = "en") . }
  OPTIONAL { ?item rdfs:label ?itemLabelEs . FILTER(LANG(?itemLabelEs) = "es") . }
  OPTIONAL { ?item rdfs:label ?itemLabelCa . FILTER(LANG(?itemLabelCa) = "ca") . }
  OPTIONAL { ?item rdfs:label ?itemLabelDe . FILTER(LANG(?itemLabelDe) = "de") . }
  OPTIONAL { ?item rdfs:label ?itemLabelIt . FILTER(LANG(?itemLabelIt) = "it") . }
  BIND(COALESCE(?itemLabelFr,
                ?itemLabelEn,
                ?itemLabelEs,
                ?itemLabelCa,
                ?itemLabelDe,
                ?itemLabelIt) AS ?itemLabel) .
} GROUP BY ?item ORDER BY ?coords

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v11("?MidPointCoords") v14("?coords"):::projected v14("?date"):::projected v10("?item"):::projected v14("?itemLabel"):::projected v4("?itemLabelCa") v3("?itemLabelDe") v6("?itemLabelEn") v5("?itemLabelEs") v9("?itemLabelFr") v2("?itemLabelIt") v14("?place"):::projected v14("?placeLabel"):::projected c9(["wd:Q1524"]):::iri c12(["bd:serviceParam"]):::iri c15(["600"]):::literal c8(["wd:Q178561"]):::iri f0[["(not bound(?place) || not bound(?date))"]] f0 --> v14 f0 --> v14 v10 --"wdt:P31"--> c8 c9 --"wdt:P625"--> v11 subgraph s1["http://wikiba.se/ontology#around"] style s1 stroke-width:4px; v10 --"wdt:P625"--> v14 c12 --"wikibase:center"--> v11 c12 --"wikibase:radius"--> c15 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v10 -."wdt:P276".-> v14 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v14 -."rdfs:label".-> v14 end end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v10 -."wdt:P582".-> v14 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v10 --"wdt:P580"--> v14 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v10 --"wdt:P585"--> v14 end union0r <== or ==> union0l end end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v10 -."rdfs:label".-> v9 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v10 -."rdfs:label".-> v6 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v10 -."rdfs:label".-> v5 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v10 -."rdfs:label".-> v4 end subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; v10 -."rdfs:label".-> v3 end subgraph optional8["(optional)"] style optional8 fill:#bbf,stroke-dasharray: 5 5; v10 -."rdfs:label".-> v2 end bind1[/"?itemLabelFr?itemLabelEn?itemLabelEs?itemLabelCa?itemLabelDe?itemLabelIt"/] v9 --o bind1 v6 --o bind1 v5 --o bind1 v4 --o bind1 v3 --o bind1 v2 --o bind1 bind1 --as--o v14 bind7[/"sample(?itemLabel)"/] v14 --o bind7 bind7 --as--o v14 bind8[/"sample(?place)"/] v14 --o bind8 bind8 --as--o v14 bind9[/"sample(?placeLabel)"/] v14 --o bind9 bind9 --as--o v14 bind10[/"sample(?date)"/] v14 --o bind10 bind10 --as--o v14 bind11[/"sample(?coords)"/] v14 --o bind11 bind11 --as--o v14