query-b56a732a202c95dd3fddc529dcf4f8b8
TODO
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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title:Student-teacher/influencer relationships, lineage starting with Socrates, located by place of birth.
#defaultView:Map{"hide":["?line","?cds"],"layer":"?teacher_or_influencerLabel"}
SELECT (?student as ?writer) (concat('Writer: ',str(?studentLabel)) as ?writerLabel) (?teacher_or_infl as ?teacher_or_influencer) (concat('Teacher or Influencer: ',str(?teacher_or_inflLabel)) as ?teacher_or_influencerLabel) ?image ?location (concat('Writer place of birth: ',?spobLabel ) as ?locationLabel) ?line
{
SELECT distinct ?student ?studentLabel ?teacher_or_infl ?teacher_or_inflLabel ?cds ?image (?spob as ?location) ?spobLabel ?line {
{
VALUES ?person {wd:Q913}
?person wdt:P802* ?academyrelated .
?academyrelated wdt:P1066* ?student .
} union {
VALUES ?person {wd:Q913}
?person wdt:P802* ?academyrelated .
?academyrelated wdt:P737* ?student .
}
?student wdt:P1066|wdt:P737 ?teacher_or_infl .
?teacher_or_infl wdt:P19 ?tpob .
?teacher_or_infl wdt:P802 ?student .
?student wdt:P19 ?spob .
?spob wdt:P625 ?cds.
?tpob p:P625/psv:P625/wikibase:geoLatitude ?lat1 ; p:P625/psv:P625/wikibase:geoLongitude ?lon1 .
?spob p:P625/psv:P625/wikibase:geoLatitude ?lat2 ; p:P625/psv:P625/wikibase:geoLongitude ?lon2 .
BIND(CONCAT('LINESTRING(', STR(?lon1), ' ', STR(?lat1), ',', STR(?lon2), ' ', STR(?lat2), ')') AS ?str) . BIND(STRDT(?str, geo:wktLiteral) AS ?line) .
OPTIONAL { ?student wdt:P18 ?image .}
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;
v2("?academyrelated")
v7("?cds")
v14("?image"):::projected
v8("?lat1")
v10("?lat2")
v13("?line"):::projected
v15("?location"):::projected
v20("?locationLabel")
v9("?lon1")
v11("?lon2")
v4("?person")
v6("?spob")
v12("?str")
v3("?student"):::projected
v4("?teacher_or_infl"):::projected
v18("?teacher_or_influencer")
v19("?teacher_or_influencerLabel")
v5("?tpob")
v16("?writer")
v17("?writerLabel")
a1((" "))
a2((" "))
a3((" "))
a4((" "))
a5((" "))
a6((" "))
a7((" "))
a8((" "))
c14(["en"]):::literal
c12(["bd:serviceParam"]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
bind0[/VALUES ?person/]
bind0-->v4
bind00(["wd:Q913"])
bind00 --> bind0
v4 --"p:direct/P802"--> v2
v2 --"p:direct/P737"--> v3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
bind1[/VALUES ?person/]
bind1-->v4
bind10(["wd:Q913"])
bind10 --> bind1
v4 --"p:direct/P802"--> v2
v2 --"p:direct/P1066"--> v3
end
union0r <== or ==> union0l
end
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v3 --"p:direct/P737"--> v4
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v3 --"p:direct/P1066"--> v4
end
union1r <== or ==> union1l
end
v4 --"p:direct/P19"--> v5
v4 --"p:direct/P802"--> v3
v3 --"p:direct/P19"--> v6
v6 --"p:direct/P625"--> v7
v5 --"p:P625"--> a1
a1 --"p:statement/value/P625"--> a2
a2 --"wikibase:geoLatitude"--> v8
v5 --"p:P625"--> a3
a3 --"p:statement/value/P625"--> a4
a4 --"wikibase:geoLongitude"--> v9
v6 --"p:P625"--> a5
a5 --"p:statement/value/P625"--> a6
a6 --"wikibase:geoLatitude"--> v10
v6 --"p:P625"--> a7
a7 --"p:statement/value/P625"--> a8
a8 --"wikibase:geoLongitude"--> v11
bind2[/"concat('LINESTRING(',str(?lon1),' ',str(?lat1),',',str(?lon2),' ',str(?lat2),')')"/]
v9 --o bind2
v8 --o bind2
v11 --o bind2
v10 --o bind2
bind2 --as--o v12
bind3[/"STRDT(?str,'geo:wktLiteral')"/]
v12 --o bind3
bind3 --as--o v13
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P18".-> v14
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c12 --"wikibase:language"--> c14
end
bind4[/"?spob"/]
v6 --o bind4
bind4 --as--o v15
bind5[/"?student"/]
v3 --o bind5
bind5 --as--o v16
bind6[/"concat('Writer: ',str(?studentLabel))"/]
null --o bind6
bind6 --as--o v17
bind7[/"?teacher_or_infl"/]
v4 --o bind7
bind7 --as--o v18
bind8[/"concat('Teacher or Influencer: ',str(?teacher_or_inflLabel))"/]
null --o bind8
bind8 --as--o v19
bind9[/"concat('Writer place of birth: ',?spobLabel)"/]
null --o bind9
bind9 --as--o v20