import { lngLatToWorld } from '@math.gl/web-mercator'; // https://epsg.io/3857 // +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs const HALF_EARTH_CIRCUMFERENCE = 6378137 * Math.PI; /** Projects EPSG:4326 to EPSG:3857 * This is a lightweight replacement of proj4. Use tests to ensure conformance. */ export function WGS84ToPseudoMercator(coord) { const mercator = lngLatToWorld(coord); mercator[0] = (mercator[0] / 256 - 1) * HALF_EARTH_CIRCUMFERENCE; mercator[1] = (mercator[1] / 256 - 1) * HALF_EARTH_CIRCUMFERENCE; return mercator; }