-function lonLatToMercator(ll) {
- var lon = ll.lon * 20037508.34 / 180;
- var lat = Math.log(Math.tan((90 + ll.lat) * Math.PI / 360)) / (Math.PI / 180);
-
- lat = lat * 20037508.34 / 180;
-
- return new OpenLayers.LonLat(lon, lat);
-}
-
-// for interacting with the PostGIS database which uses non spherical
-// Mercator. Taken from Freemap which in turn was taken from a standard
-// algorithm off the net.
-
-function lonLatToNonSphericalMercator(ll) {
- var custLat = ll.lat * (Math.PI/180);
- var a = 6378137;
- var b = 6356752.3142;
- var f = (a-b)/a;
- var e = Math.sqrt(2*f-Math.pow(f,2));
- custLat=a*Math.log(Math.tan(Math.PI/4+custLat/2)*
- Math.pow(( (1-e*Math.sin(custLat)) / (1+e*Math.sin(custLat))),e/2));
- custLon = ll.lon * (Math.PI/180) * 6378137;
- return new OpenLayers.LonLat (custLon,custLat);
-}