query-112a4d66306a066e0ebbcbf4560732cb

rq turtle/ttl

Consitituency start dates, 1520s-1660s decades for parliamentary constituencies between 1520 and 1660 (P571)inception Map showing

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map
SELECT distinct ?const ?constLabel ?parent ?parentLabel ?start ?layer ?coords ?colour ?rgb



WHERE {
     {
  SELECT distinct ?const  ?parent  ?start ?layer ?coords ?colour WHERE {
    ?item p:P39 ?positionStatement . ?positionStatement ps:P39 ?term . ?term wdt:P279 wd:Q18018860 .
    ?positionStatement pq:P768 ?const .
    ?positionStatement prov:wasDerivedFrom ?ref . ?ref pr:P1614 ?refhop .
    optional { ?const wdt:P131 ?parent .
      optional { ?parent wdt:P625 ?coords } }
    ?const wdt:P571 ?start .
    FILTER (year(?start) > 1500) .
    BIND (xsd:float(floor(year(?start)/10) - 151) AS ?colour) .
    BIND (CONCAT(str(10 * floor(year(?start)/10)),'s') AS ?layer) .
  }
}.
     {
  SELECT ?colour ?rgb WHERE {
    VALUES ?sequence {wd:Q105849312} .     # desired colour progression
    VALUES ?n {7} .                        # desired no of points either side of centre

    ?sequence p:P527 ?stmt . ?stmt pq:P1545 ?seq . ?stmt pq:P465 ?rgb .
    ?sequence p:P2670/pq:P1114 ?len .
    BIND(((?len + 1.0)/2.0) AS ?centre) .
    BIND (floor((?centre - 1.0) / xsd:float(?n)) AS ?step) .
    BIND (?n + 1.0 + ((xsd:float(?seq) - ?centre)  / xsd:float(?step)) AS ?colour) .

    FILTER((?colour = floor(?colour)) && (?colour >= 1) && (?colour <= 1 + 2* ?n))
  } ORDER BY ?colour}.
    SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} order by ?start

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v18("?centre") v20("?colour"):::projected v5("?const"):::projected v9("?coords"):::projected v2("?item") v11("?layer"):::projected v17("?len") v14("?n") v8("?parent"):::projected v3("?positionStatement") v6("?ref") v7("?refhop") v16("?rgb"):::projected v15("?seq") v13("?sequence") v1("?start"):::projected v19("?step") v14("?stmt") v4("?term") a1((" ")) c5(["wd:Q18018860"]):::iri c22(["en"]):::literal c20(["bd:serviceParam"]):::iri f0[["year-from-dateTime(?start) > '1500^^xsd:integer'"]] f0 --> v1 v2 --"p:P39"--> v3 v3 --"p:statement/P39"--> v4 v4 --"p:direct/P279"--> c5 v3 --"p:qualifier/P768"--> v5 v3 --"prov:wasDerivedFrom"--> v6 v6 --"p:reference/P1614"--> v7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P131".-> v8 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v8 -."p:direct/P625".-> v9 end end v5 --"p:direct/P571"--> v1 bind1[/"http://www.w3.org/2001/XMLSchema#float(numeric-floor(year-from-dateTime(?start) / '10^^xsd:integer') - '151^^xsd:integer')"/] v1 --o bind1 bind1 --as--o v20 bind2[/"concat(str('10^^xsd:integer' * numeric-floor(year-from-dateTime(?start) / '10^^xsd:integer')),'s')"/] v1 --o bind2 bind2 --as--o v11 f3[["?colour = numeric-floor(?colour)?colour >= '1^^xsd:integer'?colour <= '1^^xsd:integer' + '2^^xsd:integer' * ?n"]] f3 --> v20 f3 --> v14 bind4[/VALUES ?sequence/] bind4-->v13 bind40(["wd:Q105849312"]) bind40 --> bind4 bind5[/VALUES ?n/] bind5-->v14 bind50(["7^^xsd:integer"]) bind50 --> bind5 v13 --"p:P527"--> v14 v14 --"p:qualifier/P1545"--> v15 v14 --"p:qualifier/P465"--> v16 v13 --"p:P2670"--> a1 a1 --"p:qualifier/P1114"--> v17 bind6[/"?len + '1.0^^xsd:decimal' / '2.0^^xsd:decimal'"/] v17 --o bind6 bind6 --as--o v18 bind7[/"numeric-floor(?centre - '1.0^^xsd:decimal' / http://www.w3.org/2001/XMLSchema#float(?n))"/] v18 --o bind7 v14 --o bind7 bind7 --as--o v19 bind8[/"?n + '1.0^^xsd:decimal' + http://www.w3.org/2001/XMLSchema#float(?seq) - ?centre / http://www.w3.org/2001/XMLSchema#float(?step)"/] v14 --o bind8 v15 --o bind8 v18 --o bind8 v19 --o bind8 bind8 --as--o v20 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c20 --"wikibase:language"--> c22 end