Exemple #1
0
 public static void Transform(Proj4Projection src, Proj4Projection dst,
                              double[] x, double[] y, double[] z)
 {
     lock (lockObj)
     {
         //Proj4Projection.CheckInitialized(src);
         //Proj4Projection.CheckInitialized(dst);
         if (x == null)
         {
             throw new ArgumentException("Argument is required", "x");
         }
         if (y == null)
         {
             throw new ArgumentException("Argument is required", "y");
         }
         if (x.Length != y.Length || (z != null && z.Length != x.Length))
         {
             throw new ArgumentException("Coordinate arrays must have the same length");
         }
         if (src.IsLatLong)
         {
             CoordinateDomain cd = dst._coordinateDomain;
             if (cd == null)
             {
                 for (int i = 0; i < x.Length; i++)
                 {
                     x[i] *= Proj.DEG_TO_RAD;
                     y[i] *= Proj.DEG_TO_RAD;
                 }
             }
             else
             {
                 for (int i = 0; i < x.Length; i++)
                 {
                     cd.CorrectX(ref x[i]);
                     cd.CorrectY(ref y[i]);
                     //
                     x[i] *= Proj.DEG_TO_RAD;
                     y[i] *= Proj.DEG_TO_RAD;
                 }
             }
         }
         int result = Proj.pj_transform(src.prj, dst.prj, x.Length, 1, x, y, z);
         if (result != 0)
         {
             string message = "Tranformation Error";
             int    errno   = GetErrNo();
             if (errno != 0)
             {
                 message = Proj4Projection.GetErrorMessage(errno);
             }
             throw new ApplicationException(message);
         }
         if (dst.IsLatLong)
         {
             for (int i = 0; i < x.Length; i++)
             {
                 x[i] *= Proj.RAD_TO_DEG;
                 y[i] *= Proj.RAD_TO_DEG;
             }
         }
     }
 }