1

I wonder how I can interleave float coordinates. This website describes how to do the interleaving part, but it is only for integers.

I have tried following method:

lat = 5.01, lng = 6.01

newLat = (5.01+90) * 100

newLng = (6.01+180) * 100

But it appears to not have the right bit sequence. Does someone know of a better way to represent lat and lng as a 32 bit sequence?

Community
  • 1
  • 1
  • What does "not have the right bit sequence" mean? What you tried looks valid, although it's only going to give you a resolution of 1/100 degree, which may be too coarse for your purposes (it's nowhere near accurate enough to identify a particular house, for example). You should choose a multiplicative factor such that the largest possible float value turns into an integer that is as close as possible to the maximum value the bit interleaving code can handle. – jasonharper Oct 25 '19 at 16:48
  • And how can I do that? You mean I should multiply by 2^16 if I am using 16 bits? Take a look at this one: https://www.slideshare.net/CCR_Inc/geomesa-on-spark-sql-extracting-location-intelligence-from-data?fbclid=IwAR1G4pBl36buEMbCYKvD6F0gcK47WINXzV9j7N_EQTM4VPYMLspMf4rIHTE I tried to do the same, but end up with something weird... –  Oct 26 '19 at 07:44
  • No, multiplying by 2^16 would cause an overflow of a 16-bit integer, since your float values can be greater than 1. 182 might work - that turns 360.0 into 65520, which barely fits. – jasonharper Oct 26 '19 at 12:46
  • So what should the formula look like? –  Oct 28 '19 at 08:26

0 Answers0