Conversion result implemented in Google Maps, using data of my hometown Deinze, Belgium
To convert ESRI shapefiles to geoJSON (which you can perfectly use JavaScript and thus pass on to Google Maps, see screenshot above) you will need GDAL (Geospatial Data Abstraction Library) — Mac Users: download here. I have installed GDAL 1.9 Complete but perhaps the framework itself might also do.
After installation, you can use ogr2ogr to do the actual conversion.
Needed to convert LAMBERT 1972 (EPSG:31370) coordinates to WGS84 (EPSG:4326) for a project I’m working on in order to use the coordinates with Google Maps (which uses a SphericalMercator (EPSG:900913) projection).
Took me quite a while to find the needed algorithm, so hereby I’m listing them (and am providing the JavaScript implementation):
JavaScript:
var lambert72toWGS84 = function(x, y){
var newLongitude, newLatitude;
var n = 0.77164219,
F = 1.81329763,
thetaFudge = 0.00014204,
e = 0.08199189,
a = 6378388,
xDiff = 149910,
yDiff = 5400150,
theta0 = 0.07604294;
var xReal = xDiff - x,
yReal = yDiff - y;
var rho = Math.sqrt(xReal * xReal + yReal * yReal),
theta = Math.atan(xReal / -yReal);
newLongitude = (theta0 + (theta + thetaFudge) / n) * 180 / Math.PI;
newLatitude = 0;
for (var i = 0; i < 5 ; ++i) {
newLatitude = (2 * Math.atan(Math.pow(F * a / rho, 1 / n) * Math.pow((1 + e * Math.sin(newLatitude)) / (1 - e * Math.sin(newLatitude)), e / 2))) - Math.PI / 2;
}
newLatitude *= 180 / Math.PI;
return [newLatitude, newLongitude];
}