Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

id attribute is not set if it is 0 #1877

Open
strech345 opened this issue Mar 28, 2020 · 5 comments
Open

id attribute is not set if it is 0 #1877

strech345 opened this issue Mar 28, 2020 · 5 comments
Labels

Comments

@strech345
Copy link

@strech345 strech345 commented Mar 28, 2020

test with turf.lineString(<coords>,{},{id:0})
on v.5.1.6

if id is 0 the id field is missing

@rowanwins
Copy link
Member

@rowanwins rowanwins commented Mar 30, 2020

Thanks for the bug report @strech345

@river-honer
Copy link

@river-honer river-honer commented Apr 12, 2020

If this is still an open issue, I would like to tackle it as it seems like a good first contribution to this project.

@river-honer
Copy link

@river-honer river-honer commented Apr 12, 2020

I investigated this issue, and it's solved in 6.2.0-alpha.1.

To test, I added an id of 0 to the linestring used in the unit tests. Here's the created feature object with the id attached:

{
  type: 'Feature',
  id: 0,
  properties: { name: 'test line' },
  geometry: { type: 'LineString', coordinates: [ [Array], [Array] ] }
}

If this needs more work, I can be involved :)

@morganherlocker
Copy link
Member

@morganherlocker morganherlocker commented Apr 12, 2020

This looks good. Just for reference, here is the section of the GeoJSON spec that backs this up:

https://tools.ietf.org/html/rfc7946#section-3.2

If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of the Feature object with the name "id", and the value of this member is either a JSON string or number.

@river-honer
Copy link

@river-honer river-honer commented Apr 14, 2020

@morganherlocker If the bug exists in the latest shipped released but is fixed in the current master, should the issue be closed? Or should it be fixed in a patch version? If there needs to be a fix in a patch, I would be able to do so and update the tests for it, just would appreciate some direction :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.