tilezen / mapbox-vector-tile

Python package for encoding & decoding Mapbox Vector Tiles
MIT License
240 stars 47 forks source link

Add optimisation function. #108

Closed zerebubuth closed 5 years ago

zerebubuth commented 5 years ago

Add optimisation function: optimise_tile, called with a string of bytes, will decode it, optimise it and re-encode it. The optimisations are:

Both of these together reduce tile size by a few percent (I've seen 1-4% in my tests).

NOTE: I'm not sure what's up with the test failure. It seems to fail when run as python setup.py test, but not when the tests are run explicitly (e.g: for i in tests/test_*.py; do j=`echo $i | sed "s,\.py,,;s,/,\.,"`; python -m unittest $j; done). As far as I can tell, it seems to be something to do with unittest "manually" loading modules and ending up loading something from protobuf twice, which it doesn't like. Perhaps related to https://github.com/protocolbuffers/protobuf/issues/3276. In any case, seems like an upstream bug, and I haven't figured out a work-around other than running the tests individually.