paulmach / orb

Types and utilities for working with 2d geometry in Golang
MIT License
886 stars 103 forks source link

Compressed mvt data is not handled #62

Closed CarbonHeartDev closed 2 years ago

CarbonHeartDev commented 3 years ago

Some packages such as Tegola generates mvt tiles which are already compressed in gzip format, when I try to unmarshal these tiles with orb I get a generic EOF exception and that con lead to big wastes of developer time in debugging therefore I believe that a detection of compressed tiles (reading the first bytes of the input is enough to detect the compression) and a clear exception can be really helpful to developers which uses this package, even an implicit decompression feature can be implemented but I believe that leaving the eventual decompression of the tiles to another library while keeping this library focused towards parsing and processing of geospatial data is more respectful of the single responsibility principle.

In any case I'd be happy to contribute to the library implementing the detection and the eventual implicit decompression of compressed vector tiles.

paulmach commented 3 years ago

Hi,

This comes up from time to time. I definitely think a better error would be good and help a lot of people. There is already a UnmarshalGzipped helper function if you know it's gzipped, but as you said, sometimes it's hard to know.

PRs welcome.

paulmach commented 2 years ago

Fixed by returned a special error, if the data is found to be gzipped. https://github.com/paulmach/orb/pull/64