Giter VIP home page Giter VIP logo

swiss-projection-light's Introduction

DEPRECATED use swiss-projection instead

swiss-projection-light

Convert points and GeoJSON objects between LV03(EPSG:21781), LV95(EPSG:2056) and WGS84(EPSG:4326).

Install

NPM

$ npm install swiss-projection-light
var ch = require('swiss-projection-light')

Browser

Download swiss-proj.min.js

<script src="swiss-proj.min.js"></script>

The library is accessible through the global variable ch.

Usage

ch.<input-projection>.to<output-projection>.point([<x>,<y>], <round>)
// or 
ch.<input-projection>.to<output-projection>.GeoJSON(<geojson-object>, <round>)

<round> is a boolean (defaults to false). If true, the result will be rounded to closest integer for results in LV03 or LV95 and to 0.000001 in WGS.

Example 1: LV03 point to WGS84

ch.lv03.toWgs.point([600000, 200000])

// returns
// [ 7.4386329497797306, 46.95108228114304 ]

ch.lv03.toWgs.point([600000, 200000], true)

// returns
// [ 7.438633, 46.951082 ]

Exemple 2: WGS GeoJSON feature to LV95

var feature = {
	type: 'Feature', properties: {}, geometry: { type: 'Point', coordinates: [7.438633, 46.951082] }
}

ch.wgs.toLv95.GeoJSON(feature, true)

// returns

//{ type: 'Feature',
// properties: {},
// geometry: {
//  type: 'Point',
//  coordinates: [ 2600000, 1200000 ] 
// },
// crs: {
//  type: 'name',
//  properties: { name: 'urn:ogc:def:crs:EPSG::2056' } 
// } 
//}

This method works for both FeatureCollection and Feature.

swiss-projection-light's People

Contributors

idris-maps avatar

Stargazers

 avatar

Watchers

 avatar  avatar

swiss-projection-light's Issues

long/lat mixup

Hi,

thanks for the library, I'm using it in one of our projects. However I think there is a mixup, in the example you do:

ch.lv03.toWgs.point([600000, 200000])

and in the documentation you say

ch.<input-projection>.to<output-projection>.point([<x>,<y>], <round>)

But in the Swiss LV03 coordinate system x is 2xx xxx and y is 6xx xxx. There is no explanation of what is sent back, I assumed it's lat and the long but in your example you create a POINT and if this is WKT then it's usually long/lat.

Long story short is I assumed I get back lat/long and that is clearly wrong. Also Swiss people would assume y is 6xx xxx and not 2xx xxx. Either way there is a bug in your interpretation or a lack of documentation or both :) Would be great if you could clarify that.

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.