query-c8eccf2d7c3007fd4f85b9d425ab9ca0
(27) Map of death places layered by manner or cause of death: Water Margin charactersNo.27 (2019.11.14T0246 created)
Use at
- https://query.wikidata.org/sparql
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#>
# show Water Margin characters' death places on map
# with manner/cause of death as layer
#defaultView:Map{"layer":"?deathLabel"}
SELECT DISTINCT ?person ?nick_name ?personLabel ?image ?personDescription ?groupLabel ?typeLabel ?death ?deathLabel ?place ?placeLabel ?coord
WHERE {
# define ?person as one that is present in work (P1441) Water Margin (Q70827), and
?person wdt:P1441 wd:Q70827;
# is instance of (P31) or any subclass of (P279) fictional character (Q95074)
wdt:P31/wdt:P279* wd:Q95074.
# optional: show ?person's death place (P20) as ?place
OPTIONAL {?person wdt:P20 ?place
# optional: show ?place's coordinate location (P625) as ?coord
OPTIONAL {?place wdt:P625 ?coord} }
# optional: show ?person's manner of death (P1196) or cause of death (wdt:P509) as ?death
OPTIONAL {?person (wdt:P1196|wdt:P509) ?death
# To avoid showing any other relation
# define ?relation as only manner of death (P1196) or cause of death (P509)
VALUES ?relation {wdt:P1196 wdt:P509}
# ?relation is from ?person to ?death
?person ?relation ?death.
# show ?relation as ?type in table
### Note: The reason why ?relation is not shown as edgeLabel in graph is because in addition to ?person and ?death,
### a third variable, ?place, also shows itself (with link to item), not just its label, thus appearing in graph, and
### edgeLabel works correctly when there are only two variables.
### Three variables (?person, ?death, ?place) cause errors on edgeLabel, although may still work well for edge (as in this query).
### The edge connects two values that has an item link (vertex), from the one in the leftest vertical column in the table to any other one in the same horizontal row.
### Make the order of columns correct, and make right decision on
### whether a variable should show itself (with link to item) or just show its label,
### so that the edge can work correctly.
?type wikibase:directClaim ?relation;
a wikibase:Property}
# show ?person's nick name (P1449) as ?nick_name
OPTIONAL {?person wdt:P1449 ?nick_name}
# optional: show ?person's member_of (P463) as ?group
OPTIONAL {?person wdt:P463 ?group}
# optional: show ?person's image (P18) as ?image
OPTIONAL {?person wdt:P18 ?image}
# show label in simplified Chinese (zh-hans) as default, and English when no default label exists
SERVICE wikibase:label {bd:serviceParam wikibase:language "zh-hans,en".}
}
# order layer by ?deathLabel
order by ?deathLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?coord"):::projected
v5("?death"):::projected
v1("?deathLabel"):::projected
v9("?group")
v10("?image"):::projected
v8("?nick_name"):::projected
v2("?person"):::projected
v3("?place"):::projected
v6("?relation")
v7("?type")
a1((" "))
c12(["wikibase:Property"]):::iri
c19(["zh-hans,en"]):::literal
c5(["wd:Q95074"]):::iri
c2(["wd:Q70827"]):::iri
c17(["bd:serviceParam"]):::iri
v2 --"wdt:P1441"--> c2
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P20".-> v3
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P625".-> v4
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;
v2 -."wdt:P509".-> v5
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P1196"--> v5
end
union0r <== or ==> union0l
end
bind0[/VALUES ?relation/]
bind0-->v6
bind00(["wdt:P1196"])
bind00 --> bind0
bind01(["wdt:P509"])
bind01 --> bind0
v2 -->v6--> v5
v7 --"wikibase:directClaim"--> v6
v7 --"a"--> c12
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P1449".-> v8
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P463".-> v9
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P18".-> v10
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c17 --"wikibase:language"--> c19
end