Originally direct GPS positioning in Service, found that positioning on Baidu map data offset more serious ah, later learned that Baidu map latitude and longitude through encryption.
Search the web can turn the GPS latitude and longitude latitude and longitude
Baidu
GeoPoint p = new GeoPoint (x, y);
GeoPoint p2 = CoordinateConvert.bundleDecode (CoordinateConvert.fromWgs84ToBaidu (p));
Turn out the data is not very tricky ah.
Is there any know the correct way to Baidu GPS location latitude and longitude latitude and longitude of the phone turn ah?
Can the Service or directly with Baidu direct positioning it?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Nobody knows?
Reply:
Positioning with Baidu, would not converted.
Reply:
The good solution, as long as you set the bit map with Baidu, access to the latitude and longitude,
Then set gps position, access to the latitude and longitude, as a comparison, calculate the difference between each and then get together with gps latitude and longitude can be the difference between
Reply:
This value is not a pro-fixed, random. . .
Reply:
Do not. . . This is a regular. . . . . . . . . . . . . . . . . . Believe it or not, anyway, I believed
Before I get with android api plus the difference between the exact latitude and longitude on Baidu map display
Try,
Reply:
As with Baidu map, Baidu why not locate it?
Reply:
This algorithm is a state secret, conversion requires online be connected to Baidu, the following is the result of my painstaking research, quick to point it:
protected void runTest () throws Throwable {
try {
BaiduLocation bl = new BaiduLocation ();
bl.gpsx = 120 ;/ / longitude
bl.gpsy = 30 ;/ / latitude
GetBaiduLocation (bl);
if (bl.ok) {
int baidux = (int) (bl.baidux * 1E6);
int baiduy = (int) (bl.baiduy * 1E6);
/ / Conversion is successful, the coordinates are Baidu dedicated
}
else {
/ / / Conversion failed
}
}
catch (Exception ex) {
}
}
class BaiduLocation {
public float gpsx, gpsy;
public float baidux, baiduy;
public boolean ok = false;
}
public static String GetBaiduLocation (float x, float y) throws MalformedURLException, IOException {
String url = String.format ("http://api.map.baidu.com/ag/coord/convert?from=0&to=4&x =% f & y =% f", x, y);
HttpURLConnection urlConnection = (HttpURLConnection) (new URL (url) openConnection ().);
urlConnection.connect ();
BufferedReader reader = new BufferedReader (new InputStreamReader (urlConnection.getInputStream ()));
String lines = reader.readLine ();
reader.close ();
urlConnection.disconnect ();
return lines;
}
public static boolean GetBaiduLocation (BaiduLocation bl) {
try {
bl.ok = false;
String res = GetBaiduLocation (bl.gpsx, bl.gpsy);
if (res.startsWith ("{") && res.endsWith ("}")) {
res = res.substring (1, res.length () - 2) replace ("\" "," ");.
String [] lines = res.split (",");
for (String line: lines) {
String [] items = line.split (":");
if (items.length == 2) {
if ("error". equals (items [0])) {
bl.ok = "0" equals (items [1]);.
}
if ("x". equals (items [0])) {
bl.baidux = ConvertBase64 (items [1]);
}
if ("y". equals (items [0])) {
bl.baiduy = ConvertBase64 (items [1]);
}
}
}
}
} Catch (Exception e) {
bl.ok = false;
}
return bl.ok;
}
private static float ConvertBase64 (String str) {
byte [] bs = Base64.decode (str);
return Float.valueOf (new String (bs));
}
Reply:
Upstairs is very grateful that he wrote a Main tried it, basically little gap. Given points.
Reply:
Thanks to the 7th floor, very good thing
Reply:
Learn good things
Reply:
I think more Huitie know these are not the why, the following excerpt from http://www.eoeandroid.com/thread-208221-1-1.html
As we all know the Earth is an irregular oval body, the coordinate system is defined in the GIS map projection and datum is determined by two parameters, defined by a particular datum ellipsoid and the corresponding transformation parameters determined. Datum is the use of a particular ellipsoid approximation of specific regions of the Earth's surface, so that each country or region has its own plane. Datum is established based on the ellipsoid, the ellipsoid can correspond to multiple planes, and datum corresponds to only one ellipsoid. Meaning that either Google Maps, search maps or high moral map, Baidu map only difference for different geographic earth latitude and longitude coordinate system standard production, there is no question whether the Right, we are only quasi-reference or is not the same standard. Google Maps uses WGS84 geographic coordinate system (except China range), Google China Maps and Soso Chinese map is used GCJ02 geographic coordinate system, Baidu uses BD09 coordinate system, and equipment typically contains a GPS chip or Compass chip acquired WGS84 geographic coordinates of latitude and longitude, why not unified with the WGS84 geographic coordinate system which is published by the National Mapping Bureau Geographic map of the requirements for publishing maps must comply GCJ02 standard coordinate system, that is, the state can not directly use WGS84 geographic coordinate system. So we do not feel accurately locate many called for the publication of the map coordinates of Mars map is only just not the same. That is why the device when collecting the latitude and longitude on a map displayed often have great deviation, far beyond the technical specifications of civilian GPS 10 米 offset, so we have a Google Maps Tencent Soso correction correction correction Baidu hybrid map Google referrals existence value. How that correction for Google Maps, search soso map correction or rectification of Baidu map it, if the algorithm is currently no good direct conversion algorithm, so we are using the method of comparison it is divided into several small pieces found Earth deviation map recorded, and then find the latitude and longitude based on the closest any deviation plus the offset to convert latitude and longitude can be achieved between the different maps. There are 0.01 degrees latitude and longitude information correction can provide any format, you can directly adjust the latitude and longitude offset back. Baidu map correction information includes a total of 29,699,997 of the China Sea correction data, Google maps contain only a total of 12,597,551 of China's land correction data.
Also as far as I know, in North America, Europe, the earth coordinate system using WGS84, China has its own earth coordinate system: Beijing, Xi'an 54 or 80. WGS84, 54 Beijing, Xi'an 80, respectively, define different ellipsoids, the same place, they are not necessarily the same as the latitude and longitude, plus a different map projection, the reaction to the plane of the map is clearly a difference.
In fact, different ellipsoids, just know that it's a long axle and a flat rate, can be translated to each other, the conversion formula can be found on the wiki.
Reply:
In this way, what are the limitations on the conversion right
Reply:
Only temporary individual needs can be positioned so
Reply:
In the larger scope tried? This deviation may be in an area not too bad, but the large-scale look at this value is random, ah, have you measured over a different city or a different area of the same city?
Reply:
is almost the same
Reply:
private static float ConvertBase64 (String str)
{
byte [] bs = Base64.decode (str);
return Float.valueOf (new String (bs));
}
This function can explain how always wrong Kazakhstan it?
No comments:
Post a Comment