Skip to content

Instantly share code, notes, and snippets.

View edingroot's full-sized avatar

Chi Chang edingroot

  • Yelp
  • London, United Kingdom
View GitHub Profile
// Ref: https://kuro.tw/posts/2015/06/11/js-note-twd97-convert-to-longitude-and-latitude/
function twd97_to_latlng($x, $y) {
var pow = Math.pow, M_PI = Math.PI;
var sin = Math.sin, cos = Math.cos, tan = Math.tan;
var $a = 6378137.0, $b = 6356752.314245;
var $lng0 = 121 * M_PI / 180, $k0 = 0.9999, $dx = 250000, $dy = 0;
var $e = pow((1 - pow($b, 2) / pow($a, 2)), 0.5);
$x -= $dx;
$y -= $dy;
# Convert Lat/Lon to TWD97
# Ref: http://fyyang.blogspot.tw/2012/09/python-twd97.html
from math import tan, sin, cos, radians # Using math.tan, math.sin, math.cos, math.radians
class LatLngToTWD97(object): # class for convert
"""This object provide method for converting lat/lng coordinate to TWD97
coordinate
The reference to:
http://blog.ez2learn.com/2009/08/15/lat-lon-to-twd97/