replace inconsistent rider count with destination and heading

This commit is contained in:
steven 2025-05-18 15:15:22 -04:00
parent 4025bc115b
commit d104b16fc2
2 changed files with 7 additions and 9 deletions

View file

@ -9,7 +9,7 @@
<script src="/static/leaflet/leaflet.js"></script>
<link rel="stylesheet" href="/static/leaflet/leaflet.css">
<base target="_blank">
<style>html,body{height:100%;margin:0;}#map{height:100vh;}iframe{border:none;width:400px;}.leaflet-popup-content{min-width:400px}</style>
<style>html,body{height:100%;margin:0;}#map{height:100vh;}iframe{border:none;width:444px;}</style>
</head>
<body>
<div id="map"></div>
@ -35,19 +35,17 @@ function updateMap(){
let routes={};
fetch("tarc.csv").then(response=>response.text()).then(csv=>{
csv.split("\n").forEach(line=>{
let [lat,lng,r,id,p,d,s,t]=line.split(",");
p=parseInt(p);
let [lat,lng,r,id,h,dir,dest,s,t]=line.split(",");
t=new Date(t*1000).toLocaleTimeString("en-US",{hour12:false});
if(!busLayers[r]){busLayers[r]=L.layerGroup().addTo(map)}
if(!busMarkers[id]){busMarkers[id]=L.marker([0,0],{icon:busIcon}).on('click',()=>filterRoutes(r)).addTo(busLayers[r])}
if(!routes[r]){routes[r]=[0,0]}
routes[r][0]++;
routes[r][1]+=p;
busMarkers[id].setLatLng([lat,lng]).bindPopup(`<b>Route ${r}</b><br>#${id}<br>${p} riders<br>${d}<br>${s}mph<br>${t}`)
if(!routes[r]){routes[r]=0}
routes[r]++;
busMarkers[id].setLatLng([lat,lng]).bindPopup(`<b>Route ${r}</b><br>#${id} <span style="transform:rotate(${h}deg);display:inline-block;">^</span><br>${dir}<br>${dest}<br>${s}mph<br>${t}`)
})
let overlayLayers={};
for(let r in routes){
overlayLayers[`${r.padStart(2,0)} | ${String(routes[r][0]).padStart(2,0)} vehicle(s) | ${routes[r][1]} rider(s)`]=busLayers[r]
overlayLayers[`${r.padStart(2,0)} | ${String(routes[r]).padStart(2,0)} vehicle(s)`]=busLayers[r]
}
layerControl.remove();
layerControl=L.control.layers(null,overlayLayers).addTo(map);