query-8ac22fac8412eba042421bcb12220d85

rq turtle/ttl

Content

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map
SELECT
  ?coordinates
  ?university
  ?universityLabel
  ?item
  ?itemLabel
  ?P856
{
   {
  SELECT
    ?item
    # TODO: Since we are using SAMPLE, which value would be taken
    # under consideration when, for example, a parent organization has
    # multiple coordinate locations?
    (SAMPLE(?coordinates) AS ?coordinates)
  {
     {
  SELECT DISTINCT ?item {
    ?item wdt:P31/wdt:P279* wd:Q115557431.
  }
}
    # Data from a parent organization
    OPTIONAL{?item wdt:P749+/wdt:P625 ?P749_plus_P625}.
    # Data from the item
    OPTIONAL{?item wdt:P625 ?P625}.
    OPTIONAL{?item wdt:P159/wdt:P625 ?P159_P625}.
    OPTIONAL{?item wdt:P131+/wdt:P625 ?P131_plus_P625}.

    BIND(COALESCE(IF(BOUND(?P625), ?P625, 1/0),
                  IF(BOUND(?P159_P625), ?P159_P625, 1/0),
                  IF(BOUND(?P131_plus_P625), ?P131_plus_P625, 1/0),
                  IF(BOUND(?P749_plus_P625), ?P749_plus_P625, 1/0))
         AS ?coordinates)
  }
  GROUP BY ?item
}
  OPTIONAL{ {
  SELECT DISTINCT
    ?item
    ?university
  {
    ?item wdt:P749+ ?university.
    ?university wdt:P31/wdt:P279* wd:Q3918.
  }
}}.
  OPTIONAL{?item wdt:P856 ?P856}.
  SERVICE wikibase:label {bd:serviceParam wikibase:language "en"}.
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?P131_plus_P625") v4("?P159_P625") v3("?P625") v2("?P749_plus_P625") v8("?P856"):::projected v7("?coordinates"):::projected v1("?item"):::projected v7("?university"):::projected a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) c13(["en"]):::literal c8(["wd:Q3918"]):::iri c11(["bd:serviceParam"]):::iri c3(["wd:Q115557431"]):::iri v1 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P749".-> a2 a2 --"wdt:P625"--> v2 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P625".-> v3 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P159".-> a3 a3 --"wdt:P625"--> v4 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P131".-> a4 a4 --"wdt:P625"--> v5 end bind0[/"if(bound(?P625),?P625,'1^^xsd:integer' / '0^^xsd:integer')if(bound(?P159_P625),?P159_P625,'1^^xsd:integer' / '0^^xsd:integer')if(bound(?P131_plus_P625),?P131_plus_P625,'1^^xsd:integer' / '0^^xsd:integer')if(bound(?P749_plus_P625),?P749_plus_P625,'1^^xsd:integer' / '0^^xsd:integer')"/] v3 --o bind0 v4 --o bind0 v5 --o bind0 v2 --o bind0 bind0 --as--o v7 bind2[/"sample(?coordinates)"/] v7 --o bind2 bind2 --as--o v7 subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P749".-> v7 v7 --"wdt:P31"--> a5 a5 --"wdt:P279"--> c8 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P856".-> v8 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end