当前位置:网站首页>Research and arrangement of electronic map coordinate system
Research and arrangement of electronic map coordinate system
2022-06-28 03:40:00 【Bright in snow】
「 Blog move 」 New address : Simple books
This article is organized by the reference links at the end of the article 、 Integrate 、 Modified to
1. Brief introduction of electronic map coordinate system
- WGS-84 Coordinate system : The earth coordinate system , International longitude and latitude coordinate standard
- GCJ-02 Coordinate system : The Mars coordinate system ,WGS84 The encrypted coordinate system , Prepared by China Survey Bureau .
- BD-09 Coordinate system : Baidu coordinate system ,GCJ02 The encrypted coordinate system .
GCJ-02 Coordinate system , It's in the standard WGS-84 The coordinate system is artificially offset , such as Google Map 、 tencent SOSO Maps and so on use the country directly GCJ-02 Coordinate system , We have an unwritten saying , The former is called earth coordinates , The latter is called Mars coordinates , also , Mars coordinates cannot be converted into earth coordinates 「 Although there are certain methods on the Internet , But they are basically based on the offset database , High precision databases need to be purchased , Of course, this is a means of cracking 」.
All the electronic maps 、 Navigation equipment , All need to add national security plug-ins .
First step , Mapping company mapping , After surveying and Mapping , To the State Bureau of Surveying and mapping , An electronic map of real coordinates , Encrypted into “ Mars coordinates ”, Such a map can be published and published , Then you can let GPS The company deals with .
The second step , be-all GPS company , As long as you need car navigation , Need to use navigation electronic map , It is necessary to add the national security algorithm to the software , take COM The real coordinate signal read out by mouth , The encryption is converted into confidential coordinates required by the state . such ,GPS The navigator and the navigation electronic map can be completely matched ,GPS It can work normally .
| API | Coordinate system |
|---|---|
| Baidu Maps API | Baidu coordinates |
| Tencent search map API | Mars coordinates |
| Sohu Sogou map API | Sogou coordinates |
| Alibaba cloud map API | Mars coordinates |
| Picture bar MapBar Map API | Picture bar coordinates |
| Gao de MapABC Map API | Mars coordinates |
| Psychic chart 51ditu Map API | Mars coordinates |
- notes 1: Baidu map uses Baidu coordinates , It supports importing earth coordinates and Mars coordinates into Baidu coordinates , But cannot export . And batch coordinate conversion can only be converted at one time 20 individual ( To be verified ).
- notes 2: Sogou map supports direct display of earth coordinates , Support earth coordinates 、 Mars coordinates 、 Baidu coordinates are imported into Sogou coordinates , Again , Sogou coordinates cannot be exported .
Finish the coordinate system , We can naturally know the problem here , Pass the following questions , Let's say my research on this .
2、 Mutual transformation of various coordinate systems
2.1 Mars coordinate system 「GCJ-02」 And Baidu coordinate system 「BD-09」 The transformation algorithm of
among bd_encrypt take GCJ-02 The coordinates are converted to BD-09 coordinate , bd_decrypt conversely .
void bd_encrypt(double gg_lat, double gg_lon, double &bd_lat, double &bd_lon)
{
double x = gg_lon, y = gg_lat;
double z = sqrt(x * x + y * y) + 0.00002 * sin(y * x_pi);
double theta = atan2(y, x) + 0.000003 * cos(x * x_pi);
bd_lon = z * cos(theta) + 0.0065;
bd_lat = z * sin(theta) + 0.006;
}
void bd_decrypt(double bd_lat, double bd_lon, double &gg_lat, double &gg_lon)
{
double x = bd_lon - 0.0065, y = bd_lat - 0.006;
double z = sqrt(x * x + y * y) - 0.00002 * sin(y * x_pi);
double theta = atan2(y, x) - 0.000003 * cos(x * x_pi);
gg_lon = z * cos(theta);
gg_lat = z * sin(theta);
} 2.2 The earth coordinate system 「WGS-84」 To the Martian coordinate system 「GCJ-02」 The transformation algorithm of
WGS-84 To GCJ-02 Transformation 「 namely GPS Bias 」 Algorithm
using System;
namespace Navi
{
class EvilTransform
{
const double pi = 3.14159265358979324;
//
// Krasovsky 1940
//
// a = 6378245.0, 1/f = 298.3
// b = a * (1 - f)
// ee = (a^2 - b^2) / a^2;
const double a = 6378245.0;
const double ee = 0.00669342162296594323;
//
// World Geodetic System ==> Mars Geodetic System
public static void transform(double wgLat, double wgLon, out double mgLat, out double mgLon)
{
if (outOfChina(wgLat, wgLon))
{
mgLat = wgLat;
mgLon = wgLon;
return;
}
double dLat = transformLat(wgLon - 105.0, wgLat - 35.0);
double dLon = transformLon(wgLon - 105.0, wgLat - 35.0);
double radLat = wgLat / 180.0 * pi;
double magic = Math.Sin(radLat);
magic = 1 - ee * magic * magic;
double sqrtMagic = Math.Sqrt(magic);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.Cos(radLat) * pi);
mgLat = wgLat + dLat;
mgLon = wgLon + dLon;
}
static bool outOfChina(double lat, double lon)
{
if (lon < 72.004 || lon > 137.8347)
return true;
if (lat < 0.8293 || lat > 55.8271)
return true;
return false;
}
static double transformLat(double x, double y)
{
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.Sqrt(Math.Abs(x));
ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.Sin(y * pi) + 40.0 * Math.Sin(y / 3.0 * pi)) * 2.0 / 3.0;
ret += (160.0 * Math.Sin(y / 12.0 * pi) + 320 * Math.Sin(y * pi / 30.0)) * 2.0 / 3.0;
return ret;
}
static double transformLon(double x, double y)
{
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.Sqrt(Math.Abs(x));
ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.Sin(x * pi) + 40.0 * Math.Sin(x / 3.0 * pi)) * 2.0 / 3.0;
ret += (150.0 * Math.Sin(x / 12.0 * pi) + 300.0 * Math.Sin(x / 30.0 * pi)) * 2.0 / 3.0;
return ret;
}
}
} The above reference is from :http://www.xue5.com/Mobile/iOS/679842.html
2.3 Baidu online conversion API
http://api.map.baidu.com/ag/coord/convert?from=0&to=4&x=longitude&y=latitude
from: Source coordinate system 「0 Express WGS-84 coordinate ;2 Express GCJ-02 coordinate 」
to: Converted coordinates 「4 Express BD-09 coordinate , That is, the line used by Baidu map 」
x: longitude
y: latitude
After the request, a string of Json
{
"error":0,
"x":"MTIxLjUwMDIyODIxNDk2",
"y":"MzEuMjM1ODUwMjYwMTE3"
}
error: Is the result error flag bit ,0 It means success
x: Coordinate system 2 Hour is longitude ,4 Time is latitude (Base64 code )
y: Coordinate system 4 Hour is longitude ,2 Time is latitude (Base64 code )What circumstance , Longitude and latitude are encrypted ? Then I'll have to see what I can do next
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
public class BaiduAPIConverter extends Thread {
public static void testPost(String x, String y) throws IOException {
try {
URL url = new URL("http://api.map.baidu.com/ag/coord/convert?from=2&to=4&x="+ x + "&y=" + y);
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "utf-8");
// remember to clean up
out.flush();
out.close();
// Once the transmission is successful , You can get the response from the server by using the following methods :
String sCurrentLine, sTotalString;
sCurrentLine = sTotalString = "";
InputStream l_urlStream;
l_urlStream = connection.getInputStream();
BufferedReader l_reader = new BufferedReader(new InputStreamReader(l_urlStream));
while ((sCurrentLine = l_reader.readLine()) != null) {
if (!sCurrentLine.equals(""))
sTotalString += sCurrentLine;
}
sTotalString = sTotalString.substring(1, sTotalString.length() - 1);
String[] results = sTotalString.split("\\,");
if (results.length == 3) {
if (results[0].split("\\:")[1].equals("0")) {
String mapX = results[1].split("\\:")[1];
String mapY = results[2].split("\\:")[1];
mapX = mapX.substring(1, mapX.length() - 1);
mapY = mapY.substring(1, mapY.length() - 1);
mapX = new String(Base64.decode(mapX));
mapY = new String(Base64.decode(mapY));
System.out.println("\t" + mapX + "\t" + mapY);
}
}
sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/** * @param args * @throws IOException */
public static void main(String[] args) throws IOException {
testPost("120.151379", "30.184678");
System.out.println("ok");
}
} It's almost good to be here , The main code has been written , Write the rest by yourself .
The above reference is from :http://scalpel.me/archives/136
2.4 Baidu built-in conversion method , Can not be limited to Baidu positioning SDK
Get... In Baidu map WGS-84 coordinate , Call the following methods :
BMapManager.getLocationManager().setLocationCoordinateType(MKLocationManager.MK_COORDINATE_WGS84); So from Baidu API The coordinates obtained in are WGS-84 了 , However, if this coordinate is displayed on Baidu map, it will be offset , That is to say, take out a coordinate , The original display is offset , Therefore, in order to display it normally, it is necessary to convert it into... Before drawing it on Baidu map BD-09 .
convert to BD-09, Calling method :
GeoPoint wgs84;
GeoPoint bd09= CoordinateConvert.bundleDecode(CoordinateConvert.fromWgs84ToBaidu(wgs84));I really don't understand why it should be designed as CoordinateConvert.fromWgs84ToBaidu(wgs84) Returned a Bundle, So we need to CoordinateConvert.bundleDecode() Again into GeoPoint .
3. Reference article
边栏推荐
- matlab习题 —— 矩阵的常规运算
- Li Kou daily question - day 29 -575 Divide candy
- MySQL 数据库的自动备份操作
- WebSocket(简单体验版)
- 导入Excel文件,解决跳过空白单元格不读取,并且下标前移的问题,以及RETURN_BLANK_AS_NULL报红
- What is the best and safest software to download when buying stocks?
- 爱普生L3153打印机如何清洗喷头
- 可扩展数据库(下)
- 2022 operation of simulated examination platform of special operation certificate examination question bank for safety management personnel of hazardous chemical business units
- Tencent games released more than 40 products and projects, including 12 new games
猜你喜欢

WPF 下的自定义控件以及 Grid 中控件的自适应

资源管理、高可用与自动化(下)

2022 electrician (elementary) recurrent training question bank and online simulation examination

A pit filling trip based on LNMP to build a personal website

"Five layer" architecture of cloud applications and services

【PaddleDetection】ModuleNotFoundError: No module named ‘paddle‘

建立自己的网站(17)

Tencent games released more than 40 products and projects, including 12 new games

Summary of the use of composition API in the project

资源管理、高可用与自动化(中)
随机推荐
Inference optimization implementation of tensorrt model
资源管理、高可用与自动化(下)
Is it safe to buy stocks and open an account through the account opening link of the broker manager? Want to open an account for stock trading
数据库系列之MySQL和TiDB中慢日志分析
Use js programming questions [split] in Niuke
Importer un fichier Excel, résoudre le problème de sauter les cellules vides et de ne pas lire, et avancer l'indice, et retourner Blank As NULL Red
云应用、服务的“5层”架构
service实现类里面为何一直报红
What is the core problem to be solved in the East and West?
国泰君安证券靠谱吗?开证券账户安全吗?
nn. Parameter and torch nn. Init series of functions to initialize model parameters
电子地图坐标系统研究整理
WPF 下的自定义控件以及 Grid 中控件的自适应
SSH框架的搭建(下)
TypeError:&nbsp;&#039;module&amp;#03…
WebSocket(简单体验版)
matlab习题 —— 数据的基本处理
启牛商学院赠送证券账户是真的吗?开户到底安不安全呢
失联修复:让“躲猫猫”无处可藏
ETCD数据库源码分析——集群间网络层服务端RaftHandler