Project:SPARQL/examples: Difference between revisions

Line 952: Line 952:
    
    
   ?person bnwdt:P29  ?residence .  
   ?person bnwdt:P29  ?residence .  
 
      optional { ?residence bnwdt:P153 ?geo2 .  } # for geocoords added to BN
 
   optional {
   optional {
      
      
Line 963: Line 964:
      
      
       optional {?wikidata wdt:P625 ?geo1 .  } # geocoords if available
       optional {?wikidata wdt:P625 ?geo1 .  } # geocoords if available
       optional {?wikidata wdt:P131 ?terr . # admin territory of place if available
        
                    ?terr wdt:P625 ?terr_geo . # get geo for the admin territory to use as a fallback
      } # /wikidata service   
                    filter exists { ?wikidata wdt:P131 wd:Q84 . } # (only applies to the London postal areas at the moment)
                }
      BIND(COALESCE(?geo1, ?terr_geo) AS ?geo).  # if geo1 available, use that, if not use terr_geo
    } # /wikidata service   
     } #/wikidata optional
     } #/wikidata optional
    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
579

edits