Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apparent geoToH3 or H3ToGeo bug on master #38

Closed
travisbrady opened this issue Mar 26, 2018 · 9 comments
Closed

Apparent geoToH3 or H3ToGeo bug on master #38

travisbrady opened this issue Mar 26, 2018 · 9 comments

Comments

@travisbrady
Copy link
Contributor

I used geoToH3 to encode the coordinates for NYC and then ran the H3 hex string through H3toGeo and got a confusing result.
This is with a fresh clone of master built per readme instructions and running on a Mac.

$ ./bin/geoToH3 12
40.7128 -74.0060
8c2a107289061ff

Then

$ ./bin/h3ToGeo
8c2a107289061ff
40.7127470097 285.9940373051

Unless I misunderstand the purpose of these tools, 285.9940373051 is obviously an illegal value and far from the expected -74.0060.

$ uname -a
Darwin HA002727 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64
@sahrk
Copy link

sahrk commented Mar 26, 2018

285.9940373051 is the same longitude as -74.0060. h3ToGeo gives longitude values in the range 0-360 degrees.

@travisbrady
Copy link
Contributor Author

Ahh, I see. Still somewhat confusing to me as I'd typically expect ThingToInt(IntToThing(blah)) == blah.

Does H3 provide any docs or functions for these sorts of conversions? I think many people often use latitudes in the range -180 to 180, so this kind of thing would tend (I'd think) to confuse other users too. But I'll close for now.

@dfellis
Copy link
Collaborator

dfellis commented Mar 27, 2018

I will note that the bindings (that haven't been released, yet, hi again @isaacbrodsky :) ) do convert back to -180 -> 180 (and -90 -> 90 for latitude) because that's what people tend to expect. I don't recall why we haven't pushed this down to the C code, but I do know it will cause some churn with the test suite.

@travisbrady
Copy link
Contributor Author

@dfellis good to know as I'm currently writing some bindings of my own (in OCaml). I expect to have them on github in the next week or so.

@isaacbrodsky
Copy link
Collaborator

I'm OK with changing the C library/applications/examples to return negative angles, since that's what the bindings do anyways. (hi @dfellis :) ) Or, we should add this to the bindings documentation.

@travisbrady Please feel free to open a PR to add your bindings to the bindings list when you feel they're ready.

@nrabinowitz
Copy link
Collaborator

I'd support updating the C lib here. I think it subverts user expectations, and agree with @travisbrady's point that it breaks assumptions about round-trip stability.

@sahrk
Copy link

sahrk commented Mar 29, 2018

I should point-out that, unless you limit geoToH3 to only accept longitudes in the range +/-180 (which I don't recommend), then geoToH3/h3ToGeo can't be completely round-trip stable, in the sense that the user will necessarily get back their input longitude value in the original input range.

@nrabinowitz
Copy link
Collaborator

nrabinowitz commented Mar 30, 2018 via email

@gacafe
Copy link

gacafe commented Jun 6, 2019

Resolved this generally... the input was incorrect (130 is not a lat), but bit concerning that the two libraries give different results for the same input.
There is a problem still.
Using the example, I expect h3_to_geo(geo_to_h3(lat,lon), resolution) to return the original lat,lon input, or something quite nearby... If I use the example, this is true, but if I do it in Australia, its not true -- the [-180,180] bounds are respected but the answer is shifted by 180:

11:37 AM gacafe ∈ h3 (master) ./bin/geoToH3 -r 15
130.90938479800002 -12.365644588
8f16c6d624a25a8
11:38 AM gacafe ∈ h3 (master) ./bin/h3ToGeo      
8f16c6d624a25a8
49.0906178199 167.6343623402

Using the Python library --

>>> h3_address = h3.geo_to_h3(37.3615593, -122.0553238, 15)
>>> hex_center_coordinates = h3.h3_to_geo(h3_address)
>>> hex_center_coordinates
[37.36156313952111, -122.05532505846305]
>>> h3_address = h3.geo_to_h3(130.90938479800002, -12.365644588,15)
>>> hex_center_coordinates = h3.h3_to_geo(h3_address)
>>> hex_center_coordinates
[-49.09061440581596, -12.36565153299568]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants