{"action":"created","issue":{"url":"https://api.github.com/repos/chrisveness/geodesy/issues/9","labels_url":"https://api.github.com/repos/chrisveness/geodesy/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/chrisveness/geodesy/issues/9/comments","events_url":"https://api.github.com/repos/chrisveness/geodesy/issues/9/events","html_url":"https://github.com/chrisveness/geodesy/issues/9","id":53522664,"number":9,"title":"Further possible conversion bugs","user":{"login":"davegurnell","id":231655,"avatar_url":"https://avatars.githubusercontent.com/u/231655?v=3","gravatar_id":"","url":"https://api.github.com/users/davegurnell","html_url":"https://github.com/davegurnell","followers_url":"https://api.github.com/users/davegurnell/followers","following_url":"https://api.github.com/users/davegurnell/following{/other_user}","gists_url":"https://api.github.com/users/davegurnell/gists{/gist_id}","starred_url":"https://api.github.com/users/davegurnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davegurnell/subscriptions","organizations_url":"https://api.github.com/users/davegurnell/orgs","repos_url":"https://api.github.com/users/davegurnell/repos","events_url":"https://api.github.com/users/davegurnell/events{/privacy}","received_events_url":"https://api.github.com/users/davegurnell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-06T14:59:20Z","updated_at":"2015-02-03T11:15:49Z","closed_at":null,"body":"Hi Chris,\r\n\r\nIt looks like there are still bugs in some of the NGR <-> GridRef and OSGB36 <-> WGS84 conversions. This round-trip test fails:\r\n\r\n~~~ javascript\r\ntest('round trip conversions (NGR <-> WGS84)', function(assert) {\r\n  var LatLonE = require('./latlon-ellipsoid.js');\r\n  var OsGridRef = require('./osgridref.js');\r\n\r\n  // The steps in this test are:\r\n  //  - parse an NGR\r\n  //  - convert to easting/northing\r\n  //  - convert to OSGB36\r\n  //  - convert to WGS84\r\n  //  - convert back to OSGB36\r\n  //  - convert back to easting/northing\r\n  //  - convert back to NGR\r\n\r\n  var ngr = \"TQ 44359 80653\";\r\n\r\n  var grid = OsGridRef.parse(ngr);\r\n  assert.equal(grid.easting, 544359, \"grid.easting\");\r\n  assert.equal(grid.northing, 180653, \"grid.northing\");\r\n\r\n  var osgb = OsGridRef.osGridToLatLon(grid);\r\n  console.log('osgb', osgb);\r\n  assert.equal(osgb.lat.toFixed(5), '51.50587', \"osgb.lat\");\r\n  assert.equal(osgb.lon.toFixed(5), '0.08030', \"osgb.lon\");\r\n\r\n  var wgs = osgb.convertDatum(LatLonE.datum.WGS84);\r\n  console.log('wgs', wgs);\r\n  assert.equal(wgs.lat.toFixed(5), '51.31876', \"wgs.lat\");\r\n  assert.equal(wgs.lon.toFixed(5), '0.07867', \"wgs.lon\");\r\n\r\n  // Problem 1: `wgs` doesn't have a convertDatum method...\r\n  // I guess there are several types of coordinate in the geodesy library:\r\n  var wgs2 = new LatLonE(wgs.lat, wgs.lon, LatLonE.datum.WGS84);\r\n\r\n  // Problem 2: this conversion comes out wrong...\r\n  // Latitude goes down instead of up as I'd expect:\r\n  var osgb2 = wgs2.convertDatum(LatLonE.datum.OSGB36);\r\n  console.log('osgb2', osgb2);\r\n  assert.equal(osgb2.lat.toFixed(5), osgb.lat.toFixed(5), \"osgb2.lat\"); // error: expected: '51.50587', actual: '51.13099'\r\n  assert.equal(osgb2.lon.toFixed(5), osgb.lon.toFixed(5), \"osgb2.lon\"); // error: expected: '0.08030', actual: '0.08029'\r\n\r\n  // Problem 3: this conversion fails with the following error:\r\n  // \"Can only convert OSGB36 point to OsGrid\"\r\n  var grid2 = OsGridRef.latLonToOsGrid(osgb2);\r\n  console.log('grid2', grid2);\r\n  assert.equal(grid2.easting, grid.easting, \"grid2.easting\");\r\n  assert.equal(grid2.northing, grid.northing, \"grid2.northing\");\r\n\r\n  var ngr2 = grid2.toPrecision(10);\r\n  assert.equal(ngr2, ngr, \"ngr2\");\r\n\r\n  assert.end();\r\n});\r\n~~~\r\n\r\nApologies if the errors are due to me mis-using the code or the expected accuracy of the conversions involved. Happy to help with the fixes if I can.\r\n\r\nBest regards,\r\n\r\nDave\r\n"},"comment":{"url":"https://api.github.com/repos/chrisveness/geodesy/issues/comments/72633756","html_url":"https://github.com/chrisveness/geodesy/issues/9#issuecomment-72633756","issue_url":"https://api.github.com/repos/chrisveness/geodesy/issues/9","id":72633756,"user":{"login":"davegurnell","id":231655,"avatar_url":"https://avatars.githubusercontent.com/u/231655?v=3","gravatar_id":"","url":"https://api.github.com/users/davegurnell","html_url":"https://github.com/davegurnell","followers_url":"https://api.github.com/users/davegurnell/followers","following_url":"https://api.github.com/users/davegurnell/following{/other_user}","gists_url":"https://api.github.com/users/davegurnell/gists{/gist_id}","starred_url":"https://api.github.com/users/davegurnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davegurnell/subscriptions","organizations_url":"https://api.github.com/users/davegurnell/orgs","repos_url":"https://api.github.com/users/davegurnell/repos","events_url":"https://api.github.com/users/davegurnell/events{/privacy}","received_events_url":"https://api.github.com/users/davegurnell/received_events","type":"User","site_admin":false},"created_at":"2015-02-03T11:15:49Z","updated_at":"2015-02-03T11:15:49Z","body":"Hi Chris,\r\n\r\nThis looks great! Thanks very much -- I'll try it out ASAP.\r\n\r\nCheers,\r\n\r\nDave\r\n\r\n\r\n\r\n> On 1 Feb 2015, at 22:31, Chris Veness <notifications@github.com> wrote:\r\n> \r\n> I have reorganised the libraries into a more rational structure, which I hope addresses these issues (I also improved the accuracy of the datum conversion, #ddde271 <https://github.com/chrisveness/geodesy/commit/ddde271a16c06f9c0696c76a989e04140c2790f5>). I've added a test <https://github.com/chrisveness/geodesy/commit/162afc6827b2d8dd1e681e296ba294b2fe69e757> which round-trips TQ 44359 80653 through OSGB36 to WGS84 and back, which completes successfully.\r\n> \r\n> —\r\n> Reply to this email directly or view it on GitHub <https://github.com/chrisveness/geodesy/issues/9#issuecomment-72388472>.\r\n> "}}