-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
162 lines (153 loc) · 6.27 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html style="margin:0px;">
<head>
<title>Budapest Route Planner</title>
<meta name='viewport' content='width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no' />
<link rel="stylesheet" href="style/style.css">
<script src='scripts/maplibre-gl/maplibre-gl.js'></script>
<link href='scripts/maplibre-gl/maplibre-gl.css' rel='stylesheet' />
<script type="text/javascript" charset="utf-8" src="scripts/external/turf.min.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/gtfs.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/style.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/local.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/menuControl.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/workerPromises.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/route_ui.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/isochrone.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/external/decomp.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/debug_ui.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/stop_ui.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/external/protobuf.minimal.min.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/external/protobuf-gtfs-realcity.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/realtime.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/external/inflate_stream.min.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/destinations_ui.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/discordIntegration.js"></script>
<script>
var map, mapUI, stopDrawUI, route, countdown, realtime, realtimeUI, workerPromises;
var gtfs, gtfsRoutes, gtfsWorker, progress;
function onLoad()
{
realtime = new Realtime();
map = new maplibregl.Map({
container: 'map',
style: style,
center: [19.06086, 47.52918],
zoom: 12
});
map.doubleClickZoom.disable();
map.touchZoomRotate.disableRotation();
try{map.touchZoomRotate._tapDragZoom.disable();}catch(e){console.warn("Failed to disable tap-drag-zoom!");}
mapUI = new MapUI(map);
mapUI.addMarkerOnClick();
map.addControl(new maplibregl.FullscreenControl({ container: document.querySelector('body') }));
map.addControl(new maplibregl.NavigationControl());
map.addControl(new maplibregl.GeolocateControl({
positionOptions: { enableHighAccuracy: true },
trackUserLocation: true
}).on('geolocate', (e) => {
console.log('geolocate', e);
mapUI.updateUserLocation({lng:e.coords.longitude, lat:e.coords.latitude});
}).on('trackuserlocationstart', function() {
}).on('trackuserlocationend', function() {
}));
countdown = new Countdown();
stopDrawUI = new StopDrawUI(map);
realtimeUI = new RealtimeUI(mapUI);
map.addControl(new MenuControl(),'top-left');
map.addControl(new IsochroneControl(),'top-left');
map.addControl(new DestinationsControl(),'top-left');
route = new Route(mapUI);
progress = new ProgressBar();
gtfsWorker = new Worker('scripts/gtfsWorker.js');
workerPromises = new WorkerPromises(gtfsWorker);
gtfsWorker.onmessage = function(e) {
if(typeof e.data !== 'object' || e.data === null) return;
if('route' in e.data) {
console.log('got route', e.data);
mapUI.routeReceived();
route.drawRoute(e.data.route.path);
showRoute(e.data.route.steps);
document.getElementById('routeInfoContainer').classList.remove('hidden');
}
if('progress' in e.data) {
progress.setTitle(e.data.progress[0]);
progress.setProgress(e.data.progress[1]);
if(e.data.progress[1] >= 1) progress.hide();
else if(!progress.isVisible()) progress.show();
}
if('info' in e.data) {
const cElem = document.getElementById("coordinates");
cElem.innerHTML = e.data.info;
}
if('rowInd' in e.data && 'row' in e.data) {
receiveHeatmapMessage(e.data);
}
if('stops' in e.data) {
receiveStopsForDrawing(e.data.stops);
}
if('task' in e.data && e.data.task == 's2') {
receiveGeoJsonForDrawing(e.data.cell);
}
if('task' in e.data && e.data.task == 's2bb') {
stopDrawUI.updateStops(e.data);
}
if('task' in e.data && e.data.task == 'stopInfo') {
stopDrawUI.showStopDetailedInfo(e.data);
}
if('task' in e.data && e.data.task == 'timing' && dsts) {
dsts.processRouteStats(e.data);
}
workerPromises.checkMessageFromWorker(e.data);
}
mapUI.setWorker(gtfsWorker);
}
</script>
</head>
<body onload="onLoad();">
<div id="map"></div>
<pre id="coordinates"></pre>
<div id="routeInfoContainer" class="bottomContainer hidden" onclick="this.classList.add('hidden')">
<div id="routeInfoContent">
<div class="title"></div>
<div class="routes">
<div class="entry">
<div class="rightHeadline"></div>
<h1></h1>
<div class="route">
</div>
<div class="details">
</div>
</div>
</div>
<div><br></div>
</div>
</div>
<div id="stopInfoContainer" class="bottomContainer hidden" onclick="this.classList.add('hidden')">
<div id="stopInfoContent">
<div class="title"></div>
<div class="stopDepartures">
</div>
<div><br></div>
</div>
</div>
<div id="progressBarContainer" class="bottomContainer hidden" onclick="this.classList.add('hidden')">
<div id="progressContent">
<div id="progressTitle">Sample Title</div>
<div id="progressBarDiv"><progress id="progressBar" max="100" value="70">70%</progress></div>
</div>
</div>
<div id="trackerBarContainer" class="bottomContainer hidden">
<div id="trackerContent">
<div class="titleRow">
<div class="hide button" onclick="this.parentElement.parentElement.parentElement.classList.add('hidden')">❌</div>
<div class="cleanup button" onclick="dsts.cleanup()">🧹</div>
<div class="refresh button" onclick="dsts.updateRouteStats(false)">🔄</div>
<div class="title">destinations</div>
</div>
<div class="destinations">
</div>
</div>
</div>
</body>
</html>