Opened 11 years ago

Closed 11 years ago

#78 closed defect (fixed)

Mercator error

Reported by: nbald Owned by: madair
Priority: major Milestone: 1.1.0
Component: core Version: trunk
Keywords: Cc:

Description

Look's like there's a bug in mercator.

Here's what I do :

<script src="proj4js/lib/proj4js-combined.js"></script>
<script>

Proj4js.defs["TESTWRF"]="+proj=merc +lon_0=5.937 +lat_ts=45.027 +ellps=sphere";


var WRFproj = new Proj4js.Proj("TESTWRF");
var center = new Proj4js.Point(5.364315,46.623154);

console.log(center.x + "\n" + center.y + "\n");

Proj4js.transform(Proj4js.WGS84, WRFproj, center);
console.log(center.x + "\n" + center.y + "\n");

Proj4js.transform(WRFproj,Proj4js.WGS84, center);
console.log(center.x + "\n" + center.y + "\n");

</script>

Results :

* initial wgs 
5.364315
46.623154

* wgs -> mercator
-45007.078762357225
4129776.713075627

* mercator -> wgs
5.364315000000002
25.526229853836988

My Proj4 string is tested working here : http://cs2cs.mygeodata.eu/

Change History (3)

comment:1 by nbald, 11 years ago

Findout how to fix it :

in the merc, inverse function: should add parenthesis

if (this.sphere) {
      lat = Proj4js.common.HALF_PI - 2.0 * Math.atan(Math.exp(-y / (this.a * this.k0)));
    }

instead of

if (this.sphere) {
      lat = Proj4js.common.HALF_PI - 2.0 * Math.atan(Math.exp(-y / this.a * this.k0));
    }

comment:2 by madair, 11 years ago

Status: newassigned

tried using this patch but still getting an incorrect answer. Need to look into it more.

comment:3 by madair, 11 years ago

Resolution: fixed
Status: assignedclosed

this is fixed and working in the github version now

Note: See TracTickets for help on using tickets.