mapbox/geojson-vt

Why should project coordinates between [0,1] first?

YanZuH opened this issue · 2 comments

I don't quite understand why the coordinates should be projected between [0,1]x[0,1].
Can someone tell me,please.

`def project_x(x):
return x / 360. + 0.5

def project_y(y):
sin = math.sin(y * math.pi / 180.)
if sin == 1.:
return 0.
if sin == -1.:
return 1.
y2 = 0.5 - 0.25 * math.log((1. + sin) / (1. - sin)) / math.pi
return 0 if y2 < 0. else (1. if y2 > 1. else y2)`

It's just a convention, to easily convert it into tile coords later. 0..1 is also a good range for retaining precision in double floating point.

It's just a convention, to easily convert it into tile coords later. 0..1 is also a good range for retaining precision in double floating point.

thanks!