query-4c76a10825ec303a9efc079e69ace5a3

rq turtle/ttl

Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Stations de métro d'une ville à l'aide d'un modèle תחנות מטרו של עיר עם תבנית Metro station of city with template Metro station of city with template Stazione della metropolitana di una città con template Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Metrostation van de stad met sjabloon Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Metro station of city with template Tunnelbanestationer från stad med mall Metro station of city with template Metro station of city with template Станції метро міста з шаблоном Metro station of city with template 通过模板查询城市级行政区的地铁线路

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#TEMPLATE={"template":"metro station of ?city","variables":{"?city":{"query":"SELECT DISTINCT ?cityLabel where {?city wdt:P31/wdt:P279* wd:Q1637706. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en"} }"} } }
#defaultView:Map{"hide":["?comm1Label","?coord1", "?comm2","coord2","?layer","?str","?line", "?rgb"],"layer":"?connectingLine1Label"}
SELECT ?comm1 ?comm1Label ?coord1 ?comm2 ?coord2 ?line ?connectingLine1 ?connectingLine1Label ?layer ?rgb WHERE {
  BIND(wd:Q8686 AS ?city)
  ?comm1 wdt:P31/wdt:P279* wd:Q928830 ;
         wdt:P131*/wdt:P279* ?city;
         wdt:P625 ?coord1 ;
         wdt:P81 ?connectingLine1;
         wdt:P197 ?comm2 .
  ?connectingLine1 wdt:P465 ?rgb.
  ?comm2 wdt:P81 ?connectingLine2;
         wdt:P625 ?coord2 .
  FILTER (?connectingLine1 = ?connectingLine2)

  ?comm1 p:P625 [# ps:P625 [];
                  psv:P625 [ wikibase:geoLongitude ?coord1lon; wikibase:geoLatitude ?coord1lat; ] ] .
  ?comm2 p:P625 [# ps:P625 [];
                  psv:P625 [ wikibase:geoLongitude ?coord2lon; wikibase:geoLatitude ?coord2lat; ] ] .

  BIND(CONCAT('LINESTRING (', STR(?coord1lon), ' ', STR(?coord1lat), ',', STR(?coord2lon), ' ', STR(?coord2lat), ')') AS ?str) .
  BIND(STRDT(?str, geo:wktLiteral) AS ?line) .
  BIND(?connectingLine1 AS ?layer)

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}

ORDER BY (?connectingLine1Label)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?city") v5("?comm1"):::projected v7("?comm2"):::projected v2("?connectingLine1"):::projected v1("?connectingLine1Label"):::projected v3("?connectingLine2") v6("?coord1"):::projected v11("?coord1lat") v10("?coord1lon") v9("?coord2"):::projected v13("?coord2lat") v12("?coord2lon") v16("?layer"):::projected v15("?line"):::projected v8("?rgb"):::projected v14("?str") a1((" ")) a2((" ")) a4((" ")) a3((" ")) a6((" ")) a5((" ")) c16(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal c3(["wd:Q928830"]):::iri c14(["bd:serviceParam"]):::iri f0[["?connectingLine1 = ?connectingLine2"]] f0 --> v2 f0 --> v3 bind1[/"'wd:Q8686'"/] bind1 --as--o v4 v5 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c3 v5 --"p:direct/P131"--> a2 a2 --"p:direct/P279"--> v4 v5 --"p:direct/P625"--> v6 v5 --"p:direct/P81"--> v2 v5 --"p:direct/P197"--> v7 v2 --"p:direct/P465"--> v8 v7 --"p:direct/P81"--> v3 v7 --"p:direct/P625"--> v9 a3 --"wikibase:geoLongitude"--> v10 a3 --"wikibase:geoLatitude"--> v11 a4 --"p:statement/value/P625"--> a3 v5 --"p:P625"--> a4 a5 --"wikibase:geoLongitude"--> v12 a5 --"wikibase:geoLatitude"--> v13 a6 --"p:statement/value/P625"--> a5 v7 --"p:P625"--> a6 bind2[/"concat('LINESTRING (',str(?coord1lon),' ',str(?coord1lat),',',str(?coord2lon),' ',str(?coord2lat),')')"/] v10 --o bind2 v11 --o bind2 v12 --o bind2 v13 --o bind2 bind2 --as--o v14 bind3[/"STRDT(?str,'geo:wktLiteral')"/] v14 --o bind3 bind3 --as--o v15 bind4[/"?connectingLine1"/] v2 --o bind4 bind4 --as--o v16 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end