Atlaslog / Field Notes / Coordinates & projections
Field note · Coordinates & projections
Baidu Mercator without MCBAND segments puts points 3 km off
Quick answer
Baidu's BD09MC is not EPSG:3857; its Y axis uses an 18-segment MCBAND/LLBAND lookup table. Computing tile coordinates with the standard Mercator formula shifts the mosaic about 3.8 km south-west, which is 15 tiles at zoom 18.
Symptom
- Tiananmen BD-09 116.410172, 39.916634 gives x=12958335, y=4855942 with the standard formula, but Baidu's own tiles imply 12962180, 4859510.
- The assembled tile mosaic sits south-west of the real position and drifts further at higher zoom levels.
- At zoom 18 the offset equals about 15 tiles.
Checklist
- Compare your computed tile indices with the tiles Baidu actually serves; a whole-grid shift means the projection differs.
- Search the code for the MCBAND, LLBAND and MC2LL constants.
- Reverse-engineer one known point (picker coordinate plus its tile number) and see whether segment coefficients are needed.
- Compare points at the same latitude but different longitudes: if the error varies only with latitude, the Y-axis segmenting is missing.
Fix
Do not reimplement BD09MC; keep BD-09 lon/lat and let the official API project, or use Baidu's MercatorProjection, which already carries the 18-segment table.
Code
const MCBAND = [12890594.86, 8362377.87, 5591021, 3481989.83, 1678043.12, 0];
const LLBAND = [75, 60, 45, 30, 15, 0];
const x = 116.410172 * 20037508.34 / 180; // 12958335
const y = Math.log(Math.tan((90 + 39.916634) * Math.PI / 360)) / (Math.PI / 180);
const yy = y * 20037508.34 / 180; // 4855942
// 与百度实际值 12962180 / 4859510 差约 3.8 kmconst projection = new BMapGL.MercatorProjection();
const p = projection.lngLatToPoint(new BMapGL.Point(116.410172, 39.916634));
// => { x: 12962179.6, y: 4859509.1 }
const ll = projection.pointToLngLat(new BMapGL.Pixel(12962179.6, 4859509.1));
// => { lng: 116.410172, lat: 39.916634 }
Watch out
- Substituting Cesium's WebMercatorProjection for Baidu's projection in the Baidu plugin.
- Reusing lng*20037508.34/180 and only patching the X axis, which fixes longitude while latitude stays kilometres off.
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Atlaslog (2026). Baidu Mercator without MCBAND segments puts points 3 km off. https://www.jingweizhi.com/en/cookbook/bd09-mcband.html (accessed 2026-11-03).