paulmach / orb

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

Missing check if tile projected coordinates are in larger extent #3

Closed karsten42 closed 6 years ago

karsten42 commented 6 years ago

In order to use the generated vector tiles as a source for mapbox all coordinates in a tile must not exceed a certain extent. (https://www.mapbox.com/mapbox-gl-js/style-spec/#sources-vector)

https://github.com/paulmach/orb/blob/1f34bf6ee9935efca353b8cc0e06396d347cf836/encoding/mvt/projection.go#L27-L31 Maybe the projection could also return if the point should be included or not?

Was this check left out by choice?

paulmach commented 6 years ago

thanks for taking a close look at this, should probably return an error when marshaling. Interestingly I don't see any reference to these bounds in https://github.com/mapbox/vector-tile-spec

I'm on vacation this week, will take a closer look into this next week.

paulmach commented 6 years ago

Okay, so I had some time to think about this. This requirement seems to be just for mapbox gl and not necessarily something that's required by the spec. Thus I think it should be left out here.

I think the user should clip the geometry to a little more than the tile bound. You can use the clip sub-package to do that.

karsten42 commented 6 years ago

Fair enough. I think it would make sense to have this functionality on the layers then, see #5. What do you think?

paulmach commented 6 years ago

merged #5 thank you.