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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cesium-with-bdgrid

v0.0.2

Published

基于北斗网格的cesium地图工具库,提供基于北斗网格的地图渲染、动画等功能

Downloads

29

Readme

Cesium with BDGrid

基于北斗网格的Cesium地图工具库,提供符合GB/T 39409-2020标准的北斗二维/三维网格编码功能。

License: MIT TypeScript

🌟 特性

  • 国标合规 - 严格遵循GB/T 39409-2020标准
  • 二维网格编码 - 支持1-10级北斗二维网格位置码
  • 三维网格编码 - 支持1-10级北斗三维网格位置码(含高度域)
  • Z序编码 - 层级3、6支持Z序编码方向处理
  • TypeScript支持 - 完整的类型定义
  • 高性能 - 优化的算法实现

📦 安装

npm install cesium-with-bdgrid

或使用yarn:

yarn add cesium-with-bdgrid

🚀 快速开始

基本使用

import { BDGrid2D, BDGrid3D } from 'cesium-with-bdgrid';

// 创建二维网格实例
const bdGrid2D = new BDGrid2D();

// 经纬度转二维网格码(北京天安门,层级5)
const gridCode2D = bdGrid2D.toCode(116.4074, 39.9042, 5);
console.log(gridCode2D); // "N50J47539B80000000000"

// 二维网格码转经纬度范围
const range2D = bdGrid2D.toRange("N50J47539B80000000000");
console.log(range2D); // { minLng: 116.4074, maxLng: 116.4078, minLat: 39.9042, maxLat: 39.9046 }

// 创建三维网格实例
const bdGrid3D = new BDGrid3D();

// 经纬度高程转三维网格码(北京天安门,海拔44米,层级5)
const gridCode3D = bdGrid3D.toCode3D(116.4074, 39.9042, 44, 5);
console.log(gridCode3D); // "N50J47539B800000000000000000000"

// 三维网格码转空间范围
const range3D = bdGrid3D.toRange3D("N50J47539B800000000000000000000");
console.log(range3D); // { minLng: 116.4074, maxLng: 116.4078, minLat: 39.9042, maxLat: 39.9046, minHeight: 0, maxHeight: 88 }

📚 API文档

BDGrid2D类

构造函数

const bdGrid2D = new BDGrid2D();

方法

toCode(lng: number, lat: number, level: number): string

将经纬度转换为北斗二维网格码。

参数:

  • lng - 经度(十进制,-180°~180°)
  • lat - 纬度(十进制,-90°~90°)
  • level - 目标层级(1-10)

返回值: 20位北斗二维网格码

示例:

const code = bdGrid2D.toCode(116.4074, 39.9042, 5);
// "N50J47539B80000000000"
toRange(gridCode: string): SpaceRange

将北斗二维网格码转换为经纬度范围。

参数:

  • gridCode - 北斗二维网格码(1-20位)

返回值: 包含经纬度范围的对象

示例:

const range = bdGrid2D.toRange("N50J47539B80000000000");
// { minLng: 116.4074, maxLng: 116.4078, minLat: 39.9042, maxLat: 39.9046 }

BDGrid3D类

构造函数

const bdGrid3D = new BDGrid3D();

方法

toCode3D(lng: number, lat: number, height: number, level?: number): string

将经纬度高程转换为北斗三维网格码。

参数:

  • lng - 经度(十进制,-180°~180°)
  • lat - 纬度(十进制,-90°~90°)
  • height - 高程(米,-6302000~528680000)
  • level - 目标层级(1-10,默认5)

返回值: 32位北斗三维网格码

示例:

const code = bdGrid3D.toCode3D(116.4074, 39.9042, 44, 5);
// "N50J47539B800000000000000000000"
toRange3D(gridCode: string): SpaceRange

将北斗三维网格码转换为空间范围。

参数:

  • gridCode - 北斗三维网格码(32位)

返回值: 包含经纬度和高度范围的对象

示例:

const range = bdGrid3D.toRange3D("N50J47539B800000000000000000000");
// { minLng: 116.4074, maxLng: 116.4078, minLat: 39.9042, maxLat: 39.9046, minHeight: 0, maxHeight: 88 }

🎯 网格层级说明

二维网格层级划分(GB/T 39409-2020 5.1)

| 层级 | 网格大小 | 编码长度 | 说明 | |------|----------|----------|------| | 1 | 6°×4° | 4位 | 1:100万图幅 | | 2 | 30′×30′ | 6位 | 1/12×1/8级1 | | 3 | 15′×10′ | 7位 | Z序编码 | | 4 | 1′×1′ | 9位 | 标准编码 | | 5 | 4″×4″ | 11位 | 标准编码 | | 6 | 2″×2″ | 12位 | Z序编码 | | 7 | 0.25″×0.25″ | 14位 | 标准编码 | | 8 | ~0.03125″×~0.03125″ | 16位 | 标准编码 | | 9 | ~0.0039″×~0.0039″ | 18位 | 标准编码 | | 10 | ~0.00049″×~0.00049″ | 20位 | 标准编码 |

三维网格编码结构(GB/T 39409-2020 6.2)

三维网格码由20位二维网格码和12位高度域编码组成:

N50J47539B80000000000 000000000000
↑                    ↑ ↑
二维网格码(20位)     高度域编码(12位)

📋 国标合规性

本项目严格遵循GB/T 39409-2020《北斗网格位置码》标准:

  • 地球参数 - 使用标准地球长半轴6378137m
  • 网格划分 - 按国标5.1要求划分各级网格
  • 编码规则 - 实现国标5.2规定的编码方式
  • Z序编码 - 层级3、6实现国标图4、图7的Z序编码
  • 高度域编码 - 按国标6.2实现三维交叉组成逻辑
  • 补零规则 - 未达到10级的高度层级末尾补零

📄 许可证

本项目基于MIT许可证开源 - 查看LICENSE文件了解详情。

📞 联系方式/问题反馈