hutool.core.util.coordinate

Module Contents

Classes

Coordinate

坐标点

CoordinateUtil

坐标工具类,提供WGS84/GCJ02/BD09坐标系转换

API

class hutool.core.util.coordinate.Coordinate

Bases: typing.NamedTuple

坐标点

longitude: float = None
latitude: float = None
class hutool.core.util.coordinate.CoordinateUtil

坐标工具类,提供WGS84/GCJ02/BD09坐标系转换

WGS84: GPS全球定位系统使用的坐标系 GCJ02: 国测局坐标系(火星坐标系),国内地图服务使用 BD09: 百度坐标系,在GCJ02基础上进一步加密

_PI = None
_A = 6378245.0
_EE = 0.00669342162296594
static out_of_china(lng: float, lat: float) bool

判断是否在中国范围外(公开方法)

参数:
  • lng – 经度

  • lat – 纬度

返回:

是否在中国范围外

static wgs84_to_mercator(lng: float, lat: float) hutool.core.util.coordinate.Coordinate

WGS84 转 Web Mercator 投影坐标

参数:
  • lng – WGS84 经度

  • lat – WGS84 纬度

返回:

Web Mercator 坐标 (x, y),单位为米

static mercator_to_wgs84(x: float, y: float) hutool.core.util.coordinate.Coordinate

Web Mercator 投影坐标转 WGS84

参数:
  • x – Mercator X 坐标(米)

  • y – Mercator Y 坐标(米)

返回:

WGS84 坐标 (经度, 纬度)

static _out_of_china(lng: float, lat: float) bool

判断是否在中国范围外

参数:
  • lng – 经度

  • lat – 纬度

返回:

是否在中国范围外

static _transform_lat(lng: float, lat: float) float

纬度转换偏移量计算

参数:
  • lng – 经度

  • lat – 纬度

返回:

纬度偏移量

static _transform_lng(lng: float, lat: float) float

经度转换偏移量计算

参数:
  • lng – 经度

  • lat – 纬度

返回:

经度偏移量

static _delta(lng: float, lat: float) tuple

计算GCJ-02偏移量

参数:
  • lng – WGS84经度

  • lat – WGS84纬度

返回:

(经度偏移, 纬度偏移)

static wgs84_to_gcj02(lng: float, lat: float) hutool.core.util.coordinate.Coordinate

WGS84转GCJ02(GPS转国测局坐标)

参数:
  • lng – WGS84经度

  • lat – WGS84纬度

返回:

GCJ02坐标

static gcj02_to_wgs84(lng: float, lat: float) hutool.core.util.coordinate.Coordinate

GCJ02转WGS84

参数:
  • lng – GCJ02经度

  • lat – GCJ02纬度

返回:

WGS84坐标

static gcj02_to_bd09(lng: float, lat: float) hutool.core.util.coordinate.Coordinate

GCJ02转BD09(转百度坐标)

参数:
  • lng – GCJ02经度

  • lat – GCJ02纬度

返回:

BD09坐标

static bd09_to_gcj02(lng: float, lat: float) hutool.core.util.coordinate.Coordinate

BD09转GCJ02

参数:
  • lng – BD09经度

  • lat – BD09纬度

返回:

GCJ02坐标

static wgs84_to_bd09(lng: float, lat: float) hutool.core.util.coordinate.Coordinate

WGS84转BD09

参数:
  • lng – WGS84经度

  • lat – WGS84纬度

返回:

BD09坐标

static bd09_to_wgs84(lng: float, lat: float) hutool.core.util.coordinate.Coordinate

BD09转WGS84

参数:
  • lng – BD09经度

  • lat – BD09纬度

返回:

WGS84坐标

static distance(lng1: float, lat1: float, lng2: float, lat2: float) float

计算两点间距离(米),使用Haversine公式

参数:
  • lng1 – 第一个点的经度

  • lat1 – 第一个点的纬度

  • lng2 – 第二个点的经度

  • lat2 – 第二个点的纬度

返回:

两点间的距离(米)