Coordinate Transformation Overview

Coordinate Transformation Overview

Google Maps uses the WGS84 geographic coordinate system (except China), Google China Maps, AutoNavi, Tencent, etc. use the GCJ02 geographic coordinate system, Baidu uses the BD09 coordinate system, and devices generally include GPS chips or Beidou chips . The latitude and longitude is the WGS84 geographic coordinate system. my country requires that Internet maps must be encrypted at least with GCJ02 for the first time in China, and geographic data under WGS84 coordinates are not allowed to be directly used, and any coordinate system cannot be converted to WGS84 coordinates.

This is why the latitude and longitude collected by the device often has a large deviation when displayed on the map, far exceeding the technical specification of the 10-meter offset of civilian GPS.

For this, domestic map services all provide corresponding functions. For example, Baidu Map uses the BD09 coordinate system, and Baidu Map Location Service can set the return latitude and longitude coordinate type:

option.setCoorType("bd09ll");
//可选,设置返回经纬度坐标类型,默认GCJ02
//GCJ02:国测局坐标;
//BD09ll:百度经纬度坐标;
//BD09:百度墨卡托坐标;
//海外地区定位,无需设置坐标类型,只能统一返回WGS84类型坐标

In order to correctly display the point position on the Baidu map, it must be used BD09ll.

And Baidu Maps does not provide WGS84 latitude and longitude positioning services.

To obtain WGS84 latitude and longitude with a mobile phone, you must call native positioning to obtain it.

WGS84 coordinates can be obtained by using the positioning chip or native positioning. In order to display correctly on the map, coordinate conversion is also required.

For example, Baidu Maps provides a coordinate conversion function that provides non-Baidu coordinates to Baidu coordinates:

WGS84(大地坐标系)→bd09(百度坐标系)
GCJ02(国测局坐标系)→bd09(百度坐标系)

Qianxun Location provides an online coordinate conversion service , which can perform the following coordinate conversions:

BD09转化WGS84

BD09转化GCJ02

GCJ02转化WGS84

GCJ02转化BD09

How to enter coordinates to locate on the map?

For example, in the search box at the top of Google Maps, enter your coordinates.

The following examples are supported coordinate formats:

  • Degrees Minutes Seconds (DMS) : 41°24'12.2"N 2°10'26.5"E
  • Degrees and Decimal Minutes (DMM) : 41 24.2028, 2 10.4418
  • Decimal Degrees (DD) : 41.40338, 2.17403

For example, the data transmitted by the GPS chip module is $GNGGA data, and its latitude and longitude format is ddmm.mmmm (degree-minute format).

Just enter your query in degrees and decimal minutes on Google Maps. There must be a large offset because no coordinate transformation is done.

Online conversion tool can be used to convert WGS84 to GCJ02 .

Replenish

Various online tools may not work well at times, so it is best if you can write your own code conversion.

A ** gcoord ** library is recommended here.

Introduce:

<script src="https://unpkg.com/gcoord/dist/gcoord.js"></script>

use:

var result = gcoord.transform(
  [116.403988, 39.914266],    // 经纬度坐标
  gcoord.WGS84,               // 当前坐标系
  gcoord.BD09                 // 目标坐标系
);

console.log(result);  // [116.41661560068297, 39.92196580126834]

The result of this conversion is the same as the online tool conversion.

Guess you like

Origin blog.csdn.net/xiaoshihd/article/details/109519472