query-48ad0e348b6f387d3954c3c1af72a60d

rq turtle/ttl

Map query on ancient locations in ScotlandForts (filtered by map location)

Use at

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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
#defaultView:Map
SELECT DISTINCT (?typeLabel AS ?layer) ?label ?loc ?place ?picURI ?extURI ?tDesc
WHERE
{
   { { ?place wdt:P31 wd:Q532 .} UNION { ?place wdt:P31 wd:Q3957 .} 
       ?place wdt:P131/wdt:P31 ?where . FILTER (?where = wd:Q15060255 )  
   }.
   ?place wdt:P31 ?tLabel. ?tLabel rdfs:label ?tDesc filter (lang(?tDesc) = "en"). #Place name
   ?place      
      wdt:P625 ?loc ; # location to plot on map
          p:P625/psv:P625 ?coord; # coordinate-location statement    
      rdfs:label ?label filter (lang(?label) = "en"). #Place name
  OPTIONAL { ?place wdt:P18 ?picURI } .
  BIND(IF( regex(?label, "^Pit.*") , "Pict",
       IF( regex(?label, "^Aber.*") , "Pict", 
       IF( regex(?label, "^*.cardin.*") , "Pict", 
       IF( regex(?label, "^*.carden") , "Pict", 
       IF( regex(?label, "^Inver.*") , "Gael",   
       IF( regex(?label, "^Dun.*") , "Gael",
       IF( regex(?label, "^Bal.*") , "Gael",
       IF( regex(?label, "^Glen.*") , "Gael",
       IF( regex(?label, "^Strath.*") , "Gael",
       IF( regex(?label, "^Stran.*") , "Gael",
       IF( regex(?label, "^Stron.*") , "Gael",
       IF( regex(?label, "^Tigh.*") , "Gael",
       IF( regex(?label, "^Kil.*") , "Gael",
       IF( regex(?label, "^*.dale") , "Norse",    
       IF( regex(?label, "^*.dair") , "Norse",
       IF( regex(?label, "^*.firth") , "Norse",    
       IF( regex(?label, "^*.forth") , "Norse",        
          "Scot" ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
      ) AS ?typeLabel). 
  FILTER(?typeLabel != "Scot").
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?coord") v2("?label"):::projected v10("?layer") v7("?loc"):::projected v9("?picURI"):::projected v5("?place"):::projected v3("?tDesc"):::projected v6("?tLabel") v10("?typeLabel"):::projected v4("?where") a1((" ")) a2((" ")) c6(["wd:Q3957"]):::iri c5(["wd:Q532"]):::iri f0[["?typeLabel != 'Scot'"]] f0 --> v10 f1[["?label = 'en'"]] f1 --> v2 f2[["?tDesc = 'en'"]] f2 --> v3 f3[["?where = 'wd:Q15060255'"]] f3 --> v4 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P31"--> c6 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v5 --"p:direct/P31"--> c5 end union0r <== or ==> union0l end v5 --"p:direct/P131"--> a1 a1 --"p:direct/P31"--> v4 v5 --"p:direct/P31"--> v6 v6 --"rdfs:label"--> v3 v5 --"p:direct/P625"--> v7 v5 --"p:P625"--> a2 a2 --"p:statement/value/P625"--> v8 v5 --"rdfs:label"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P18".-> v9 end bind4[/"if(regex(?label,'^Pit.*'),'Pict',if(regex(?label,'^Aber.*'),'Pict',if(regex(?label,'^*.cardin.*'),'Pict',if(regex(?label,'^*.carden'),'Pict',if(regex(?label,'^Inver.*'),'Gael',if(regex(?label,'^Dun.*'),'Gael',if(regex(?label,'^Bal.*'),'Gael',if(regex(?label,'^Glen.*'),'Gael',if(regex(?label,'^Strath.*'),'Gael',if(regex(?label,'^Stran.*'),'Gael',if(regex(?label,'^Stron.*'),'Gael',if(regex(?label,'^Tigh.*'),'Gael',if(regex(?label,'^Kil.*'),'Gael',if(regex(?label,'^*.dale'),'Norse',if(regex(?label,'^*.dair'),'Norse',if(regex(?label,'^*.firth'),'Norse',if(regex(?label,'^*.forth'),'Norse','Scot')))))))))))))))))"/] v2 --o bind4 bind4 --as--o v10 bind5[/"?typeLabel"/] v10 --o bind5 bind5 --as--o v10