npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cgcs2000

v0.0.11

Published

China Geodetic Coordinate System 2000 (CGCS2000)

Downloads

30

Readme

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 | 坐标系名称 | 描述 | |-------|-----------------------------------|------------------------| | 4490 | CGCS2000_Geographic | CGCS2000 地理坐标系 | | 4546 | CGCS2000_3Degree_GK_Zone_46 | 3度带投影,46带 | | 4526 | CGCS2000_6Degree_GK_Zone_26 | 6度带投影,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