User:Stefan Kühn/OSM

From Wikidata
Jump to navigation Jump to search
#title:Wikidata-Items without weblink to OSM
#defaultView:Map, Table
SELECT distinct ?item ?itemLabel ?itemDescription ?osm_rel ?osm_way ?osm_node
(URI(CONCAT("https://www.openstreetmap.org/#map=18/", STR(?lat), '/', STR(?lon))) as ?osm_goto)
?coord ?rgb
WITH {
 SELECT distinct ?region                   # all aubregions
 WHERE {
 hint:Query hint:optimizer "None" .         
 BIND(wd:Q1731 AS ?state).                 # where? (Country / region / city)
 ?region wdt:P131* ?state.            
 MINUS { ?region wdt:P576 _:b0.}          # administrative unit without dissolution date   
 }
} AS %region

WHERE {
  INCLUDE %region.
  ?item wdt:P131 ?region.      
  ?item  (wdt:P31/wdt:P279*) wd:Q11755880.    # what? (monuments, churches)
  MINUS {?item wdt:P31 wd:Q19860854.} 
  MINUS {?item wdt:P31 wd:Q15893266.} 
  MINUS {?item wdt:P402 [].}   
  MINUS {?item wdt:P10689 [].}  
  MINUS {?item wdt:P11693 [].}  

  OPTIONAL {?item wdt:P402   ?osm_rel. }
  OPTIONAL {?item wdt:P10689 ?osm_way. }
  OPTIONAL {?item wdt:P11693 ?osm_nod. }
  BIND(BOUND(?osm_rel) as ?check_osm_rel)   
  BIND(BOUND(?osm_way) as ?check_osm_way)
  BIND(BOUND(?osm_nod) as ?check_osm_nod)
  
  BIND(  IF( ?check_osm_rel , "7FFF00",
         IF( ?check_osm_way , "009500",  
         IF( ?check_osm_nod , "99cc00", 
            "ff2d00"))) AS ?rgb).   

  OPTIONAL { ?item wdt:P18 ?image . }     
  OPTIONAL { ?item wdt:P625 ?coord. }  

  OPTIONAL{?item p:P625 / psv:P625 / wikibase:geoLatitude ?lat . }
  OPTIONAL{?item p:P625 / psv:P625 / wikibase:geoLongitude ?lon . }
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de,en". }
}
Wikidata-Items without weblink to OSM