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

fenfu

v1.0.9

Published

中国地图分幅编号计算工具(GB/T 13989-2012标准)

Downloads

11

Readme

fenfu

中国地图分幅编号计算工具,符合 GB/T 13989-2012 国家标准。支持单点计算和范围查询,适用于测绘、GIS开发、城市规划等场景。

特性

  • ✅ 支持8种比例尺(100万至5000)
  • ✅ 单点坐标转图幅编号
  • ✅ 矩形范围批量图幅查询
  • ✅ 自动处理高纬度特殊分幅规则
  • ✅ 输入验证与错误处理
  • ✅ 比例尺代码自动识别
  • ✅ TypeScript类型支持

安装

npm install fenfu
# 或
yarn add fenfu

使用示例

1. 单点计算

const MapSheetCalculator = require('fenfu');
// 或
import MapSheetCalculator from 'fenfu';

// 计算北京天安门(1:10万)
const code = MapSheetCalculator.calculate(116.3912, 39.9067, '10万');
console.log(code); // 输出:J50B001002

2. 范围查询

// 计算北京市朝阳区范围(1:5万比例尺)
const codes = MapSheetCalculator.calculateInRange(
  116.4, 39.8,   // 西南角(经度,纬度)
  116.6, 40.0,   // 东北角
  '5万'
);
console.log(codes);
/* 输出示例:
[
  'J50E001001',
  'J50E001002',
  'J50E002001',
  'J50E002002',
  'J50E003001'
]
*/

3. 比例尺识别

根据图幅编号自动判断其对应的比例尺。

const scale = MapSheetCalculator.getScaleFromSheetCode('J50G001001');
console.log(scale); // 输出:1万
console.log(MapSheetCalculator.getScaleFromSheetCode('S500000000')); // 100万
console.log(MapSheetCalculator.getScaleFromSheetCode('V50C001000')); // 25万
console.log(MapSheetCalculator.getScaleFromSheetCode('J50D012034')); // 10万

API文档

1. calculate(lng, lat, scale)

  • 参数
    • lng number 经度(-180~180)
    • lat number 纬度(-90~90)
    • scale string 比例尺(支持值:100万50万25万10万5万2.5万1万5000
  • 返回string 图幅编号
  • 错误:无效输入时抛出异常

2. calculateInRange(minLng, minLat, maxLng, maxLat, scale)

  • 参数
    • minLng number 范围最小经度
    • minLat number 范围最小纬度
    • maxLng number 范围最大经度
    • maxLat number 范围最大纬度
    • scale string 比例尺
  • 返回string[] 覆盖范围内的所有图幅编号
  • 注意:大范围计算可能返回大量结果,建议分块处理

3. getScaleFromSheetCode(sheetCode)

  • 参数
    • sheetCode string 图幅编号(如 'J50G001001'
  • 返回string 对应比例尺描述(如 '1万'
  • 支持比例尺
    • '100万''50万''25万''10万'
    • '5万''2.5万''1万''5000'

验证安装

你可以通过以下命令快速验证安装是否成功并测试基本功能:

npm install fenfu
node -e "console.log(require('fenfu').calculate(116.3912, 39.9067, '10万'))"
node -e "console.log(require('fenfu').calculateInRange(116.2, 39.8, 116.5, 40.0, '10万'))"
node -e "console.log(require('fenfu').calculateInRange(116.4, 39.8, 116.6, 40.0, '5万'))"
node -e "console.log(require('fenfu').getScaleFromSheetCode('J50G001001'))"

开源协议

MIT License