Git Product home page Git Product logo

cgcsfile2json's Introduction

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)

cgcsfile2json's People

Contributors

hongfaqiu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.