mapbox / mapbox/mapbox-gl-js

Feature ids data loss for values > 2^53

Open
#7,020 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Feature ids are being represented by number type in Javascript where the Number.MAX_SAFE_INTEGER value is 2^53 - 1 (MDN)

https://github.com/mapbox/mapbox-gl-js/blob/4761e0b6cdfbe91826698876ab8659babbba1ad9/flow-typed/vector-tile.js#L18

The vector tile spec defines feature ids to be unsigned 64-bit integers.
https://github.com/mapbox/vector-tile-spec/blob/26b7823b16df1e15f55adb44243a3896acb7b804/2.1/vector_tile.proto#L32

Any feature ids >Number.MAX_SAFE_INTEGER will lose precision when used in mapbox-gl-js

Expected Behavior

mapbox-gl-js fully supports 64-bit unsigned integer values for feature id

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with flow-typed/vector-tile.js at line 18 and compare its feature-id type with the vector tile spec's unsigned 64-bit definition. Trace the feature-id path in mapbox-gl-js and add coverage for values above Number.MAX_SAFE_INTEGER. Done means feature IDs retain their exact unsigned 64-bit values.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.