Skip to content

"Overwrites" followups#108

Merged
dabreegster merged 8 commits into
a-b-street:mainfrom
tordans:overwrites-followup
Mar 14, 2026
Merged

"Overwrites" followups#108
dabreegster merged 8 commits into
a-b-street:mainfrom
tordans:overwrites-followup

Conversation

@tordans

@tordans tordans commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

This is a mixed bag again; a follow up to #103
Same discosures apply.

  1. I adressed the review comments from UI Update; Editing mode Update; Bulk-Update-Page; Manual-Update-Page #103 (comment)

  2. The "Generate crossings" section is now a radio button group with better labels and stored in localstorage

    image
  3. The Overwrites Page now has a button to set and delete the draft crossing.
    The undo code is a bit more performant ("Remove" button next to manual crossings).
    The manual crossing backend now looks at more way types; uses a shared helper to keep the different code parts in sync.

  4. We restore the manual crossings now after loading them from file and store them a bit differently so they load more like we had them before.

  5. The manual override marker are now dragable; and dont interfere with the Mapillary Pins (when Mapillary is active)

tordans added 8 commits March 11, 2026 14:20
(PR a-b-street#103)

Keep SetTags(WayID, Vec<String>, Vec<(String, String)>) with explicit
fields. Add doc comment and inline comments (remove_keys, add_tags) so
the two vecs are clearly defined.
(PR a-b-street#103)

- Add SEVERANCE_HIGHWAY_TYPES in lib.rs as single source of truth for
  motorway through tertiary_link (no service).
- Add is_severance_highway(tags) and is_road_without_sidewalks_implicit(tags);
  the latter is severance types OR highway=service for RoadWithoutSidewalksImplicit.
- Way::is_severance() now uses is_severance_highway(); classify uses
  is_road_without_sidewalks_implicit() so service stays explicit and the
  rest reuse the same definition.
- Store "overrides" with keyPath "id"; single record id "default" (no region).
- DB version 2; create store when oldVersion < 2 so existing v1 DBs don’t break (no data migration).
- Remove legacy migration and deleteOverrides(); simplify file comment.
- Add mapillaryLayers.ts with stable layer IDs; use them in Mapillary.svelte and OverwritesMode.
- Skip setting pointA/pointB when the click hits a Mapillary pin.
- Only query layers that exist in the current style so it works when Mapillary is off.
- Apply overwrites immediately after import: when importing a file, segments
  in the current boundary are applied right away (no need to switch modes).
- Store snapped geometry: new crossings use snapCrossingSegment() before apply;
  start/end are saved as snapped coords so re-apply and import snap correctly.
- Backend: add snap_crossing_segment() and snapCrossingSegment WASM; reuse
  same RTree/snap logic as AddCrossingSegment, return snapped WGS84 coords.
- Surface backend snap/apply errors in the UI via applyError state and a
  dismissible danger alert (e.g. "Couldn't find a line to snap to").
- Normalize imported segments (ids, valid start/end) and fix appliedCount
  when applying only newly imported segments.
- Remove unused LineString/WayProps imports in OverwritesMode.
- Replace three crossing buttons with one radio group (major / minor / all)
- Persist choice in crossingScopeBulk (LocalStorageWrapper on card header)
- Option C labels: Major only, Major+minor excl. service/track, All roads
- Single 'Generate missing crossings' button; 'all' uses only_major_roads=false
Use marker, add bbox guard, add buttons

@dabreegster dabreegster left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick skim LGTM! Some optional stuff for later. Thanks for this PR, merging

Comment thread backend/src/edits.rs
#[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).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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

}
}

/** Backend may return a plain object or a Map (from WASM/serde). Normalize to { start: { lng, lat }, end: { lng, lat } }. */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels messy -- why are there two formats in the first place? Could clean up later, not worried about it now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100%. The backend provides one data structure and the import (json) a different one. We also don't have something like Zod in the dependencies yet which means quite verbose validation code is needed.

Note to self: Look into Zod Mini and use one structure for both "input" sources.

Comment thread backend/src/edits.rs
) -> 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(

Copy link
Copy Markdown
Collaborator

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

@dabreegster dabreegster merged commit 9c042e2 into a-b-street:main Mar 14, 2026
@tordans tordans deleted the overwrites-followup branch March 15, 2026 06:14
@tordans tordans mentioned this pull request Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants