[MetaCRS] Coordinate transformation returning NaN

Mike Adair madair at dmsolutions.ca
Thu Jul 23 15:00:43 EDT 2009


Hi Andrew,

You need to include the x_0, y_0 and lat_0 values for the EPSG:2054 def 
string.  We should probably default those to 0 so you don't get this 
error but the following def string will do as a workaround:

Proj4js.defs["EPSG:2054"] = "+proj=tmerc +ellips=WGS84 +datum=WGS84 
+lon_0=31 +lat_0=0 +x_0=0 +y_0=0 +units=m +no_defs";

Mike

stretch wrote:
> Hi all
>
> I am following on from a post i made a couple of weeks ago
> (here:http://n2.nabble.com/map-coordinates-in-different-coordinate-system-td3224904.html).
> It was suggested to post here.
>
> Firstly. I am trying to reproject from 4148 to 2054 (hartebeesthoek94 Lo31).
> Much discussion in my previous post, and indeed on other mailing lists (i.e
> GDAL) relates to this projection and the fact that it is south orientated.
> Let me firstly try and clarify as we have had some discussion around this
> very topic on the africa osgeo mailing list.
> 1. Officially (i think) hartebeesthoek94 used a modified South Orientated
> transverse mercator projection
> 2. Only some surveyors and engineers use this in Cad packages
> 3. 99% of all GIS users in South Africa do NOT use this South orientated
> Transverse Mercator and instead use  the standard transverse mercator (with
> Hartebeesthoek/WGS84 datum and WGS84 ellipsoid)
>
> What I am trying to accomplish should therefore NOT rely on support for a
> south orientated projection.
>
> Here is my code:
>
>     Proj4js.defs["EPSG:2054"] = "+proj=tmerc +ellips=WGS84 +datum=WGS84
> +lon_0=31 +units=m +no_defs"; 
>     Proj4js.defs["EPSG:4148"]  = "+proj=longlat +ellps=WGS84
> +towgs84=0,0,0,0,0,0,0 +no_defs "; 
>     
>     var source = new Proj4js.Proj('EPSG:4148');    //source coordinates will
> be in Longitude/Latitude
>     var dest = new Proj4js.Proj('EPSG:2054');     //destination coordinates 
>  
>     // transforming point coordinates
>     var p = new Proj4js.Point(30.352,-29.623);   //any object will do as
> long as it has 'x' and 'y' properties
>     Proj4js.transform(source, dest, p);      //do the transformation.  x and
> y are modified in place
>     alert(p.x);
>     alert(p.y);
>
> the alert return "NAN", if i use EPSG:27563 as per the example, the alert
> return a correct value
>
> On a further note if i run
> cs2cs +proj=latlong +datum=WGS84 +to +proj=tmerc +lon_0=31 +datum=WGS84 
> and then enter:
> 30.352 -29.623
> You will get:
> -62758.77       -3278498.65 0.00
>
> Which is the correct result:
>
> I would appreciate any assistance in getting my transformation to work
> correctly
> Regards
> Andrew
>   

-- 
   Michael Adair
   Senior Software Architect
   DM Solutions Group Inc.

   Office: (613) 565-5056 x26
   madair at dmsolutions.ca
   http://www.dmsolutions.ca
   http://research.dmsolutions.ca




More information about the MetaCRS mailing list