Skip to content

Commit

Permalink
fix routing, temporarily disable duplicate reports
Browse files Browse the repository at this point in the history
  • Loading branch information
bopjesvla committed Feb 9, 2025
1 parent 28d8539 commit c3e795c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 810 deletions.
2 changes: 1 addition & 1 deletion js/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function clearParams() {
window.navigate();
}

clearFilters.onclick = (navigateHomeCallback) => {
clearFilters.onclick = () => {
clearParams()
window.navigateHome()
}
Expand Down
10 changes: 10 additions & 0 deletions js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ var handleMarkerNavigation = function (marker) {
}, 100)
};

$$(".sidebar.show-spot").addEventListener("click", function (event) {
const link = event.target.closest("a"); // Ensure it's an <a> tag
if (link && link.href) {
event.preventDefault(); // Prevent default navigation
history.pushState({}, "", link.href); // Update the URL without reloading
navigate();
}
});

var map = L.map(
"hitch-map",
{
Expand Down Expand Up @@ -506,6 +515,7 @@ window.destinationMarkers = destinationMarkers;

// Set up hash change listener
window.onhashchange = navigate
window.onpopstate = navigate

// Initial navigation
navigate()
Expand Down
28 changes: 22 additions & 6 deletions scripts/show.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import html
import os
import sqlite3
import sys
from jinja2 import Environment, FileSystemLoader

Expand Down Expand Up @@ -74,18 +73,23 @@

service_areas = pd.read_sql("select * from service_areas", get_db())
service_area_geoms = gpd.GeoDataFrame(
service_areas[["geom_id"]], geometry=gpd.GeoSeries.from_wkt(service_areas.geometry_wkt), crs="EPSG:4326"
service_areas[["geom_id"]],
geometry=gpd.GeoSeries.from_wkt(service_areas.geometry_wkt),
crs="EPSG:4326",
)

points["service_area_id"] = points.sjoin(service_area_geoms, how="left")["geom_id"]

road_islands = pd.read_sql("select * from road_islands", get_db())
road_island_geoms = gpd.GeoDataFrame(
road_islands[["id"]], geometry=gpd.GeoSeries.from_wkt(road_islands.geometry_wkt), crs="EPSG:4326"
road_islands[["id"]],
geometry=gpd.GeoSeries.from_wkt(road_islands.geometry_wkt),
crs="EPSG:4326",
)

points["road_island_id"] = points.sjoin(road_island_geoms, how="left").drop_duplicates("id_left")["id_right"]


# pseudo-random cluster id based on lat/lon
points["cluster_id"] = (points.lat * 1e10 + points.lon * 1e10).round()

Expand Down Expand Up @@ -137,11 +141,13 @@
}
)


rating_text = "rating: " + points.rating.astype(int).astype(str) + "/5"
destination_text = (
", ride: " + np.round(points.ride_distance).astype(str).str.replace(".0", "", regex=False) + " km " + points.arrows
)


points["wait_text"] = None
has_accurate_wait = ~points.wait.isnull() & ~points.datetime.isnull()
points.loc[has_accurate_wait, "wait_text"] = (
Expand Down Expand Up @@ -228,9 +234,19 @@ def e(s):
# make sure high-rated are on top
places.sort_values("z-index", inplace=True, ascending=True)

marker_data = places[["lat", "lon", "rating", "text", "wait", "ride_distance", "review_users", "dest_lats", "dest_lons"]].to_json(
orient="values"
)
marker_data = places[
[
"lat",
"lon",
"rating",
"text",
"wait",
"ride_distance",
"review_users",
"dest_lats",
"dest_lons",
]
].to_json(orient="values")

try:
subprocess.run(["npm", "run", "build"], check=True, text=True)
Expand Down
Loading

0 comments on commit c3e795c

Please sign in to comment.