query-0e70669a78249bb6af2d87a8b540a878

rq turtle/ttl

(1) Map of residence citiesNo.1 (2020.10.01T1846 created)

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#>
# map of residence cities
# also viewable as table, timeline, and image grid
#defaultView:Map
SELECT DISTINCT ?residence ?residenceLabel ?countryLabel ?image ?coord ?start ?end
WHERE {
  # define "?residence, ?starttime, ?endtime" as:
  VALUES (?residence ?starttime ?endtime)
         # Nanchang (Q171943), 4 February 1975 (Q69292163), 1979 (Q2484)
         {(wd:Q171943 wd:Q69292163 wd:Q2484)
          # Zhengzhou (Q30340), 1979 (Q2484), September 1993 (Q3478983)
          (wd:Q30340 wd:Q2484 wd:Q3478983)
          # Beijing (Q956), September 1993 (Q3478983), September 1999 (Q1150759)
          (wd:Q956 wd:Q3478983 wd:Q1150759)
          # Aix-en-Provence (Q47465), September 1999 (Q1150759), March 2000 (Q1616972)
          (wd:Q47465 wd:Q1150759 wd:Q1616972)
          # Beijing (Q956), March 2000 (Q1616972), 24 August 2001 (Q69304006)
          (wd:Q956 wd:Q1616972 wd:Q69304006)
          # New Haven (Q49145), 24 August 2001 (Q69304006), 24 February 2006 (Q22663364)
          (wd:Q49145 wd:Q69304006 wd:Q22663364)
          # Beijing (Q956), 1 March 2006 (Q22663369), 31 August 2023 (Q69306908)
          (wd:Q956 wd:Q22663369 wd:Q69306908)
          # Haikou, Hainan (Q189823), 18 September 2023 (Q69306926), "today"
          (wd:Q189823 wd:Q69306926 "today")}
  # optional: show ?residence's country (P17) as ?country
  OPTIONAL {?residence wdt:P17 ?country}
  # optional: show ?residence's image (P18) as ?image
  OPTIONAL {?residence wdt:P18 ?image}
  # optional: show ?residence's coordinate location (P625) as ?coord
  OPTIONAL {?residence wdt:P625 ?coord}
  # optional: show ?starttime's point in time (P585) as ?start
  OPTIONAL {?starttime wdt:P585 ?start}
   # optional: if ?endtime has "point in time" (P585), the value is ?x
  OPTIONAL {?endtime wdt:P585 ?x}
  # use IF to define ?end as:
  # if ?endtime is "today", today (NOW); otherwise (?endtime has "point in time" (P585)), ?x
  ### Note: If ?endtime is not "today", and does not have "point in time" (P585), ?end will have no value.
  BIND (IF(?endtime="today", NOW(), ?x) AS ?end)
  # show label in auto language as default, and English when no default label exists
  SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?coord"):::projected v4("?country") v9("?end"):::projected v3("?endtime") v5("?image"):::projected v1("?residence"):::projected v7("?start"):::projected v2("?starttime") v8("?x") c6(["bd:serviceParam"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal bind0[/VALUES ?endtime ?residence ?starttime/] bind0-->v1 bind0-->v2 bind0-->v3 bind00(["wd:Q171943"]) bind00 --> bind0 bind01(["wd:Q69292163"]) bind01 --> bind0 bind02(["wd:Q2484"]) bind02 --> bind0 bind03(["wd:Q30340"]) bind03 --> bind0 bind04(["wd:Q2484"]) bind04 --> bind0 bind05(["wd:Q3478983"]) bind05 --> bind0 bind06(["wd:Q956"]) bind06 --> bind0 bind07(["wd:Q3478983"]) bind07 --> bind0 bind08(["wd:Q1150759"]) bind08 --> bind0 bind09(["wd:Q47465"]) bind09 --> bind0 bind010(["wd:Q1150759"]) bind010 --> bind0 bind011(["wd:Q1616972"]) bind011 --> bind0 bind012(["wd:Q956"]) bind012 --> bind0 bind013(["wd:Q1616972"]) bind013 --> bind0 bind014(["wd:Q69304006"]) bind014 --> bind0 bind015(["wd:Q49145"]) bind015 --> bind0 bind016(["wd:Q69304006"]) bind016 --> bind0 bind017(["wd:Q22663364"]) bind017 --> bind0 bind018(["wd:Q956"]) bind018 --> bind0 bind019(["wd:Q22663369"]) bind019 --> bind0 bind020(["wd:Q69306908"]) bind020 --> bind0 bind021(["wd:Q189823"]) bind021 --> bind0 bind022(["wd:Q69306926"]) bind022 --> bind0 bind023(["today"]) bind023 --> bind0 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P17".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P18".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P625".-> v6 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P585".-> v7 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P585".-> v8 end bind1[/"if(?endtime = 'today',NOW(),?x)"/] v3 --o bind1 v8 --o bind1 bind1 --as--o v9 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end