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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cgcsfile2json

v0.0.4

Published

convert cgcs2000 polygon shp or txt to geojson

Downloads

3

Readme

cgcsfile2json

convert cgcs2000(4528, 4549, 4490) polygon shp or txt to CGCS_2000(EPSG:4490) geojson 代码写得很烂,凑活用吧,后面有空再重构

usage

For node.js

npm install --save cgcsfile2json

example


import file2coor from 'cgcsfile2json'

let txtFile = getFile('test.txt');
let coors = file2coor.getCoordinates();
// coors: [4528, 4549, 4490];
// coorsCh: ['大地2000 有带号直角坐标系', '大地2000 无带号直角坐标系', '大地2000经纬度坐标系']
// txt's coordinate defalut is '大地2000 有带号直角坐标系'
let data = file2coor.convertFile(txtFile, 'txt'); 

let shpFile = getFile('test.shp');
let data2 = file2coor.convertFile(shpFile, 'shp', coors[2]); 

API

getCoordinates()

[4528, 4549, 4490]

convertFile(file, type, coor = 4528)

convert .shp or .txt file to geojson

boundCheck(data, order = false)

check if the geojson data is out of bounds when 'order' value is true, representes the point's coordinates is [lat, lon], otherwise defalut is [lon, lat]

setBoundary(bound)

defalut boundary is:

{ // 杭州范围
  xMin: 118.1217,
  xMax: 120.7753,
  yMin: 29.1304,
  yMax: 30.6191
}

judgeTypeByName(file, type)

judge the file(shp or txt)'s coordinates, txt file is 4528('大地2000 有带号直角坐标系').

The coordinate system of SHP file will be judged by whether the converted data exceeds the set boundary

parsingShape(file)

parse the shp file to geojson

parsingShape(file).then(res => {
  console.log(res);
})

handleDataChange(data, coor, precise = true)

convert the data to CGCS_2000(EPSG:4490) geojson when precise param is false, use the offline algorithm, which can only be accurate to the seven decimal place. defalut chose the online algorithm provided by arcgis server.

xy2lonlat(X, Y, L0)

convert cscs2000(XYZ) point to cscs2000(BLH)