Skip to content

Commit

Permalink
Remake
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Mar 17, 2014
1 parent 37214d5 commit 901d7f2
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion sexagesimal.js
@@ -1,11 +1,37 @@
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.sexagesimal=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
(function(e){if("function"==typeof bootstrap)bootstrap("sexagesimal",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeSexagesimal=e}else"undefined"!=typeof window?window.sexagesimal=e():global.sexagesimal=e()})(function(){var define,ses,bootstrap,module,exports;
return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
module.exports = element;
module.exports.pair = pair;
module.exports.format = format;
module.exports.formatPair = formatPair;

function element(x, dims) {
return search(x, dims).val;
}

function formatPair(x) {
return format(x.lat, 'lat') + ' ' + format(x.lon, 'lon');
}

// Is 0 North or South?
function format(x, dim) {
var dirs = {
lat: ['N', 'S'],
lon: ['E', 'W']
}[dim] || '',
dir = dirs[x >= 0 ? 0 : 1],
abs = Math.abs(x),
whole = Math.floor(abs),
fraction = abs - whole,
fractionMinutes = fraction * 60,
minutes = Math.floor(fractionMinutes),
seconds = Math.floor((fractionMinutes - minutes) * 60);

return whole + '° ' +
(minutes ? minutes + "' " : '') +
(seconds ? seconds + '" ' : '') + dir;
}

function search(x, dims, r) {
if (!dims) dims = 'NSEW';
if (typeof x !== 'string') return { val: null, regex: r };
Expand Down Expand Up @@ -44,3 +70,4 @@ function swapdim(a, b, dim) {
},{}]},{},[1])
(1)
});
;

0 comments on commit 901d7f2

Please sign in to comment.