|
1 | 1 | {% import 'sparql-helpers.sparql' as sparql_helpers -%} |
2 | | -PREFIX target: <http://www.wikidata.org/entity/{{ q }}> |
3 | 2 | # title: Nearby academic institutions around a specified geographic entity. |
4 | | -PREFIX bd: <http://www.bigdata.com/rdf#> |
5 | 3 | PREFIX wd: <http://www.wikidata.org/entity/> |
6 | 4 | PREFIX wdt: <http://www.wikidata.org/prop/direct/> |
7 | | -PREFIX wikibase: <http://wikiba.se/ontology#> |
8 | 5 | PREFIX geof: <http://www.opengis.net/def/function/geosparql/> |
9 | 6 | SELECT ?distance ?unit ?unitLabel ?organization ?organizationLabel ?organizationDescription (CONCAT("/organization/", SUBSTR(STR(?organization),32)) AS ?organizationUrl) WHERE { |
10 | 7 | { # Compute distance. |
11 | 8 | SELECT ?organization ?distance ?unit WHERE { |
12 | | - { # Academic institutions on all levels |
13 | | - SELECT DISTINCT ?organization ?other_geo WHERE { |
14 | | - { ?organization wdt:P361*/wdt:P31/wdt:P279* wd:Q3918 } |
| 9 | + # Academic institutions on all levels |
| 10 | + { ?organization wdt:P361*/wdt:P31/wdt:P279* wd:Q3918 } |
15 | 11 | UNION |
16 | 12 | { ?organization wdt:P361*/wdt:P31/wdt:P279* wd:Q1371037 } |
17 | 13 | UNION |
18 | 14 | { ?organization wdt:P361*/wdt:P31/wdt:P279* wd:Q7315155 } |
19 | 15 | UNION |
20 | 16 | { ?organization wdt:P361*/wdt:P31/wdt:P279* wd:Q31855 } |
21 | | - ?organization wdt:P625 ?other_geo . |
22 | | - } |
23 | | - } |
24 | | - target: wdt:P159*/wdt:P625 ?geo . |
| 17 | + ?organization wdt:P625 ?other_geo . |
| 18 | + wd:{{ q }} wdt:P159*/wdt:P625 ?geo . |
25 | 19 | BIND (geof:distance(?other_geo,?geo) AS ?distance) |
26 | 20 | BIND (wd:Q828224 AS ?unit) |
27 | 21 | FILTER (?distance < 250) |
|
0 commit comments