-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
An option to use a feature property as ID for feature state #8987
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cc13e2d
add ability to id by property for feature state
mourner e7f8b79
flow fixes
mourner 6c146ab
rework promoteId according to PR discussions
mourner ad09b9d
properly expose promoted ids in query methods
mourner bf12653
fix lint
mourner b7935e5
use state ids that can be cast as Float64 as is; update tests
mourner 8271bd0
promoteId: geojson support, better flow typing, v8 docs
mourner 3da8aa0
fix spec test
mourner 645608c
make sure id is provided in getFeatureState
mourner 8abdcd7
minor fixes after review
mourner ce19214
hash ids > MAX_SAFE_INTEGER
mourner 71d135f
overhaul promoteId validation, add render test
mourner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
use state ids that can be cast as Float64 as is; update tests
- Loading branch information
commit b7935e53278d9d826050cc020e1f69566043bc47
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this incorrectly handles strings that can be converted to javascript numbers but not javascript integers:
'9007199254740993'
'1.2'
'Infinity'
It also looks like users of this function expect integers but this can return a float if given a float. Is that ok because it should never be given a float?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially this was hashing all non-integer ids, but then I changed it because I thought there's no longer a need to have it limited to integer — those get saved in a Float64Array anyway, which supports decimals, values like
Infinity
, and values bigger thanMAX_SAFE_INTEGER
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, actually, in addition to the above, this function being exported is a leftover from earlier — how things get stored in the position map should be an internal detail so there won't be "users" of this. I'll remove the "export".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither javascript numbers (which are 64 bit floats) or Float64Array can store integers > MAX_SAFE_INTEGER safely. Both
'9007199254740993'
and'9007199254740992'
will look like the same id to this implementation. This might seem unlikely but we ran into this with iD editor because osm uses sequential 64 integers as ids.Similar problems theoretically exist with decimals but seem less likely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough — updated to hash as a string in case a numeric id is more than
MAX_SAFE_INTEGER
.