Closed snodnipper closed 6 years ago
Good link. I think I'd need to swap the ID placement into the map above the other properties as well instead of at the end of the function to get the desired effect? Let me think about a solution here, in the between time you can copy that class into your own that implements the ITagConverter interface.
I have had a quick look over with @AndrewRadburn.
We thought it might be easier if I introduce a Feature class that contains JTS geometry.
Specifically, the feature would contain an ID of Java type Long at the class level as per specification, which may be null.
We then believe we can get rid of the id
parameter from toUserData
as any user attribute with an ID might be completely independent (e.g. fid, toid for feature ID or topological ID etc.).
https://github.com/wdtinc/mapbox-vector-tile-java/blob/6865a1654d8d21256f2ce47ca13b9af66e3054b2/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/TagKeyValueMapConverter.java#L62
The structure would therefore be:
The difference from Protobuf generated code is that the above would be easy to work with and has JTS geometries. Feature.getAttributes
could, for instance, be redirected to Geometry.getUserData
to maintain backwards compatibility for the moment.
LinkedHashMap would therefore satisfy the contract of keys being ordered according to insertion.
How does that sound to you?
If ok, I could update https://github.com/wdtinc/mapbox-vector-tile-java/pull/8 with the Feature class.
So the purpose of the com.wdtinc.mapbox_vector_tile.adapt.jts package is to translate JTS to/from MVT data. I think the interest in receiving ordered maps out of a MVT into JTS objects is something easy for me to grasp and something that I can put built-in support for. I'll comment on the layer/ feature / layergroup ideas in your pull request.
Merged via #10
Available in 2.0.0 in maven central.
From working with the library, the TagKeyValueMapConverter does not preserve the ordering of attributes.
It would be great if we could use, say, a LinkedHashMap so that attributes look consistent.
For example, geo analysts like to see:
without the order of the above being arbitrary.
For tests I created a TagKeyValueMapConverterOrder class but perhaps the overhead isn't so bad for default use?
https://github.com/wdtinc/mapbox-vector-tile-java/blob/6865a1654d8d21256f2ce47ca13b9af66e3054b2/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/TagKeyValueMapConverter.java#L71