Baidu Map GPS Information correction

Source: Internet
Author: User
Tags gety

Title, with the mobile phone Baidu to obtain GPS-related coordinates information and the real coordinate information has a certain deviation exists, as to why the deviation, for the moment.

The following thing I searched for is to reduce the error to a minimum method, for reference only.

Baidu latitude and longitude coordinates and Google latitude and longitude coordinates are converted. Use the URL below to convert the original coordinates or Google coordinates into the coordinates of Baidu, will get the Base64 character, Restore is the true latitude and longitude.

There are four parameters in the request interface:
where the values corresponding to the From and to are: 0 true coordinates, 2google coordinates, 4BAIDU coordinates.
From: The coordinate system being converted
To: Convert to this coordinate system
X: Longitude
Y: Latitude
There are three keys in the interface answer,
Answer format such as: {"error": 0, "x": "Mte2ljmymtyymzg4mjiz", "Y": "Ndaumdy2nde2mjc4nzmx"}
where x and y are the required values

The application is as follows:

Package Com.baidumap error correction; Import;import;import;import;import;import;import; Import Com.sun.xml.internal.messaging.saaj.util.base64;class baidumapmodifyvalue{string error; String x; String Y;public string GetError () {return error;} public void SetError (String error) {this.error = error;} Public String GetX () {return x;} public void SetX (String x) {this.x = x;} Public String GetY () {return y;} public void Sety (String y) {this.y = y;}} public class Bmapgismodify {public static String converttostring (InputStream inputstream) {InputStreamReader INP          Utstreamreader = new InputStreamReader (InputStream);          BufferedReader BufferedReader = new BufferedReader (InputStreamReader);          StringBuilder result = new StringBuilder ();          String line = null;          try {while (line = Bufferedreader.readline ()) = null) {        Result.append (line + "\ n");          }} catch (IOException e) {e.printstacktrace ();                  } finally {try{inputstreamreader.close ();                  Inputstream.close ();              Bufferedreader.close ();              }catch (IOException e) {e.printstacktrace ();      }} return result.tostring ();  }/* * In the GIS information, "X, Y" XY represents the latitude and longitude * out of the GIS correction information, the content "x, y" XY represents the latitude and longitude * */public static String Modifygis (string valuexy) { SYSTEM.OUT.PRINTLN ("Original GIS value:" +valuexy); string[] Gisxy = Valuexy.split (","); String GISX = gisxy[0]; String gisy = gisxy[1]; /* Fix the connection address * the values corresponding to the From and to are: 0 true coordinates, 2google coordinates, 4BAIDU coordinates. From: Converted coordinate system to: convert to this coordinate system x: Longitude y: Latitude */String Urlvalue = " &x= "+gisx+" &y= "+gisy; HttpURLConnection urlconnection = null; JSON parse callback value String responsestr = "";         try{url url = new URL (urlvalue);      URLConnection = (httpurlconnection) url.openconnection ();              Get Request Define://urlconnection.setrequestmethod ("get");                            Urlconnection.connect ();              Connection Response from Test servlet//system.out.println ("Connection Response from Test servlet");                            InputStream InputStream = Urlconnection.getinputstream ();              Convert Stream to String responsestr = ConvertToString (InputStream);          System.out.println (RESPONSESTR);          }catch (IOException e) {System.out.println ("Baidu GIS correction, URL forced parsing, abnormal");        }finally{Urlconnection.disconnect (); } baidumapmodifyvalue result = new Gson (). Fromjson (Responsestr, Baidumapmodifyvalue.class); if (!result.error equals ("0")) {System.out.println ("Baidu map corrects GIS, returns result marker bit not 0, exception"); return "Resulterror";} else{String GISXY_OK = Base64.base64decode (Result.getx ()) + "," +base64.base64decode (result.geTY ()); SYSTEM.OUT.PRINTLN ("Correcting GIS values:" +GISXY_OK); return GISXY_OK; }} public static void Main (string[] args) {/* Baidu map Pickup coordinate system URL Connection * HTTP://API.MAP.BAIDU.COM/LBSAPI/GETPOINT/INDEX.HTML?QQ-P * tick ' coordinate reverse ', you can do numerical coordinates to reverse the geographical coordinates * */String Gisinfo = "133.94404224820853,21.537722890239518"; Modifygis (Gisinfo);}}


Baidu Map GPS Information correction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.