Skip to content

Commit

Permalink
removed the ISN93_To_WGS84 method in favor of using the isn2wgs module
Browse files Browse the repository at this point in the history
  • Loading branch information
Baldur Már Helgason committed Sep 13, 2013
1 parent 774bbd0 commit 0e91e79
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 45 deletions.
5 changes: 3 additions & 2 deletions endpoints/bus/realtime.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var h = require('../../lib/helpers.js'),
request = require('request'),
app = require('../../server');
app = require('../../server'),
isn2wgs = require('isn2wgs');

app.get('/bus/realtime', function(req, res){
var data = req.query;
Expand Down Expand Up @@ -66,7 +67,7 @@ app.get('/bus/realtime', function(req, res){

route.busses.forEach(function(bus, key){

var location = h.ISN93_To_WGS84(bus.X,bus.Y),
var location = isn2wgs(bus.X,bus.Y),
oneRoute = {
'unixTime': Date.parse(bus.TIMESTAMPREAL)/1000,
'x': location.lat,
Expand Down
43 changes: 0 additions & 43 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,49 +104,6 @@ exports.browser = function(){
return browsers[Math.floor(Math.random()*browsers.length)];
}

/**
* Function to change strange icelandic lat and lng points to the real thing
* http://kort.samsyn.is/api/api/v2/Example/Example12.aspx
* http://kort.samsyn.is/api/SiteWatch.aspx?v=2&key=Bus49fVdg
*/
exports.ISN93_To_WGS84 = function(q,p){
q = parseFloat(q);
p = parseFloat(p);
q=q-500000;
p=p-500000;
var m = Math.pow(Math.sqrt(q*q+Math.pow(2982044.27322585-p,2))/11616778.382033,1.10334624954392);
var o = 1.5707963267949-(2*Math.atan(m));
var l = o;
var k = 0.0818191913305*Math.sin(l);o=1.5707963267949-2*Math.atan(m*Math.pow(((1-k)/(1+k)),0.04090959566525));
while(o-l>0.000001){
l = o;
k = 0.0818191913305*Math.sin(l);
o = 1.5707963267949-2*Math.atan(m*Math.pow(((1-k)/(1+k)),0.04090959566525))
}
return {
lat:Math.round((o*57.2957795130823)*1000000)/1000000,
lng:Math.round(((((Math.atan(q/(2982044.27322585-p)))*57.2957795130823)/0.90633380084752)-19)*1000000)/1000000
};
}

/**
* Function to change lat and lng points to strange icelandic location points
* //http://kort.samsyn.is/api/api/v2/Example/Example12.aspx
* //http://kort.samsyn.is/api/SiteWatch.aspx?v=2&key=Bus49fVdg
*/
exports.WGS84_To_ISN93=function(l,m){
l = parseFloat(l);
m = parseFloat(m);
var k=l*0.0174532925199433;
var p=0.0818191913305*Math.sin(k);
var o=11616778.382033*Math.pow(Math.tan(0.785398163397448-(k/2))/Math.pow((1-p)/(1+p),0.04090959566525),0.90633380084752);
var q=(m+19)*0.0158185089469038;
return {
x:Math.round((500000+o*Math.sin(q))*1000)/1000,
y:Math.round((3482044.27322585-o*Math.cos(q))*1000)/1000
};
}

/**
* Iterates through all members of an object and changes it in place.
* Changes all members holding arrays of size 1 and sets them to the single item the array holds.
Expand Down

0 comments on commit 0e91e79

Please sign in to comment.