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

Calling C# OpenLocationCode.Encode with length 2 fails 'Illegal code length 2' #360

Closed
brewmanz opened this issue Aug 21, 2019 · 4 comments

Comments

@brewmanz
Copy link

brewmanz commented Aug 21, 2019

Calling C# OpenLocationCode.Encode with length 2 fails with 'System.ArgumentException: Illegal code length 2.'.
I am using NuGet package OpenLocationCode by Jon McPherson, v2.1.0
This is for both GeoPoint and lat/long.
A length of 2 is valid (https://github.com/google/open-location-code/blob/master/docs/specification.md), giving a 'box' 20 degrees across.
My test code is

        [TestMethod]
        public void UT_HD0099_Encode_LL()
        {
            string res;
            res = Google.OpenLocationCode.OpenLocationCode.Encode(12.123456789, 123.123456789, 11);
            Assert.AreEqual("7Q4544FF+99P", res);
            res = Google.OpenLocationCode.OpenLocationCode.Encode(12.123, 123.123, 4);
            Assert.AreEqual("7Q450000+", res);
            res = Google.OpenLocationCode.OpenLocationCode.Encode(12.123, 123.123, 2);
            Assert.AreEqual("7Q000000+", res);
        }

(I don't like your 'insert code' formatting)

@drinckes
Copy link
Contributor

NB: I edited your comment to improve the code formatting.

@drinckes
Copy link
Contributor

We don't maintain the C# code in this repository, could you please open an issue here?

@brewmanz
Copy link
Author

re-raised as requested at [https://github.com/JonMcPherson/open-location-code/issues/10]

@JonMcPherson
Copy link
Contributor

JonMcPherson/open-location-code#11 (comment)

This bug is also affecting the Java implementation and has been since the initial implementation almost 5 years ago. And since I originally ported this from the Java implementation, this bug made its way here and has been here from the start.
We should probably also create an Issue/PR to the canonical repository to fix the Java implementation and add these test cases.
See open-location-code/java/~/OpenLocationCode.java#L191

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

3 participants