[GIS] Openlayers feature identification

openlayers

In OL4 (or, I guess, any version >=3.0), all features have an undefined id unless it is set by any mean. They do have, however, an ol_uid value (as far as I could understand, all ol objects have such property), that seems a "random" number set automatically by openlayers. In order to store feature styles in memory, it is safe to use this variable as a map index? I am doing it already, but want to be sure that there's "no chance" of collision.

Best Answer

As they said in the comment, there'll be no collision.

https://github.com/openlayers/openlayers/blob/4a2d711fb77703ef708c596452775f4d0eebaf11/src/ol/index.js#L112-L114

Unique IDs are generated as a strictly increasing sequence.

Related Question