Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Changesets without closed_at property throw Cannot read property 'toString' of null error #240

Open
1 of 3 tasks
jguddas opened this issue Aug 13, 2021 · 1 comment · May be fixed by #262
Open
1 of 3 tasks

Changesets without closed_at property throw Cannot read property 'toString' of null error #240

jguddas opened this issue Aug 13, 2021 · 1 comment · May be fixed by #262

Comments

@jguddas
Copy link

jguddas commented Aug 13, 2021

  • I'm submitting a Bug
  • 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

to: cs.closed_at || null,

(null).toString() does not work
c.to.toString() +

Possible solutions:

  1. Better error message
var data = getDataParam(changeset);
+ if (!data.to) {
+   new Error('Changeset has no closed_at property!')
+ }
  1. Not returning null.
- to: cs.closed_at || null,
+ to: cs.closed_at || …,
@zstadler
Copy link

zstadler commented Oct 25, 2023

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

function getDataParam(c) {
return (
'[out:xml][adiff:%22' +
c.from.toString() +
',%22,%22' +
c.to.toString() +
'%22];(node(bbox)(changed);way(bbox)(changed);relation(bbox)(changed););out%20meta%20geom(bbox);'
);
}

zstadler added a commit to zstadler/changeset-map that referenced this issue Oct 25, 2023
Resolve osmlab#240 using the one-timestamp variant of the Overpass `adiff` statement if the `closed_at` property of the changeset is not set. For example
```
[adiff:"2023-10-25T07:00:00Z"]
```

Also, simplify the overpass query using the new-ish [`nwr` syntax](https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#The_Query_Statement)
@zstadler zstadler linked a pull request Oct 25, 2023 that will close this issue
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants