query: #defaultView:Map{"hide":["?coordinates", "?line", "?rgb"]}
  SELECT DISTINCT ?coordinates ?line ?station ?stationLabel ?connectLabel ?image ?opening ?rgb
  
  WITH {
    SELECT ?metro ?station ?coordinates ?image ?lat ?lon ?opening WHERE {
      {
        SELECT ?metro ?station (SAMPLE(?coord_stmt) AS ?coord_stmt) (SAMPLE(?image) AS ?image) (sample(?opening) as ?opening) WHERE {
          VALUES ?metro { wd:Q541027 } .
          ?station wdt:P31/wdt:P279* wd:Q55488 .
          ?station wdt:P81?/wdt:P361 ?metro .
          ?station p:P625 ?coord_stmt  .
          OPTIONAL { ?station wdt:P18 ?image }.
          OPTIONAL { ?station wdt:P1619 ?opening }.
        } GROUP BY ?metro ?station
      }
      hint:SubQuery hint:optimizer "None".
      ?coord_stmt ps:P625 ?coordinates .
      ?coord_stmt psv:P625 / wikibase:geoLatitude ?lat .
      ?coord_stmt psv:P625 / wikibase:geoLongitude ?lon . 
    }
  } AS %stations
  
  WITH {
    SELECT (?station AS ?nextstation) (?lat AS ?lat2) (?lon AS ?lon2) WHERE {
      INCLUDE %stations
    }
  } AS %nextstations
  
  WITH {
    SELECT ?line ?connect ?rgb WHERE {
      INCLUDE %stations .
      INCLUDE %nextstations .
      ?station p:P197 ?nextstationstatement .
      ?nextstationstatement ps:P197 ?nextstation .
      ?nextstationstatement pq:P81 ?connect . ?connect wdt:P361 ?metro  . 
      OPTIONAL {?connect (p:P462/pq:P465)|wdt:P465 ?rgb} .
      FILTER(STR(?station) < STR(?nextstation)) .    
      BIND(CONCAT('LINESTRING (', STR(?lon), ' ', STR(?lat), ',', STR(?lon2), ' ', STR(?lat2), ')') AS ?str) .
      BIND(STRDT(?str, geo:wktLiteral) AS ?line) 
    }
  } AS %lines
   
  WHERE {
    { INCLUDE %stations }  UNION { INCLUDE %lines  } .
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  }