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

Automatically generate unique feature ID #614

Closed
ryanbaumann opened this issue Jul 26, 2018 · 5 comments
Closed

Automatically generate unique feature ID #614

ryanbaumann opened this issue Jul 26, 2018 · 5 comments

Comments

@ryanbaumann
Copy link

ryanbaumann commented Jul 26, 2018

Feature Request

Add a Tippecanoe option to automatically generate an integer unique feature id. --generate-id.

Ideal scenario

  • If a geojson source contains an id value, use the specified id value in the tiles generated in Tippecanoe
  • If a geojson source does not contain an id value, automatically generate one by default.
  • Expose a Tippecanoe option to disable automatic feature id generation if it doesn't exist
  • Expose an option to promote a property value from a feature to an id value, just like geojson-vt allows Åuto-generation and promotion options for Feature Ids geojson-vt#109 cc/ @asheemmamoowala

Use case

FeatureStates in Mapbox GL require feature id values to function. Currently, Tippecanoe will not generate feature ID values for a dataset, a user must create feature id values in their geojson data source before passing to Tippecanoe.

cc/ @ericfischer

Reference: mapbox/mapbox-gl-js#6974

@e-n-f
Copy link
Contributor

e-n-f commented Jul 26, 2018

Thanks for the idea. Thinking out loud, there are basically two ways that this could go:

  • Assign IDs sequentially
  • Assign IDs by a hash of the feature data

Sequential assignment is probably preferable (and would generate smaller tiles), but has the complication that when reading in parallel with -P there are discontinuities between the sequence numbers being assigned by each reader thread, so the IDs would not be stable from one run to the next if assigned at that time. It is also sensitive to the input ordering in general, so if features are inserted or deleted in the source data, the generated IDs will be completely different when the edited data set is retiled.

Hash assignment is stable both across runs and across feature insertions and deletions, but has the risk of assigning the same ID to multiple features that happen to hash the same, and the certainty of assigning the same ID to duplicated features within the input.

They both have the problem of how to avoid accidentally reusing an ID that was also assigned manually.

So I think this will have to be an additional stage in between parsing and tiling, after the complete set of manually-assigned IDs is known, and the complete feature sequence is known. I'm still not sure whether it is better to hash (with increments when duplicate hashes are detected) or to use an incrementing counter.

@e-n-f
Copy link
Contributor

e-n-f commented Jul 26, 2018

#615 adds the most basic --generate-ids option (using the input feature sequence for the ID), with the disclaimer that the IDs are not stable and that their format may change in the future.

@benydc
Copy link

benydc commented Jul 28, 2018

@ericfischer when can I expect to use this? I tried installing with brew but gives me version 1.30.1 as latest.

@e-n-f
Copy link
Contributor

e-n-f commented Jul 30, 2018

Sorry, I only just tagged the release (https://github.com/mapbox/tippecanoe/releases/tag/1.30.3). It looks like https://github.com/Homebrew/homebrew-core/blob/master/Formula/tippecanoe.rb gets updated by a bot for new releases, but I'm not sure how long that cycle takes.

@e-n-f
Copy link
Contributor

e-n-f commented Jul 31, 2018

Looks like this is in the homebrew version now.

@e-n-f e-n-f closed this as completed Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants