Skip to content

Commit a0b1892

Browse files
committed
Use refactored Feature method
1 parent f0ef919 commit a0b1892

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

backend/Cargo.lock

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/src/map_model.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use geo::{
66
Closest, ClosestPoint, Coord, Euclidean, Length, Line, LineInterpolatePoint, LineLocatePoint,
77
LineString, Point, Polygon,
88
};
9-
use geojson::{Feature, FeatureCollection, GeoJson, Geometry};
9+
use geojson::{Feature, FeatureCollection, GeoJson};
1010
use serde::Serialize;
1111
use utils::{Mercator, Tags};
1212

@@ -284,7 +284,7 @@ impl MapModel {
284284
.linestring
285285
.line_interpolate_point(filter.percent_along)
286286
.unwrap();
287-
let mut f = Feature::from(Geometry::from(&self.mercator.to_wgs84(&pt)));
287+
let mut f = self.mercator.to_wgs84_gj(&pt);
288288
f.set_property("filter_kind", filter.kind.to_string());
289289
f.set_property("road", r.0);
290290
f.set_property("edited", Some(filter) != self.original_modal_filters.get(r));
@@ -317,15 +317,15 @@ impl MapModel {
317317
.linestring
318318
.line_interpolate_point(filter.percent_along)
319319
.unwrap();
320-
let mut f = Feature::from(Geometry::from(&self.mercator.to_wgs84(&pt)));
320+
let mut f = self.mercator.to_wgs84_gj(&pt);
321321
f.set_property("kind", "deleted_existing_modal_filter");
322322
gj.features.push(f);
323323
}
324324

325325
// Any direction edits
326326
for r in &self.roads {
327327
if self.directions[&r.id] != Direction::from_osm(&r.tags) {
328-
let mut f = Feature::from(Geometry::from(&self.mercator.to_wgs84(&r.linestring)));
328+
let mut f = self.mercator.to_wgs84_gj(&r.linestring);
329329
f.set_property("kind", "direction");
330330
f.set_property("direction", self.directions[&r.id].to_string());
331331
gj.features.push(f);
@@ -334,9 +334,7 @@ impl MapModel {
334334

335335
gj.features.extend(self.boundaries.values().cloned());
336336

337-
let mut f = Feature::from(Geometry::from(
338-
&self.mercator.to_wgs84(&self.boundary_polygon),
339-
));
337+
let mut f = self.mercator.to_wgs84_gj(&self.boundary_polygon);
340338
f.set_property("kind", "study_area_boundary");
341339
gj.features.push(f);
342340

@@ -454,12 +452,12 @@ impl MapModel {
454452
.unwrap()
455453
.route(self, pt1, pt2)
456454
{
457-
let mut f = Feature::from(Geometry::from(&self.mercator.to_wgs84(&linestring)));
455+
let mut f = self.mercator.to_wgs84_gj(&linestring);
458456
f.set_property("kind", "before");
459457
features.push(f);
460458
}
461459
if let Some(linestring) = self.router_current.as_ref().unwrap().route(self, pt1, pt2) {
462-
let mut f = Feature::from(Geometry::from(&self.mercator.to_wgs84(&linestring)));
460+
let mut f = self.mercator.to_wgs84_gj(&linestring);
463461
f.set_property("kind", "after");
464462
features.push(f);
465463
}
@@ -496,7 +494,7 @@ impl Road {
496494
}
497495

498496
pub fn to_gj(&self, mercator: &Mercator) -> Feature {
499-
let mut f = Feature::from(Geometry::from(&mercator.to_wgs84(&self.linestring)));
497+
let mut f = mercator.to_wgs84_gj(&self.linestring);
500498
f.set_property("id", self.id.0);
501499
f.set_property("way", self.way.to_string());
502500
f.set_property("node1", self.node1.to_string());

backend/src/neighbourhood.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use geo::{
55
Area, Contains, Distance, Euclidean, Intersects, Length, LineInterpolatePoint, LineLocatePoint,
66
LineString, Point, Polygon,
77
};
8-
use geojson::{Feature, FeatureCollection, Geometry};
8+
use geojson::FeatureCollection;
99
use web_time::Instant;
1010

1111
use crate::geo_helpers::clip_linestring_to_polygon;
@@ -137,7 +137,7 @@ impl Neighbourhood {
137137
features.push(f);
138138
}
139139
for i in &self.border_intersections {
140-
let mut f = Feature::from(Geometry::from(&map.mercator.to_wgs84(&map.get_i(*i).point)));
140+
let mut f = map.mercator.to_wgs84_gj(&map.get_i(*i).point);
141141
f.set_property("kind", "border_intersection");
142142
features.push(f);
143143
}
@@ -148,7 +148,7 @@ impl Neighbourhood {
148148
.iter()
149149
.zip(derived.render_cells.colors.iter())
150150
{
151-
let mut f = Feature::from(Geometry::from(&map.mercator.to_wgs84(polygons)));
151+
let mut f = map.mercator.to_wgs84_gj(polygons);
152152
f.set_property("kind", "cell");
153153
match color {
154154
Color::Disconnected => f.set_property("cell_color", "disconnected"),

backend/src/shortcuts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::HashMap;
22

33
use fast_paths::InputGraph;
44
use geo::{Euclidean, Length, LineString};
5-
use geojson::{Feature, Geometry};
5+
use geojson::Feature;
66
use utils::NodeMap;
77

88
use crate::{Direction, IntersectionID, MapModel, Neighbourhood, RoadID};
@@ -124,7 +124,7 @@ impl Path {
124124
let linestring = LineString::new(pts);
125125

126126
let length = linestring.length::<Euclidean>();
127-
let mut f = Feature::from(Geometry::from(&map.mercator.to_wgs84(&linestring)));
127+
let mut f = map.mercator.to_wgs84_gj(&linestring);
128128
f.set_property("directness", self.directness);
129129
f.set_property("length_meters", length);
130130
f

0 commit comments

Comments
 (0)