changeset-map
changeset-map copied to clipboard
Changesets without closed_at property throw `Cannot read property 'toString' of null` error
- I'm submitting a Bug
- [x] bug report
- [ ] ~~feature request~~
- [ ] support / question
Brief Description
Loading of some changesets fails.
What is the current behaviour, (attach relevant screenshots) ?
TypeError: Cannot read property 'toString' of null
What is the expected behaviour ?
A better error message or maybe no error at all.
When does this occur ?
When the changeset has no closed_at property.
How do we replicate the issue ?
Example changeset: https://www.openstreetmap.org/api/0.6/changeset/109618303.json?include_discussion=true
Other Information / context:
c.to can be null
https://github.com/osmlab/changeset-map/blob/df4dbcbf9d65be5d0947e9853eb94957ca6e2f5c/lib/query.js#L21
(null).toString() does not work
https://github.com/osmlab/changeset-map/blob/df4dbcbf9d65be5d0947e9853eb94957ca6e2f5c/lib/getChangeset.js#L79
Possible solutions:
- Better error message
var data = getDataParam(changeset);
+ if (!data.to) {
+ new Error('Changeset has no closed_at property!')
+ }
- Not returning null.
- to: cs.closed_at || null,
+ to: cs.closed_at || …,
A way to provide a map for an open changeset is using an appropriate Overpass query with the one-timestamp variant of the adiff statement, e.g.,
[adiff:"2012-09-14T15:00:00Z"]
This can be done by
'[out:xml][adiff:%22' +
c.from.toString() +
- ',%22,%22' +
- c.to.toString() +
+ (c.to ? '%22,%22' + c.to.toString() : '') +
'%22];(node(bbox)(changed);way(bbox)(changed);relation(bbox)(changed););out%20meta%20geom(bbox);'
at https://github.com/osmlab/changeset-map/blob/1b5cbaac9c3d73653a54f0aa11f339fa58cc5719/lib/getChangeset.js#L81-L89