Baidu Maps uses a variant of web
Mercator projection for slicing map data into tiles, with distances expressed in degrees. It is associated with an underlying latitude-longitude reference. The reference uses the BD-09 coordinate system, which adds further obfuscation to the already obscure national standard in China,
GCJ-02 (which in turn is defined in terms of the
de facto standard around the world,
WGS 84). Baidu alleges that adopting BD-09 "protects users' privacy". The Baidu Maps API documentation specifies that "real" (WGS 84) GPS coordinates must be converted via a coordinate conversion interface. An
HTTP interface,
JavaScript API,
Android SDK, and
iOS SDK are available. The JavaScript coordinate conversion API is demonstrated online by Baidu, but without any reverse (to GCJ-02) conversion capabilities. Open source implementations in
R and various other languages exist, implemented in a manner much like the reverse GCJ-02 algorithm. BD-09's latitude-longitude coordinates are derived by scrambling a polar version of GCJ-02 coordinates and adding a fixed offset: from cmath import polar, rect from math import sin, cos, pi • Represent coordinates with complex numbers for simplicity coords = complex • baidu assumes x/real: lon; y/imag: lat here. def gcj_bd(gcj: coords) -> coords: r, θ = polar(gcj) r += 2e-5 * sin(gcj.imag * pi * 3000 / 180) θ += 3e-6 * cos(gcj.real * pi * 3000 / 180) return rect(r, θ) + (0.0065 + 0.006j) ==Street view service==