google / open-location-code

Open Location Code is a library to generate short codes, called "plus codes", that can be used as digital addresses where street addresses don't exist.
https://plus.codes
Apache License 2.0
4.06k stars 472 forks source link

Fix encoding steps for grid digits #414

Closed NetworkNode closed 3 years ago

NetworkNode commented 3 years ago

The correct calculation for the least-significant digits is: 4*(latitude % 5) + (longitude % 4) This is the formula used in many different implementations: C++ Java TypeScript

The previous documentation had this incorrect instruction: (latitude % 5) * (longitude % 4)

RiverMersey commented 3 years ago

Hi,

Could you give some advise on how I could implement that into my issue #364 using MSAccess VBA, please?

Many thanks

RiverMersey commented 3 years ago

Hi,

Furthermore, https://github.com/google/open-location-code/blob/master/docs/specification.md still refers to multiplying together, whereas you say it should be added together.

Many thanks

NetworkNode commented 3 years ago

RiverMersey, You may have had the wrong idea from this pull request. I'm not changing the OLC spec, I'm just fixing the documentation, which was wrong. I'm also not particularly experienced with Open Location Code. I was looking around this project after following links from a reddit thread. When I read this part of the spec I noticed I was confused; the instructions didn't make sense. So I looked at some of the implementations, and all of them did the same computation, and it wasn't what the instructions said.

The public page is still wrong because my pull hasn't been merged yet.

I can't help you with your MSAccess script, as I know nothing whatsoever about MSAccess. I can suggest that you trust the existing code over the specification document. I updated my earlier comment with links. Your best bet is probably to find a language you're familiar with and translate that code into whatever language your script is in.

RiverMersey commented 3 years ago

@NetworkNode many thanks for your reply!

My only source of reference has been this github. You are entirely correct that the specifications/instructions here for the least significant bytes doesn't make sense - as I suggested in my #364 issue!

My MSAccess VBA code posted there was written by me based on what I've understood from the most significant bytes instructions here.

My hope was to find help in completing that script correctly in MSAccess VBA to include the least significant byte too!

Regards, @RiverMersey