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

localcoords

v0.0.7

Published

实现国内地方投影坐标,Beijing54 地理坐标,Beijing54 投影坐标,WGS84 地理坐标的转换

Downloads

64

Readme

LocalCoords

实现国内地方投影坐标,Beijing54 地理坐标,Beijing54 投影坐标,WGS84 地理坐标的转换

注:投影坐标即为平面坐标,用 xyz 表示,地理坐标为球面坐标,用经纬度表示

安装

npm i localcoords

使用

地方投影坐标 <=> Beijing54 投影坐标

国内的投影坐标一般基于 Beijing54 坐标系,所以两者之间的转换需要通过四参数拟合得到

import {localproj_bjproj} from 'localcoords'

let fourParams = {
    x_0: 3109444.007744, // x轴偏转
    y_0: 557065.040376, // y轴偏转
    t: -1.188967233, // 旋转因子
    k: 0.985971406835, // 比例常数
}

let coord:[number,number] | Array<[number, number]> = [328443.4399,345557.6179];

// 正向转换
let resCoord1 = localproj_bjproj(coord, fourParams);

// 逆向转换
let resCoord2 = localproj_bjproj(coord, fourParams, true);

Beijing54 投影坐标系 <=> Beijing54 地理坐标系

地理坐标和投影坐标的转化需要设置投影参数,国内大比例尺地图通常都是高斯投影,所以投影参数中常用的两个参数就是中央经线和东偏距离

import {bjproj_bjlnglat} from 'localcoords';

let coord: [number,number] | Array<[number, number]> = [3546276.946407,383516.597035];

// 正向转换
let res1 = bjproj_bjlnglat(coord, {
    lon_0: 120, // 中央经线
    x_0: 500000, // 东偏
});

// 逆向转换
let res1 = bjproj_bjlnglat(coord, {
    lon_0: 120,
    x_0: 500000,
}, true);

Beijing54地理坐标系 <=> WGS84地理坐标系

Beijing54和WGS84采用不同的椭球基准,常用的拟合方法为七参数法,这里可以直接使用proj4的库进行转化

import {bjlnglat_wgslnglat} from 'localcoords';

let coord: [number, number] | Array<number, number> = [118.766898215,32.033336978 ];

// 正向转换
let res1 = bjlnglat_wgslnglat(coord);
// 逆向转换
let res2 = bjlnglat_wgslnglat(coord, true);

其他

源码