Why does DotSpatial return NaN for point reprojection?

From the master branch and examples @ https://github.com/DotSpatial/DotSpatial the following fills the xy array with NaN but we expect 1755668,5922511

``````Dim x As Double() = {2666109}
Dim y As Double() = {6484213}
Dim z(x.Length - 1) As Double

Dim xy(2 * x.Length - 1) As Double
Dim ixy As Integer = 0
For i As Integer = 0 To x.Length - 1
xy(ixy) = x(i)
xy(ixy + 1) = y(i)
z(i) = 0
ixy += 2
Next

Dim srcsys As ProjectionInfo = ProjectionInfo.FromEpsgCode(27200)
Dim destsys As ProjectionInfo = ProjectionInfo.FromEpsgCode(2193)

Reproject.ReprojectPoints(xy:=xy,
z:=z,
source:=srcsys,
dest:=destsys,
startIndex:=0,
numPoints:=x.Length)
``````
• seems this is specific to New Zealand Map Grid (EPSG:27200) re projections (other projections work OK). I've posted a GitHub issue and will try to debug the source code, – ajayel Jun 27 '17 at 19:42

I'm not a .Net developer but I suspect that your arrays `Z` and `XY` are both initialized to length 0 (`x.length - 1`) when they should be length 1 (`x.length`) and 2 (`2 * x.length`) respectively. And, depending on how loops work in .Net you may not even execute the loop as it runs from 0 to 0 to fill them in so there is no error.

I had exactly the same thing happen when using Sphere Azimuthal Equidistant http://epsg.io/53032.

(Proj.4): +proj=aeqd +lat_0=-40 +lon_0=60 +x_0=0 +y_0=0 +a=6371000 +b=6371000 +units=m +no_defs

I had a similar thing using BNG (EPSG:27700) - I dodged this by using a literal Proj4 string instead for the specific projection which wasn't working:

``````if (origProjCode == 27700)
{
prjSource = DotSpatial.Projections.ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +units=m +no_defs");
}
else
{
prjSource = DotSpatial.Projections.ProjectionInfo.FromEpsgCode(origProjCode);
}
``````

Thinking about it, I could probably work out what the issue was by inspecting the result from the literal string vs the result from the .FromEpsgCode thing - but a dodge is a dodge.