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

Decode result not correct for negative values. #3

Open
GoogleCodeExporter opened this issue Apr 2, 2016 · 0 comments
Open

Decode result not correct for negative values. #3

GoogleCodeExporter opened this issue Apr 2, 2016 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1.
        double lat = -77.9614596407155;
        double lon = -139.96324813171648;
2. try to encode this to a string
3. try to decode the string to lat & lon

What is the expected output? What do you see instead?
The latter one is the difference.

-77.9614596407155:70.14700636267662
-139.96324813171648:-83.69167774915695

What version of the product are you using? On what operating system?
Vista/JDK 1.6

Please provide any additional information below.

Test code:

    @Test
    public void testEncode_Accuracy_Mistake() {
        // -77.9614596407155:70.14700636267662
        // -139.96324813171648:-83.69167774915695
        double lat = -77.9614596407155;
        double lon = -139.96324813171648;

        String geohash = geohashUtil.encode(lat, lon);
        Assert.assertNotNull(geohash);

        double[] result = geohashUtil.decode(geohash);
        if (Math.abs(lat - result[0]) > 0.00001
                || Math.abs(lon - result[1]) > 0.00001) {
            System.out.println("============");
            System.out.println(lat + ":" + result[0]);
            System.out.println(lon + ":" + result[1]);
        }
    }

Original issue reported on code.google.com by [email protected] on 9 Jun 2011 at 3:54

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

No branches or pull requests

1 participant