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

@programmerare/sweden_crs_transformations

v1.0.0

Published

TypeScript/JavaScript library for transformation of geographic coordinates between WGS84 and the Swedish coordinate reference systems SWEREF99 and RT90

Downloads

267

Readme

TypeScript library for transformation of geographic coordinates between WGS84 and the Swedish coordinate reference systems SWEREF99 and RT90.

How to use the library

Install the module into your TypeScript (or JavaScript) module:

pnpm install @programmerare/sweden_crs_transformations

or

npm install @programmerare/sweden_crs_transformations

Then you can use this kind of code from a TypeScript module:

import {CrsProjection, CrsCoordinate} from '@programmerare/sweden_crs_transformations';
const coordinate_WGS84_latitude = 59.330231;
const coordinate_WGS84_longitude = 18.059196;
// the below explicit type ': CrsCoordinate' is optional to specify
const coordinate_WGS84: CrsCoordinate = CrsCoordinate.createCoordinate(
    CrsProjection.wgs84,
    coordinate_WGS84_latitude,      
    coordinate_WGS84_longitude
);
// the below explicit type ': CrsCoordinate' is optional to specify
const coordinate_SWEREF99TM: CrsCoordinate = coordinate_WGS84.transform(CrsProjection.sweref_99_tm);
console.log(`SWEREF99TM X: ${coordinate_SWEREF99TM.xLongitude}`);
console.log(`SWEREF99TM Y: ${coordinate_SWEREF99TM.yLatitude}`);

You can use almost the same code as above (if you skip the above optional typing) from a JavaScript Node.js module, if you are using "type": "module" in your file 'package.json', assuming that you are also using a recent version of 'Node.js'.
("type":"module" should work with Node.js versions 13.2.0 and later)
An alternative for JavaScript, if you are not using "type": "module" is to use the require syntax instead as below:

const {CrsProjection, CrsCoordinate} = require("@programmerare/sweden_crs_transformations");
// Above row: if you are NOT using "type":"module" in your "package.json"
// Below row: if you ARE using "type":"module" in your "package.json"
//import {CrsProjection, CrsCoordinate} from '@programmerare/sweden_crs_transformations';

const coordinate_WGS84_latitude = 59.330231;
const coordinate_WGS84_longitude = 18.059196;
const coordinate_WGS84 = CrsCoordinate.createCoordinate(
    CrsProjection.wgs84,
    coordinate_WGS84_latitude,      
    coordinate_WGS84_longitude
);
const coordinate_SWEREF99TM = coordinate_WGS84.transform(CrsProjection.sweref_99_tm);
console.log(`SWEREF99TM X: ${coordinate_SWEREF99TM.xLongitude}`);
console.log(`SWEREF99TM Y: ${coordinate_SWEREF99TM.yLatitude}`);

It is also possible to use a javascript bundle from within a webpage.
See the github webpage for more information

20 coordinate reference systems are supported (WGS84 + 6 RT90 + 13 SWEREF99)
rt90_sweref

License information

MIT.
The mathematical code for the transformations is based on the C# class GaussKreuger.cs in the .NET library MightyLittleGeodesy

The text below has been copied from the above linked 'MightyLittleGeodesy' webpage:

The calculations in this library is based on the excellent javascript library by Arnold Andreasson which is published under the Creative Commons license. However, as agreed with mr Andreasson, MightyLittleGeodesy is now licensed under the MIT license.

The text below has been copied from one of the source files for MightyLittleGeodesy.

/*
 * MightyLittleGeodesy 
 * RT90, SWEREF99 and WGS84 coordinate transformation library
 * 
 * Read my blog @ http://blog.sallarp.com
 * 
 * 
 * Copyright (C) 2009 Björn Sållarp
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this 
 * software and associated documentation files (the "Software"), to deal in the Software 
 * without restriction, including without limitation the rights to use, copy, modify, 
 * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 
 * permit persons to whom the Software is furnished to do so, subject to the following 
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */