GithubHelp home page GithubHelp logo

isabella232 / sexagesimal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mapbox/sexagesimal

0.0 0.0 0.0 38 KB

parse sexagesimal coordinates

License: BSD 2-Clause "Simplified" License

JavaScript 100.00%

sexagesimal's Introduction

npm version Build Status

sexagesimal

Convert between sexagesimal coordinates and decimal coordinates.

Usage

with npm (and/or) browserify

npm install @mapbox/sexagesimal

otherwise

curl https://raw.github.com/mapbox/sexagesimal/master/sexagesimal.js

Examples

var sexagesimal = require('sexagesimal');

// Converting a single DMS coordinate:

sexagesimal('40° 42′ 45.72″ N');  // direction after
// 40.712700000000005
sexagesimal('N40° 42′ 45.72″');   // direction before
// 40.712700000000005
sexagesimal('N40°42′45.72″');     // flexible whitespace
// 40.712700000000005

// Converting a coordinate pair from DMS to lat/lng:

sexagesimal.pair('40° 42′ 45.72″ N, 74° 0′ 21.24″ W');   // direction after
// [ 40.712700000000005, -74.0059 ]
sexagesimal.pair('N 40° 42′ 45.72″, W 74° 0′ 21.24″');   // direction before
// [ 40.712700000000005, -74.0059 ]

// Converting a lat/lon coordinate to DMS:

sexagesimal.coordToDMS(40.71270000000000, 'lat');
// { whole: 40, minutes: 42, seconds: 45, dir: 'N' }
sexagesimal.coordToDMS(-74.0059, 'lon');
// { whole: 74, minutes: 0, seconds: 21, dir: 'W' }

API

sexagesimal(str, dims) // returns a number or null

dims is by default NSEW but can be other ordinal directions expressed as a string of characters.

sexagesimal.pair(str, dims) // returns [lat, lon] or null

dims is by default NSEW but can be other ordinal directions expressed as a string of characters.

sexagesimal.format(float, dimension) // returns a formatted string

Format a single sexagesimal number. dimension must be a string, either "lat" or "lon".

sexagesimal.formatPair({ lat: float, lon: float }) // returns a formatted string

Format a sexagesimal coordinate.

sexagesimal's People

Contributors

bhousel avatar greenkeeperio-bot avatar kapadia avatar quincylvania avatar sabas avatar tmcw 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.