Skip to content

Commit

Permalink
Remove old score code. #22
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Aug 26, 2024
1 parent e9d40bd commit 1d14bca
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
40 changes: 0 additions & 40 deletions backend/src/heatmap.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use std::collections::HashSet;

use geo::{Coord, Densify, Line, LineString};
use geojson::FeatureCollection;
use graph::IntersectionID;
use rstar::{primitives::GeomWithData, RTree};

use crate::{MapModel, RoadKind};

Expand All @@ -24,42 +20,6 @@ pub fn along_severances(map: &MapModel) -> FeatureCollection {
calculate(map, requests)
}

// For every intersection involving a footway, look for any other nearby intersection and see how
// hard it is to walk there.
#[allow(unused)]
pub fn nearby_footway_intersections(map: &MapModel, dist_meters: f64) -> FeatureCollection {
// Look for intersections we want to connect
let mut footway_intersections = HashSet::new();
for r in &map.graph.roads {
if map.road_kinds[r.id.0] == Some(RoadKind::Footway) {
footway_intersections.insert(r.src_i);
footway_intersections.insert(r.dst_i);
}
}

// Make an rtree
let mut points: Vec<GeomWithData<[f64; 2], IntersectionID>> = Vec::new();
for i in &footway_intersections {
points.push(GeomWithData::new(
map.graph.intersections[i.0].point.into(),
*i,
));
}
let rtree = RTree::bulk_load(points);

// For every intersection, try to go to every nearby intersection
let mut requests = Vec::new();
for i1 in &footway_intersections {
let i1_pt: Coord = map.graph.intersections[i1.0].point.into();
for i2 in rtree.locate_within_distance(i1_pt.into(), dist_meters) {
// TODO Skip trivial things connected by a road
let i2_pt = map.graph.intersections[i2.data.0].point.into();
requests.push((i1_pt, i2_pt));
}
}
calculate(map, requests)
}

fn calculate(map: &MapModel, requests: Vec<(Coord, Coord)>) -> FeatureCollection {
let mut samples = Vec::new();
let mut max_score = 0.0_f64;
Expand Down
2 changes: 0 additions & 2 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ impl MapModel {
#[wasm_bindgen(js_name = makeHeatmap)]
pub fn make_heatmap(&self) -> Result<String, JsValue> {
let samples = heatmap::along_severances(self);
// TODO unit here is weird or wrong or something
//let samples = heatmap::nearby_footway_intersections(self, 500.0);
let out = serde_json::to_string(&samples).map_err(err_to_js)?;
Ok(out)
}
Expand Down

0 comments on commit 1d14bca

Please sign in to comment.