Project:SPARQL/examples: Difference between revisions

Line 1,551: Line 1,551:


#title:a map of BN items near a chosen starting point in England
#title:a map of BN items near a chosen starting point in England
#defaultView:Map


## create a thingy for the start point: change the Qxxx ID in the following PREFIX var_start line to chosen location.   
## create a thingy for the start point change the Qxxx ID in the following PREFIX var_start line to chosen location.   
## **MUST** a) be in England and b) have a wikidata item that has coordinate location!
## **MUST** a) be in England and b) have a wikidata item that has coordinate location!


Line 1,568: Line 1,569:


## TODO is there a way to get the location itemLabel and use it in the map title...
## TODO is there a way to get the location itemLabel and use it in the map title...
#defaultView:Map


SELECT distinct  ?item ?itemLabel ?locationLabel ?location ?wikidata ?wd_geo  ?distance #?wd_long ?wd_lat   
SELECT distinct  ?item ?itemLabel ?locationLabel ?location ?wikidata ?wd_geo  ?distance #?wd_long ?wd_lat   
Line 1,577: Line 1,576:
    
    
   {?item bnwdt:P29  ?location . } # resided at location
   {?item bnwdt:P29  ?location . } # resided at location
  #union
  #{?location bnwdt:P12 bnwd:Q2147 .} # OR location has instance of locality. is there a way to get this in the same structure?
   union
   union
   {?item bnwdt:P2  ?location . } # item has property P2 location
   {?item bnwdt:P2  ?location . } # item has property P2 location
   # any other possibles ?  
   # other possibles ?  
    
    
   ## limit to places in admin territory p33 england q617. (keep numbers down to avoid wikidata timing out)  
   ## limit to places in admin territory p33 england q617. (keep numbers down to avoid wikidata timing out)  
Line 1,596: Line 1,593:
     #BIND(geof:latitude(?wd_geo)  AS ?wd_lat) .   
     #BIND(geof:latitude(?wd_geo)  AS ?wd_lat) .   
     bind(geof:distance(?wd_geo, ?start) as ?distance).  
     bind(geof:distance(?wd_geo, ?start) as ?distance).  
     FILTER(?distance < 50). # < xx km from ?start_wd
 
     FILTER(?distance < 40). # < xx km from start_wd
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
586

edits