wookay / H3.jl

H3.jl ⬡ provides a Julia version of H3, Hexagonal hierarchical geospatial indexing system. https://github.com/uber/h3
Other
25 stars 4 forks source link

geoToH3 produces incorrect cell ids #10

Closed mfrawley closed 4 years ago

mfrawley commented 4 years ago

Minimal reproducible example: Python H3 lib

a, b = h3.geo_to_h3(53.5495,9.9599, H3_RES), h3.geo_to_h3(53.5492,9.93109, H3_RES)

h3.h3_distance(a,b), a, b

produces: (0, '851f1533fffffff', '851f1533fffffff')

This library produces:

a, b = geoToH3(GeoCoord(53.5495,9.9599), H3_RES), geoToH3(GeoCoord(53.5492,9.93109), H3_RES)

h3Distance(a,b), a, b

(10, 0x08596a833fffffff, 0x08596f4cffffffff)

These points are very close to one another...am I doing something wrong or is this just a really big hairy bug?

wookay commented 4 years ago
  struct GeoCoord
      lat::Cdouble
      lon::Cdouble
  end

  latitude/longitude in radians

so

using H3.API
H3_RES = 5
a, b = geoToH3(GeoCoord(deg2rad(53.5495), deg2rad(9.9599)), H3_RES), geoToH3(GeoCoord(deg2rad(53.5492),deg2rad(9.93109)), H3_RES)
@info h3Distance(a,b), a, b

[ Info: (0, 0x0851f1533fffffff, 0x0851f1533fffffff)

mfrawley commented 4 years ago

Thanks for the quick reply! I missed the comment, I even read the code and oversaw it..had a feeling I was doing something wrong. Still maybe you could add that example to the README to prevent others getting lost in the woods.

wookay commented 4 years ago

thanks to this issue.