New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

cgcs2000

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cgcs2000

China Geodetic Coordinate System 2000 (CGCS2000)

latest
npmnpm
Version
0.0.11
Version published
Weekly downloads
11
450%
Maintainers
1
Weekly downloads
 
Created
Source

CGCS2000 坐标系

CGCS2000(China Geodetic Coordinate System 2000)是中国国家大地坐标系,本库提供了完整的 CGCS2000 坐标系相关功能,包括坐标转换、坐标系查询和椭球体参数获取等。

功能特性

  • 支持 CGCS2000 坐标系的完整 WKID 范围(4490-4554)
  • 提供坐标转换功能(支持单点和批量转换)
  • 支持高斯-克吕格投影带坐标系查询
  • 提供椭球体参数获取
  • 带号计算功能(3度带和6度带)

安装

npm install cgcs2000

使用方法

基本导入

import CGCS2000 from 'cgcs2000';
// 或者
import { CGCS2000 } from 'cgcs2000';

获取椭球体参数

const ellipsoid = CGCS2000.getEllipsoid();
console.log(ellipsoid);
// 输出: { name: 'CGCS2000', semiMajorAxis: 6378137, flattening: 1/298.257222101 }

坐标转换

// 单点转换
const sourceWkid = 4490; // CGCS2000 地理坐标系
const targetWkid = 4546; // CGCS2000 3度带投影(带号46)
const coordinates: [number, number] = [116.397, 39.908]; // [经度, 纬度]

const result = CGCS2000.transform(sourceWkid, targetWkid, coordinates);
console.log(result); // 转换后的坐标

// 批量转换
const points: [number, number][] = [
  [116.397, 39.908],
  [121.4737, 31.2304],
  [113.2644, 23.1291]
];

const results = CGCS2000.transformBatch(sourceWkid, targetWkid, points);

坐标系查询

// 根据 WKID 获取坐标系信息
const coordinateSystem = CGCS2000.getCoordinateSystem(4490);
console.log(coordinateSystem?.name); // 坐标系名称

// 根据名称获取坐标系信息
const csByName = CGCS2000.getCoordinateSystemByName("CGCS2000_Geographic");

// 验证是否为 CGCS2000 坐标系
const isValid = CGCS2000.isCGCS2000(4546); // true

高斯-克吕格投影带

// 获取 3 度带无带号坐标系
const gk3NoZone = CGCS2000.getGk3DegNoZone();

// 获取 3 度带带带号坐标系
const gk3WithZone = CGCS2000.getGk3DegWithZone();

// 获取 6 度带无带号坐标系
const gk6NoZone = CGCS2000.getGk6DegNoZone();

// 获取 6 度带带带号坐标系
const gk6WithZone = CGCS2000.getGk6DegWithZone();

带号计算

// 计算 3 度带带号
const zone3 = CGCS2000.calculate3DegZoneNumber(117); // 中央子午线117度

// 计算 6 度带带号
const zone6 = CGCS2000.calculate6DegZoneNumber(117);

常用 CGCS2000 WKID

WKID坐标系名称描述
4490CGCS2000_GeographicCGCS2000 地理坐标系
4546CGCS2000_3Degree_GK_Zone_463度带投影,46带
4526CGCS2000_6Degree_GK_Zone_266度带投影,26带

API 参考

CGCS2000 类静态方法

getEllipsoid(): Ellipsoid

获取 CGCS2000 椭球体参数

getCoordinateSystem(wkid: number): CoordinateSystem | undefined

根据 WKID 获取坐标系定义

getCoordinateSystemByName(name: string): CoordinateSystem | undefined

根据名称获取坐标系定义

isCGCS2000(wkid: number): boolean

验证 WKID 是否为 CGCS2000 系列坐标系

transform(sourceWkid: number, targetWkid: number, coordinates: [number, number]): [number, number]

坐标转换

transformBatch(sourceWkid: number, targetWkid: number, coordinates: [number, number][]): [number, number][]

批量坐标转换

getGk3DegNoZone(): CoordinateSystem[]

获取所有 3 度带无带号坐标系定义

getGk3DegWithZone(): CoordinateSystem[]

获取所有 3 度带带带号坐标系定义

getGk6DegNoZone(): CoordinateSystem[]

获取所有 6 度带无带号坐标系定义

getGk6DegWithZone(): CoordinateSystem[]

获取所有 6 度带带带号坐标系定义

calculate3DegZoneNumber(centralMeridian: number): number

根据中央子午线计算 3 度带带号

calculate6DegZoneNumber(centralMeridian: number): number

根据中央子午线计算 6 度带带号

错误处理

当使用不支持的坐标系 WKID 时,会抛出错误:

try {
  CGCS2000.transform(4326, 4490, [0, 0]); // WGS84 转 CGCS2000
} catch (error) {
  console.error(error.message); // "不支持的源坐标系 WKID: 4326"
}

测试

运行测试:

npm test

生成覆盖率报告:

npm run test:coverage

依赖

许可证

MIT

Keywords

cgcs2000

FAQs

Package last updated on 06 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts