Exemple #1
0
        private CoordinateDomain CreatCoordinateDomain(XElement coordDomain)
        {
            CoordinateDomain coordinateDomain = new CoordinateDomain(Convert.ToDouble(coordDomain.Attribute(XName.Get("minx")).Value),
                                                                     Convert.ToDouble(coordDomain.Attribute(XName.Get("maxx")).Value),
                                                                     Convert.ToDouble(coordDomain.Attribute(XName.Get("miny")).Value),
                                                                     Convert.ToDouble(coordDomain.Attribute(XName.Get("maxy")).Value));

            return(coordinateDomain);
        }
Exemple #2
0
        public List <CoordinateDomain> GetCoordinateDomainItems()
        {
            List <CoordinateDomain> coordinateDomainItems = new List <CoordinateDomain>();
            IEnumerable <XElement>  projects = GetProjectNodes();

            foreach (XElement project in projects)
            {
                XElement coordDomain = project.Element(XName.Get("CoordDomain"));
                if (!String.IsNullOrEmpty(coordDomain.Attribute(XName.Get("minx")).Value) &&
                    !String.IsNullOrEmpty(coordDomain.Attribute(XName.Get("maxx")).Value) &&
                    !String.IsNullOrEmpty(coordDomain.Attribute(XName.Get("miny")).Value) &&
                    !String.IsNullOrEmpty(coordDomain.Attribute(XName.Get("maxy")).Value))
                {
                    CoordinateDomain coordinateDomain = null;
                    coordinateDomain = CreatCoordinateDomain(coordDomain);
                    coordinateDomainItems.Add(coordinateDomain);
                }
            }
            return(coordinateDomainItems);
        }
Exemple #3
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;
             }
         }
     }
 }