This project is read-only.

New Zealand Map Grid reprojection errors

Feb 20, 2012 at 6:17 AM

I was having a problem re-projecting polygons into New Zealand Map Grid. The end-points of polygons should be identical. However, when I passed the polygon coordinates into the Projections library, the end coordinates would always be different.

I discovered that the reprojection was going wrong in the OnForward method of the NewZealandMapGrid class.

There is a global array called _bf which is declared as readonly. However, when the array of coordinates was getting passed into the Proj.Zpoly1 static method, the array was getting modified, causing subsequent transformations to be incorrect.

It looks to me like the problem is that the _bf nested array is declared using object literal syntax, whcih makes it an array of reference types. This is bypassing the readonly declaration of the array, and consequently assignments to copies of the values which take place inside the Proj.Zpoly1 are actually altering the array inside this method.

I made a shallow local copy of the _bf values, and this fixed the problem.

Feb 23, 2012 at 12:41 AM

Could you submit your source?

Feb 23, 2012 at 12:41 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Apr 23, 2012 at 8:11 AM

Hi Rohan72 - I have been trying to convert a simple four point polygon from NZMG to WGS84 using featureset.reproject today and have had nothing but trouble. Am I missing something, is there an added step with NZMG. I works fine from any other projection I tried.....