-
Notifications
You must be signed in to change notification settings - Fork 479
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
Short codes with padding are unintentionally considered valid #273
Comments
ping @drinckes |
Thanks for this, I'm going to take a look at it in the next couple of days. |
This PR ^ resolves this issue |
Hey, yes, sorry for the delay Jon. I'm going to let @drinckes review this, as it involves changing the spec. |
Yes, my fault. I'm going to send this today to the public mailing list as well as some other interested parties to give them a chance to provide feedback. Anything we do will require a modification to the spec, even if it's just clarification, so what I propose is that I summarise the questions here, we get some feedback, and then proceed from there to a consensual decision. Question: What should the spec say about:
RecommendationI recommend that the answer to all of these is yes, with the requirement that the resulting code always includes a minimum of two significant digits. So for example, shortening 8FVC0000+ with relation to Zurich would return VC0000+. Shortening 8F000000+ with relation to Zurich will return 8F000000+ (because it must have two digits). This basically says that you can shorten (or attempt to shorten) any code with relation to a location, and you the recover method will return the original code. The number of digits doesn't make this either work/not work. Comments please! If I receive comments from interested parties without github accounts I'll post them here under my name. |
I think a suggestion could be added to the spec that codes SHOULD NOT be padded and shortened at the same time: what's the use case for "VC0000+ Zurich", if that code describes an area much bigger than Zurich itself (~10% the size of whole Switzerland) and if the code isn't even shorter than the full code "8FVC0000+"? That said, I don't see any reason for artificially removing the ability to recover a short code with padding while that is strictly possible. It should just be ensured that padding characters are kept intact while recovering a full code. @JonMcPherson mentioned that the Java implementation recovers short code "2300+" to "????23GG+". Inflating a code's precision like that seems like a bug to me. This bug is currently shared by maps.google.com, by the way. Searching for "8FVC0000+" on Maps leads to a map pin at "GG22+22, Niederglatt, Switzerland". |
Yea after giving it more thought, I think that the better option is to not restrict and to explicitly allow padded codes (with 2, 4, or 6 digits) to be shortened and recovered. I'm all for avoiding unnecessary exceptional cases and having one less precondition or thrown exception. However, I think if the API spec for The API spec states:
This makes the return type ambiguous as it can be either a short or full code. Because of this ambiguity, the caller has to know to check if the returned code This is why in the v2.0 release of my C# implementation, I refactored the class structure so that Additionally, there are inconsistencies in how the different implementations handle this. The Java implementation does not follow the spec and actually throws an IllegalArgumentException stating that the reference point is too far from the center of the code area when the code couldn't be shortened. Whereas most other implementations follow the spec and just return the original full code when it couldn't be shortened. I think that if |
In my opinion, the answer is yes to all three, and without restriction (no minimum significant digits requirement). For the reason that they are still meaningful, even if they may not always be considered particularly useful. E.g. Case in point: I really like that the spec today doesn't set short codes to be say "exactly 6 digits" (e.g. RG9C+VH). While this is the common size of shortened code we see (as it maps nicely to greater city areas), other use-cases for even shorter codes, say at a neighborhood level (e.g. 9C+VH), are still viable. This flexibility allows people to innovate on top of plus codes, taking advantage of their useful inherent properties. I also prefer this approach as it keeps the spec simpler and with less edge cases. |
If the proposal is that it is acceptable to remove all significant digits from these codes, then is it also acceptable to remove all significant digits from 8FVC9G8F+6W, or the first 10 digits from 8FVC9G8F+6WG? If yes, then we will need to decide how to represent these currently invalid strings (00000000+00G or just +00G). If no, then shortening padded codes is introducing a new edge case anyway. Shortening the codes is done to make them easier for people to use in the context of addressing, by reducing the number of digits someone has to remember. I think we risk defining a mathematically elegant but not practically useful solution here. |
My approach would be similar to your comment on the uneven length codes: "be conservative in what you do, be liberal in what you accept from others", which I would apply in a way that "do" are the codes we generate in the API, and "accept" are codes that are considered valid according to the spec (which is possibly not the original intent of the phrase). I don't honestly see the harm in accepting as valid a code that can be meaningfully resolved. As a straw-person, codes like I totally agree that the API should not by default generate codes that are hard to use, I think this kind of specialty use would be left for experts to determine. The API design for short codes already exhibit this principle. |
@JonMcPherson Hi, this question has nothing to do with this issue. I was trying to find a way to contact you to ask you regarding the parse live query for .NET and Unity. I downloaded your repo and placed them within my Assets folder but I tried to create a parse live query client and connecting it to the URI of the parse server (using the API Back4App) but when testing with a test callback I tried to log that I have entered the callback but it did not work. So I wanted to ask you, is there maybe something missing within the code and it is not a finished project yet or could I possibly be doing something wrong? |
Recommended tag: specification |
This issue, and #462, is fixed by #463 It is specified:
This incorporates existing specifications at https://github.com/google/open-location-code/blob/main/docs/specification.md#short-codes. |
Awesome. I'll update the C# implementation after the Java implementation is updated to use as a reference for consistency. |
From the responses above and the response in the mailing list:
Are all a yes. I personally don't think we want to entertain codes with padding after the plus though e.g. @JonMcPherson comment re We also need to address the bug in the recovery where some implementations are inflating the precision. That's a lot for a single issue, and it's drifted a bit from the earlier comments, so I've created separate issues for the spec and
Thanks everyone for your patience and contributions! Let me know if I missed anything. |
The Open Location Code specification mentions that full codes with padding cannot be shortened, which would imply that a short code with padding is invalid. However, the API reference for code validation does not specify anything about allowing or disallowing short codes with padding. And as such, most (if not all) of the implementations will determine short codes with padding as being valid (and short), and even allow them to be recovered. Because of this gap in the specification there are inconsistencies and unexpected results between the different implementations and how short codes with padding are recovered.
Theoretically, recovering a short code with padding can sensibly result in a full code with the same padding. Some implementations (such as JavaScript) do maintain the padding when recovering shortened codes as one might expect. Whereas other implementations (such as Java) do not and always result in a full code with 8 digits (non-padded) where the digits that replace the padding are determined by the recovered coordinates which may be unexpected.
Example:
To resolve this issue, I think the following needs to be done:
shorten()
spec), or explicitly allow it if it makes sense and can reasonably be recovered/shortened.test_data/validationTests.csv
to include a padded short code to test that all implementations now conform to the updated spec and handle padded short codes appropriately.I think the easiest and probably best option is to just explicitly disallow padded short codes to be consistent with disallowing shortening of padded full codes. This would also indirectly resolve these inconsistencies assuming that short code validation is fixed in each implementation.
The text was updated successfully, but these errors were encountered: