Closes #5970

### Description
Created a new endpoint `/changeset/:id/download.json` which returns the 
`osmChange` in a JSON format in addition to the existing XML endpoint.

For example:

```jsonc
{
  "version": "0.6",
  "generator": "OpenStreetMap server",
  "copyright": "OpenStreetMap and contributors",
  "attribution": "http://www.openstreetmap.org/copyright",
  "license": 
"http://opendatacommons.org/licenses/odbl/1-0/",
  "osmChange": {
    "create": [
      { "type": "node", "id": 7, "lat": 
-36.8359797, "lon": 174.7683977, "timestamp": 
"2025-05-01T09:00:52Z", "version": 1, 
"changeset": 2, "user": "kylenz_testing", 
"uid": 1 }
    ],
    "modify": [
      { "type": "way", "id": 2, 
"timestamp": "2025-05-01T09:00:52Z", "version": 
2, "changeset": 2, "user": "kylenz_testing", 
"uid": 1, "nodes": [5, 6, 7, 5], "tags": { 
"landuse": "industrial" } }
    ],
    "delete": [
      { "type": "node", "id": 4, 
"timestamp": "2025-05-01T09:00:52Z", "version": 
2, "changeset": 2, "user": "kylenz_testing", 
"uid": 1, "visible": false }
    ]
  }
}

```

**Important:** This proposed format is different to the format proposed in 
https://github.com/zerebubuth/openstreetmap-cgimap/pull/407 They key different 
is that we keep it simple like the current XML format, instead of adding a new 
`action` property to every node/way/relation. 
[Comparison](https://github.com/mmd-osm/openstreetmap-cgimap/blob/89abe65e5231959ae5ad4fa16aa479dd44d48505/test/test_apidb_backend_changeset_uploads.cpp#L2596-L2622)


In my opinion, this format is better because:
* it's consistent with the current XML format
* It doesn't use a top-level array. top-level arrays are annoying because 
they prevents other properties from being added in the future. Some apps 
already add custom properties to the XML 
file<sup>[[1]](https://forum.osm.org/t/108670)</sup>
* It's more organised and understandable since it doesn't add any new 
properties to the `Node`/`Way`/`Relation` objects/classes.

### How has this been tested?
- Tested locally with a fresh database, using changesets that 
create+modify+delete multiple nodes+ways+relations
- Unit tests


You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/5973

-- Commit Summary --

  * Implement JSON support for the changeset download API

-- File Changes --

    M app/controllers/api/changesets/downloads_controller.rb (1)
    A app/views/api/changesets/downloads/show.json.jbuilder (7)
    M test/controllers/api/changesets/downloads_controller_test.rb (86)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/5973.patch
https://github.com/openstreetmap/openstreetmap-website/pull/5973.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5973
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to