Git Product home page Git Product logo

Comments (1)

WilliamDenniss avatar WilliamDenniss commented on May 5, 2024

I am unable to obtain the full code with the short code only and I think it is awful!

OpenLocationCode.recoverNearest(shortcode: "CWC8+Q48", referenceLatitude: 37.4, referenceLongitude: -122.0)

I would have loved to use just the short code following your comment below via curbmap/OpenLocationCode-swift#1

3/ I also included ports of the recover nearest implementation. I like the short-code feature of OLC, it's useful to be able to give someone in the same city as you a shorter 6 digit code for locations within the city ☺️. Some apps like Google Maps already highlight the short code characters to speed up communication time (e.g. when you're telling someone where you are on the phone).

How this works is that to recover the short code that is within the same city area as the user, is to use the short code, and the user's current location (e.g. obtained from the GPS).

Say that the user is at 37.420950, -122.095696, and you tell them to go to CWC8+Q48

You would call the API like so, supplying the short code and their location
OpenLocationCode.recoverNearest(shortcode: "CWC8+Q48", referenceLatitude: 37.420950, referenceLongitude: -122.095696)

And it will recover it to the full code 849VCWC8+Q48 at which point they can navigate to the location.

You can try this out in Google Maps today by searching for a short code. It will use the center of the map you are currently looking at to resolve it. If someone gives you a short code in the same city as the one you are viewing, it should resolve correctly.

I know very well that many (if not all) people cannot memorize their coordinates. All they need is memorize/capture either the full or the short code and give same to others to get their address.

My second issue is the fact that OpenLocationCode.decode(code: String) seems to be producing wrong coordinates. Take the following as a case study:

Current Location

latitude CLLocationDegrees 6.6073411563472861
longitude CLLocationDegrees 3.3226713258804024
code String? β€œ6FR5J84F+”

Decoded location using the (codeLength: 8) full code generated above

latitudeLo Double 6.6049999999999898
longitudeLo Double 3.3225000000000193

latitudeHi Double 6.6074999999999875
longitudeHi Double 3.3250000000000171

latitudeCenter Double 6.6062499999999886
longitudeCenter Double 3.3237500000000182

The output didn't match the original (Current Location), thereby marking a different location on the map when used.

Please help!

Just like the digital latitude and longitude, the precision of the plus code matters. 6FR5J84F+ is only 8 digits, which will result in a fairly wide area.

Compare your code https://plus.codes/6FR5J84F+ to a made-up example https://plus.codes/6FR5J84F+7C with 2 extra digits of precision. The red box shows the area encapsulated by the code, the longer the code, the smaller the box (and thus, the more precise for the center of the box).

I would recommend codes with 10 or 11 digits (not including the '+' sign) for normal use-cases.

I'd highly recommend reading https://github.com/google/open-location-code/wiki and exploring the https://plus.codes website to learn more about the intricacies of how they work.

from open-location-code-swift.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.