query-31acbb3d79fbe87bc15c27ef84d9e874

rq turtle/ttl

Some improvements for map queryHello again, I start a new paragraph because new ideas and questions. I'd like to achieve some small improvements in this layered map visualization: any chance to influence the order of the properties in the map bubble? (ok, at this point I might need to set up my own leaflet website and use the JSON-API, I suppose …) a map layer (instead of ?year) with (manually) grouped values for ?typology, like „private building“, „public building“, „bridge“ etc. (P279 won't work here, much more chaos as P31 alone …) Any ideas? and it would be nice to have a shorte clickable link text, like „more images“ for the Commons category. would like to add a small string prefix to the year output, like so: „KAP: 1967“, where to put the concat? cannot get the ?itemDescription to work, I might have missed the way to label it properly

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"hide":"?coords","layer":"?year"}
SELECT 
  ?item ?itemLabel ?itemDescription ?commonsuri ?typologyLabel
  ?coords
  (SAMPLE(?img) as ?image) 
  (MIN(YEAR(?date)) as ?year)
  (GROUP_CONCAT(DISTINCT ?architectLabel;separator=", ") AS ?architects) 
WHERE 
{
  ?item wdt:P166 wd:Q1795794;
        p:P166 [ps:P166 ?award; pq:P585 ?date];
        wdt:P31 ?typology.


  #let's try to get the Commons Link:
  OPTIONAL {?comm schema:about ?item ; schema:isPartOf <https://commons.wikimedia.org/> .} # ?comm = other websites Commons link
  BIND(replace(wikibase:decodeUri(SUBSTR(STR(?comm), 45)),"_"," ") AS ?comm_decode) # decode it
  OPTIONAL {?item wdt:P373 ?p373 .} # or get the Commonscat property 
  BIND(COALESCE(?comm_decode, ?p373) as ?cat) . # ?cat = first fit
  BIND(IRI(CONCAT("https://commons.wikimedia.org/wiki/",?cat)) as ?commonsuri). # how to make this clickable link a bit cleaner? Just “more images"

  OPTIONAL{
    ?item wdt:P625 ?coords.
  }
  OPTIONAL{
    ?item wdt:P18 ?img.
  }
  OPTIONAL {
    ?item wdt:P84 ?architect. # will be grouped
  }
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de" .
                         ?item rdfs:label ?itemLabel .
                        ?architect rdfs:label ?architectLabel .
                        ?typology rdfs:label ?typologyLabel.
                        }
} 
GROUP BY ?item ?itemLabel ?itemDescription ?coords ?commonsuri ?typologyLabel
LIMIT 300

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v12("?architect") v14("?architectLabel"):::projected v18("?architects") v2("?award") v8("?cat") v5("?comm") v6("?comm_decode") v9("?commonsuri"):::projected v10("?coords"):::projected v3("?date"):::projected v16("?image") v11("?img"):::projected v1("?item"):::projected v13("?itemLabel"):::projected v7("?p373") v4("?typology") v15("?typologyLabel"):::projected v17("?year") a1((" ")) c17(["#91;AUTO_LANGUAGE#93;,de"]):::literal c9([https://commons.wikimedia.org/]):::iri c15(["bd:serviceParam"]):::iri c2(["wd:Q1795794"]):::iri v1 --"p:direct/P166"--> c2 a1 --"p:statement/P166"--> v2 a1 --"p:qualifier/P585"--> v3 v1 --"p:P166"--> a1 v1 --"p:direct/P31"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."schema:about".-> v1 v5 --"schema:isPartOf"--> c9 end bind0[/"replace(http://wikiba.se/ontology#decodeUri(substring(str(?comm),'45^^xsd:integer')),'_',' ')"/] v5 --o bind0 bind0 --as--o v6 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P373".-> v7 end bind1[/"?comm_decode?p373"/] v6 --o bind1 v7 --o bind1 bind1 --as--o v8 bind2[/"concat('https://commons.wikimedia.org/wiki/',?cat)"/] v8 --o bind2 bind2 --as--o v9 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P625".-> v10 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P18".-> v11 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P84".-> v12 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c15 --"wikibase:language"--> c17 v1 --"rdfs:label"--> v13 v12 --"rdfs:label"--> v14 v4 --"rdfs:label"--> v15 end bind6[/"sample(?img)"/] v11 --o bind6 bind6 --as--o v16 bind7[/"min(year-from-dateTime(?date))"/] v3 --o bind7 bind7 --as--o v17 bind8[/"?architectLabel"/] v14 --o bind8 bind8 --as--o v18