0

If I'm reading the UTFGrid spec right, you can only have 65,501 different interactive features. Or more precisely, every feature needs a unique ID in the range 0-65501.

TileMill uses UTFGrid for its interactivity, so this limit seems to apply. It shows up as non-parseable JSON being generated, JSON handling exceptions etc.

So, what ID can you use for OpenStreetMap features (loaded into a PostGIS database), given that the osm_id column will have values in the hundreds of millions.

2 Answers 2

2

If you want a unique id per row it will be easiest to use the row number.

 SELECT (row_number() OVER())-1 AS id, way, (...)

That way you'll get incrementing id starting from 0 and won't have to worry about collision.

1
  • Well, sure, but that only works if you want the right solution, instead of my hacky workaround. Dammit. :) Apr 6, 2015 at 23:19
1

I found a simple workaround that seems to work ok. Make a PostGIS layer with an extra column like this:

(SELECT way,....
osm_id % 65500 AS tinyid
FROM planet_osm_point) p

Then set tinyid as the layer's "Unique key field".

That is, take the actual osm_id modulo 65500 to always produce a value in the range 0-65500. This will occasionally cause errors if two features within the same tile have the same tinyid.

(There might be better ways?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.