Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7516035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:00:18+00:00 2026-05-30T01:00:18+00:00

Google’s Encoded Polyline Algorithm Format : How do you decode this? Perhaps run the

  • 0

Google’s Encoded Polyline Algorithm Format:

enter image description here

How do you decode this?

Perhaps run the algorithm backwards; But I’m stuck at step 5: without the initial value, how do I know if it’s positive/negative?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:00:19+00:00Added an answer on May 30, 2026 at 1:00 am

    Its encoding leftshifts then inverts if negative, eg:

    1: 0000_0001 =>0000_0010
    2: 0000_0010 =>0000_0100
    3: 0000_0011 =>0000_0110
    4: 0000_0100 =>0000_1000
    5: 0000_0101 =>0000_1010
    6: 0000_0110 =>0000_1100
    7: 0000_0111 =>0000_1110
    8: 0000_1000 =>0001_0000
    
    -1: 1111_1111 =>1111_1110 =>0000_0001
    -2: 1111_1110 =>1111_1100 =>0000_0011
    -3: 1111_1101 =>1111_1010 =>0000_0101
    -4: 1111_1100 =>1111_1000 =>0000_0111
    -5: 1111_1011 =>1111_0110 =>0000_1001
    -6: 1111_1010 =>1111_0100 =>0000_1011
    -7: 1111_1001 =>1111_0010 =>0000_1101
    -8: 1111_1000 =>1111_0000 =>0000_1111
    

    Thus, decoding has if last bit is 0, initial is positive, and if last bit is 1, initial is negative.


    Appendix:

    Full decoding demo:

    public class Test {
     public static void main(String args[]) {
      for (int point : Decode("_p~iF~ps|U_ulLnnqC_mqNvxq`@",10)) {
       System.out.println(point); // Be aware that point is in E5
      }
     }
    
     private static java.util.List<java.lang.Integer> Decode(String encoded_polylines, int initial_capacity) {
      java.util.List<java.lang.Integer> trucks = new java.util.ArrayList<java.lang.Integer>(initial_capacity);
      int truck = 0;
      int carriage_q = 0;
      for (int x = 0, xx = encoded_polylines.length(); x < xx; ++x) {
       int i = encoded_polylines.charAt(x);
       i -= 63;
       int _5_bits = i << (32 - 5) >>> (32 - 5);
       truck |= _5_bits << carriage_q;
       carriage_q += 5;
       boolean is_last = (i & (1 << 5)) == 0;
       if (is_last) {
        boolean is_negative = (truck & 1) == 1;
        truck >>>= 1;
        if (is_negative) {
         truck = ~truck;
        }
        trucks.add(truck);
        carriage_q = 0;
        truck = 0;
       }
      }
      return trucks;
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Google results on this one are a bit thin, but suggest that it is
Google gives this but it seems to only work for a WindowsForms class. I'm
Google App Engine introduction specify this Your application can run in one of three
Google's not coming to my rescue, here, and I just know this is the
Google chrome doesn't behave the same as other browsers when encountering this nugget: <?php
Google is failing me on this one. Let's say I have some ECMA script
Google/MyBrain are failing me. Without using a framework (which I'll never get past my
Google and stackoverflow seem to be silent on how to do this. I must
Google gravity and gravity script are two nice demonstrations. but no source code or
Google's market_billing sample , just like others as this one , connects to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.