query: #defaultView:Map{"hide":["?cd","?l","?rgb"]}
  #железнодарожный сеть России
  SELECT DISTINCT ?cd ?l ?i ?iLabel ?ct ?ctLabel ?o ?oLabel ?loc ?locLabel ?x ?rgb 
  WITH{SELECT ?i ?cd ?lat1 ?lon1 ?loc ?x (sample(?op)as?op)
                 WHERE{VALUES ?c1{wd:Q159}?i 
                                  wdt:P31/wdt:P279* wd:Q1318558; 
                                  wdt:P625 ?cd;
                                  wdt:P17 ?c1;
                                  p:P625/psv:P625 ?y.
                                  ?y wikibase:geoLatitude ?lat1;
                                  wikibase:geoLongitude ?lon1.
                       MINUS{?i wdt:P31/wdt:P279* wd:Q928830}
                       OPTIONAL{?i wdt:P131 ?loc}
                       OPTIONAL{?i wdt:P137 ?op}
                       OPTIONAL{?i wdt:P18 ?x}
                       }
                 GROUP BY ?i ?cd ?lat1 ?lon1 ?loc ?x
       }AS%s
  WITH{SELECT ?l ?ct ?o ?t 
                 WHERE{INCLUDE %s.
                       ?i p:P197 ?nss.
                       ?nss ps:P197 ?ns.
                       ?ns p:P625/psv:P625 ?z.
                       ?z wikibase:geoLatitude ?lat2;wikibase:geoLongitude ?lon2.
                       OPTIONAL{?nss pq:P81 ?ct.
                       OPTIONAL{?ct wdt:P137 ?o}}
                       OPTIONAL{?nss pq:P5051 ?t}
                       FILTER(STR(?i)< STR(?ns)).
                       BIND(CONCAT('LINESTRING(',STR(?lon1),' ',STR(?lat1),',',STR(?lon2),' ',STR(?lat2),')')AS?str).
                       BIND(STRDT(?str,geo:wktLiteral)AS?l)
                       }
      }AS%l
  WHERE{{INCLUDE%s}UNION{INCLUDE%l}.
        BIND(IF(BOUND(?l),IF(BOUND(?ct),IF(BOUND(?t),IF(BOUND(?o),"00f","4682b4"),"40e0d0"),"0f0"),
                IF(BOUND(?x),IF(BOUND(?loc),IF(BOUND(?op),"00f","4682b4"),"40e0d0"),"0f0"))
             AS?rgb)
        SERVICE wikibase:label{bd:serviceParam wikibase:language "ru".}
  }# 