There is a serious error in Krovak (S-JTSK) projection. Results are completely incorrect.
double[] myOut = new double[2];
myOut[0] = 12.8069888666667;
myOut[1] = 49.4522626972222;
double[] myZ = new double[1];
myZ[0] = 0;
DotSpatial.Projections.ProjectionInfo source = KnownCoordinateSystems.Geographic.World.WGS1984;
string projJTSK2 = "+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +pm=greenwich +units=m +no_defs";
DotSpatial.Projections.ProjectionInfo myJTSKPI = DotSpatial.Projections.ProjectionInfo.FromProj4String(projJTSK2);
DotSpatial.Projections.Reproject.ReprojectPoints(myOut, myZ, source, myJTSKPI, 0, myZ.Length);
//expected result is Y (-868208.52), X (-1095793.96)
//result computed by DotSpatial is y (475022.2) X (376370.6)
When examining the source code, there are some errors in the code of Krovak.cs.
First error identified in the OnInit() method.
K0 = projInfo.CentralMeridian != null ? projInfo.Lam0 : 0.9999;
This code is clearly incorrect! K0 is a scale factor and so the correct code should be:
K0 = projInfo.ScaleFactor != 1 ? projInfo.ScaleFactor : 0.9999;
I have created a unit test KrovakTest.cs to test this bug.
double[] myOut = new double[2];
myOut[0] = 12.8069888666667;
myOut[1] = 49.4522626972222;
double[] myZ = new double[1];
myZ[0] = 0;
DotSpatial.Projections.ProjectionInfo source = KnownCoordinateSystems.Geographic.World.WGS1984;
string projJTSK2 = "+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +pm=greenwich +units=m +no_defs";
DotSpatial.Projections.ProjectionInfo myJTSKPI = DotSpatial.Projections.ProjectionInfo.FromProj4String(projJTSK2);
DotSpatial.Projections.Reproject.ReprojectPoints(myOut, myZ, source, myJTSKPI, 0, myZ.Length);
//expected result is Y (-868208.52), X (-1095793.96)
//result computed by DotSpatial is y (475022.2) X (376370.6)
When examining the source code, there are some errors in the code of Krovak.cs.
First error identified in the OnInit() method.
K0 = projInfo.CentralMeridian != null ? projInfo.Lam0 : 0.9999;
This code is clearly incorrect! K0 is a scale factor and so the correct code should be:
K0 = projInfo.ScaleFactor != 1 ? projInfo.ScaleFactor : 0.9999;
I have created a unit test KrovakTest.cs to test this bug.