Repository navigation
Refactor frontend to use adiffs.osmcha.org; remove changeset-map - #772
Conversation
| }; | ||
| layerOptions = [ | ||
| { | ||
| label: 'Mapbox Satellite', |
There was a problem hiding this comment.
The Bing aerial imagery layer is just raster imagery; whereas Mapbox Satellite included a vector overlay containing boundaries, city and town names, etc which was helpful for getting your bearings when viewing a changeset. In the future I'm hoping to add an optional overlay similar to this to the Bing imagery layer.
If you end up creating something like this, iD might be able to use it as a replacement for the existing Location Overlay, which is a custom Mapbox tileset that needs to be updated manually once in a while.
There was a problem hiding this comment.
Good to know, I will keep that in mind. For OSMCha this would probably be a vector tileset and accompanying stylesheet that could be overlaid on top of the raster basemap. It looks like iD's locator overlay is a raster tileset of PNGs with alpha channels. Do you know if iD can render vector tiles? I know it uses a custom SVG-based rendering engine (not MapLibre or Leaflet), just wondering if it already supports parsing and using MVTs.
|
Congrats @jake-low @willemarcel ! This was a big lift! |
|
+1, this is a big change, well coordinated! |
|
... tears in my eyes seeing those issues close ... thank you so much for your work on this @jake-low ! |
|
Very excited about this big improvement! |
Background
OSMCha is an application for viewing OpenStreetMap changesets. To do this, OSMCha needs data about everything that was modified: specifically, it needs to know the complete old and new versions of all elements that were affected by the change, directly or indirectly.
Changesets from openstreetmap.org don't contain all of this information "off the shelf". When you download a changeset from openstreetmap.org via the API (example), it only contains the new versions of elements, not the old versions. It also does not contain elements that were modified indirectly (e.g. moving some nodes that are part of a way changes the way's shape, but does not actually generate a new version of that way, so only the nodes would be included in the changeset). These changeset files are optimized to be small in size and easy to compute (they directly match OSM's underlying data model), but because of this they don't contain enough detail for visually presenting the scope of the changes to a human. The changes in the planet.openstreetmap.org replication files have this same limitation.
To get the data we need in order to visualize changesets, OSMCha relies on a backend data pipeline that processes changesets from the OpenStreetMap API and "augments" them with additional context. These "augmented diffs" are computed in advance and then fetched by the osmcha.org website when you view a changeset.
The version of this pipeline that we currently use is based on Overpass, a queryable database system for OSM (and the same technology that powers overpass-turbo.eu). It's possible to use Overpass to query for all of the old and new versions of each element in a changeset. Our backend does this for each new changeset, and stores the results in a S3 bucket called
real-changesets.There are problems with this approach. Overpass is an impressive and flexible tool, but it's not meant for this kind of workload, so building augmented diffs in this way is expensive and fairly slow. The Overpass query we use is also prone to false positive matches if two changesets occur in the same area in a very short time window, which means OSMCha occasionally shows changes that aren't actually part of the changeset you're looking at (#467, #492).
Over the last few months, I've been working on a new pipeline to generate augmented diff data. The code for that pipeline is at osmcha/osmx-adiff-builder and it is running in production at
adiffs.osmcha.org. It uses OSMExpress to keep a local mirror of the OpenStreetMap dataset, from which it can build augmented diffs. These diffs are served in the Augmented Diff XML format, which is supported by various OSM software (thereal-changesetsbucket serves data in a bespoke JSON representation that was less interoperable with other tools).The new pipeline is faster, cheaper to operate, and does not have the same false-positive problem that our previous approach did. Its goal is to replace the existing
real-changesetsS3 bucket, and in doing so make the osmcha.org website faster and more dependable.What's in this PR
This PR switches the osmcha.org web frontend to load augmented diff data from
adiffs.osmcha.org(the new service) instead of from the S3real-changesetsbucket (the old service). To do this, a lot of other interrelated changes had to be made as well.Most significantly, OSMCha now no longer depends on the changeset-map library.
changeset-mapis one of the original tools for visualizing OSM changesets, and OSMCha was initially built around it, withchangeset-mapproviding the core map visualization UI and OSMCha providing the rest of the UI surrounding it (like the sidebar and changeset metadata panel).However, this separation created some challenges.
changeset-mapdoes its own loading of changeset data (including handling the bespokereal-changesetsJSON format). It renders both the changeset map overlay and the underlying basemap (using Mapbox GL JS 1.13). And it also renders some UI elements, like the element info panel you see in the lower right when you click a map element in OSMCha.To simplify maintenance, these jobs have been moved into the osmcha-frontend, or spun out into separate, single-purpose libraries. Parsing augmented diff XML into a JavaScript object is done by the standalone
osm-adiff-parserlibrary. To render augmented diffs on a map, we use MapLibre GL JS and a newmaplibre-adiff-viewerplugin, which takes a parsed augmented diff and renders it on top of any basemap you provide. Themaplibre-adiff-viewerplugin is UI-agnostic, so it can be used in any project that wishes to render an augmented diff on a MapLibre map (like the new osmcha-cli tool).In short, this PR means that OSMCha:
changeset-map, and instead depends onosm-adiff-parserandmaplibre-adiff-viewerto parse and render augmented diffsreal-changesets, and instead loads augmented diffs fromadiffs.osmcha.orgWhat does it look like?
Mostly the same as before. 🙂 Here's an overall before/after:
The map visualization provided by
maplibre-adiff-vieweris slightly tweaked compared to the rendering used bychangeset-map.Before/after:
Clicking on a map element reveals a new details panel (the old one was part of
changeset-map). It contains the same information as before, but the layout has been modified a bit to increase information density. Before/after:Some other minor changes include a tweaked map legend / controls panel:
And a reimplemented location filter interface, built with MapLibre and terra-draw. Before/after:
Fixes
Some changesets that
changeset-mapfailed to render are correctly handled bymaplibre-adiff-viewerThis also fixes a number of issues related to processing or rendering changesets with large bounding boxes.
Previously, there were also problems where OSMCha would incorrectly combine edits from multiple changesets together if they occurred in the same area and within a short time window. The new augmented diff service uses canonical information from the OSM API to determine which edits belong to each changeset, so it is not prone to this mistake.
Miscellaneous other issues that are fixed by this PR:
real-changesetsserviceKnown limitations
adiffs.osmcha.orghas augmented diffs for all changesets going back to about November 2024. If you try to load a changeset before that, OSMCha will fall back to using the Overpass API (much like it does today if a changeset is not found in thereal-changesetsbucket). This method is slower and subject to the limitations mentioned above (it will fail if the changeset's bounding box is very large, and may incorrectly combine changesets that happened in the same place at nearly the same time). I am planning to backfill data for older changesets in the near future.Mapbox Satellite,Mapbox Streets, andMapbox Darkbasemaps are no longer available. Bing aerial imagery is now the default basemap. We are looking into adding additional imagery providers. OpenStreetMap Carto is also still available as a basemap.