/ js / overpass.js
overpass.js
 1  function getRouteMastersData(base, done, fail, always) {
 2      var query = '[out:json];' +
 3      base + '->.route_masters;' +
 4      'rel(r.route_masters)->.routes;' +
 5      'node(r.routes)->.stops;' +
 6      'way(r.routes)[~"(high|rail)way"~"."]->.paths;' +
 7      'node(w.paths)->.paths_nodes;' +
 8      '(' +
 9        'node(r.routes:"platform");' +
10        'node(r.routes:"platform_entry_only");' +
11        'node(r.routes:"platform_exit_only");' +
12        'way (r.routes:"platform");' +
13        'way (r.routes:"platform_entry_only");' +
14        'way (r.routes:"platform_exit_only");' +
15      ');' +
16      '(._;>;)->.platforms;' +
17      '(' +
18        'relation(bn.stops)["type"="public_transport"]["public_transport"="stop_area"];' +
19        'relation(bw.stops)["type"="public_transport"]["public_transport"="stop_area"];' +
20      ')->.stop_areas;' +
21      '(' +
22        '.route_masters;' +
23        '.routes;' +
24        '.stop_areas;' +
25        '.stops;' +
26        '.paths;' +
27        '.platforms;' +
28        '.paths_nodes;' +
29      ');' +
30      'out body;';
31  
32      $("#dlForm>input[type=submit]").prop("disabled", true);
33      $("#data-error").empty();
34      $.ajax(localStorage.getItem("otv-opapi") + "/interpreter", {
35          type: "POST",
36          data: query,
37      }).done(function (data) {
38          parsed = parseOSM(data);
39          done();
40      }).fail(fail)
41        .always(always);
42  }
43  
44  function getRouteMasterById(id, done, fail, always) {
45      if (parsed && parsed.route_masters[id]) {
46          done(parsed.route_masters[id]);
47          if (always != null) {
48                  always();
49          }
50      } else {
51          var base = 'relation["type"="route_master"](' + id + ')';
52          updateStatus("dl");
53          getRouteMastersData(base, done, fail, always);
54      }
55  }