-
Notifications
You must be signed in to change notification settings - Fork 5
"Overwrites" followups #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2d743eb
Document SetTags variant args
tordans 1d3234e
Refactor classify to use shared severance highway list
tordans af1a42c
Overrides: clean IndexedDB schema, drop migration and unused API
tordans bbe935c
Overwrites: do not set marker when clicking Mapillary pins
tordans 17baa0f
Overwrites: apply on import, store snapped geometry, surface errors
tordans 0501a88
Generator: crossing scope as radio group with local storage
tordans 604e8b9
Fix manual crossing: snap to footways, handle WASM Map result, valida…
tordans e0ce988
Manual crossing: Rework interaction
tordans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,51 @@ use utils::Tags; | |
|
|
||
| use crate::{Kind, Node, Speedwalk, Way}; | ||
|
|
||
| /// Snaps two WGS84 points to the nearest road, sidewalk, or walkable path (e.g. footway); returns snapped points in WGS84. | ||
| /// Includes walkable "Other" ways (e.g. highway=footway) so manual crossings can connect e.g. a footway to a road. | ||
| pub fn snap_crossing_segment( | ||
| model: &Speedwalk, | ||
| start_wgs84: Point, | ||
| end_wgs84: Point, | ||
| ) -> Result<(Point, Point)> { | ||
| let start_pt = model.mercator.to_mercator(&start_wgs84); | ||
| let end_pt = model.mercator.to_mercator(&end_wgs84); | ||
| let closest_line = RTree::bulk_load( | ||
| model | ||
| .derived_ways | ||
| .iter() | ||
| .filter(|(_, way)| way.is_snap_target_for_crossing()) | ||
| .map(|(id, way)| GeomWithData::new(way.linestring.clone(), *id)) | ||
| .collect(), | ||
| ); | ||
| let snap_to_line = |pt: Coord| -> Result<Coord> { | ||
| let Some(obj) = closest_line.nearest_neighbor(&Point::from(pt)) else { | ||
| bail!("Couldn't find a line to snap to"); | ||
| }; | ||
| let snapped = match obj.geom().closest_point(&Point::from(pt)) { | ||
| Closest::Intersection(c) | Closest::SinglePoint(c) => c.into(), | ||
| Closest::Indeterminate => bail!("Couldn't snap point to line"), | ||
| }; | ||
| Ok(snapped) | ||
| }; | ||
| let snapped_start = snap_to_line(start_pt.into())?; | ||
| let snapped_end = snap_to_line(end_pt.into())?; | ||
| // Reject degenerate case: both points snapped to the same location (e.g. same road segment) | ||
| let dist_m = Euclidean.distance( | ||
| Point::from(snapped_start), | ||
| Point::from(snapped_end), | ||
| ); | ||
| if dist_m < 0.5 { | ||
| bail!( | ||
| "Both points snapped to the same location (distance {:.1}m). Try clicking on the two crossing ways you want to connect.", | ||
| dist_m | ||
| ); | ||
| } | ||
| let start_out = model.mercator.pt_to_wgs84(snapped_start); | ||
| let end_out = model.mercator.pt_to_wgs84(snapped_end); | ||
| Ok((Point::from(start_out), Point::from(end_out))) | ||
| } | ||
|
|
||
| #[derive(Default)] | ||
| pub struct Edits { | ||
| pub user_commands: Vec<UserCmd>, | ||
|
|
@@ -26,7 +71,12 @@ pub struct Edits { | |
|
|
||
| #[derive(Clone, Serialize)] | ||
| pub enum UserCmd { | ||
| SetTags(WayID, Vec<String>, Vec<(String, String)>), | ||
| /// Set tags on a way. First: tag keys to remove. Second: key-value pairs to add or set (applied after removals). | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for fixing this. FYI for the future, https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html#listing-6-2 is an example of the struct-style for an enum case. Then the docs are unnecessary, the field names are clear |
||
| SetTags( | ||
| WayID, | ||
| Vec<String>, // remove_keys | ||
| Vec<(String, String)>, // add_tags | ||
| ), | ||
| MakeAllSidewalks(bool), | ||
| ConnectAllCrossings(bool), | ||
| AssumeTags(bool), | ||
|
|
@@ -142,7 +192,7 @@ impl Edits { | |
| model | ||
| .derived_ways | ||
| .iter() | ||
| .filter(|(_, way)| way.kind.is_road() || way.kind == Kind::Sidewalk) | ||
| .filter(|(_, way)| way.is_snap_target_for_crossing()) | ||
| .map(|(id, way)| GeomWithData::new(way.linestring.clone(), *id)) | ||
| .collect(), | ||
| ); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet this is the thing slowing down undo in the override mode. We could get more clever about caching this or only calculating once + updating if we're doing multiple undos. Just an idea for later, not important now