osmlab / changeset-map

Visualise a changeset on a map
http://osmlab.github.io/changeset-map/
ISC License
34 stars 12 forks source link

Change OSM API `/changeset/:id.json` endpoint response parsing to handle new JSON schema #265

Closed jake-low closed 2 months ago

jake-low commented 2 months ago

The OSM API /changeset/:id.json endpoint changed schema recently, breaking the OSMCha frontend. This PR attempts to resolve that.

Normally I would test this by running yarn link, and running the OSMCha frontend locally with my modified version of the changeset-map module. But currently I'm unable to test the OSMCha frontend locally due to an ongoing and unrelated issue with OSM API login. So in lieu of that, I tested this from the REPL.

Before:

> await query(133061984, { osmApiBase: "https://api.openstreetmap.org/api/0.6" })
Uncaught TypeError: Cannot read properties of undefined (reading '0')

After:

> await query(133061984, { osmApiBase: "https://api.openstreetmap.org/api/0.6" })
[
  {
    id: 133061984,
    uid: 8794039,
    user: 'jake-low',
    from: '2023-02-26T22:48:32.000Z',
    to: '2023-02-26T22:48:34Z',
    comments: [ [Object], [Object], [Object], [Object] ],
    bbox: {
      left: -121.6737604,
      bottom: 47.4675822,
      right: -121.4541396,
      top: 47.5557535
    }
  },
  { osmApiBase: 'https://api.openstreetmap.org/api/0.6' }
]
batpad commented 2 months ago

@jake-low just eye-balling, this looks good to me!