Ejemplo n.º 1
0
        internal static CoordinateSystemBase Create(ICoordinateSystem coordSys)
        {
            CoordinateSystemBase csb = null;

            try
            {
                //This fails because the XY-M projection is not supported
                csb = new ActualCoordinateSystem(coordSys);
            }
            catch { }

            if (csb == null && coordSys != null)
            {
                IUnit unit = coordSys.GetUnits(0);
                var   au   = unit as IAngularUnit;
                var   lu   = unit as ILinearUnit;
                if (au != null)
                {
                    double radians = au.RadiansPerUnit;
                    csb = new DegreeBasedCoordinateSystem();
                }
                else if (lu != null)
                {
                    csb = new MeterBasedCoordinateSystem(lu.MetersPerUnit, lu.MetersPerUnit);
                }
            }

            if (csb == null)
            {
                csb = new MeterBasedCoordinateSystem();
            }

            return(csb);
        }
Ejemplo n.º 2
0
        internal static CoordinateSystemBase Create(ICoordinateSystem coordSys)
        {
            CoordinateSystemBase csb = null;
            try
            {
                //This fails because the XY-M projection is not supported
                csb = new ActualCoordinateSystem(coordSys);
            }
            catch { }

            if (csb == null && coordSys != null)
            {
                IUnit unit = coordSys.GetUnits(0);
                if (unit is IAngularUnit)
                {
                    double radians = (unit as IAngularUnit).RadiansPerUnit;
                    csb = new DegreeBasedCoordinateSystem();
                }
                else if (unit is ILinearUnit)
                    csb = new MeterBasedCoordinateSystem(((ILinearUnit)unit).MetersPerUnit, ((ILinearUnit)unit).MetersPerUnit);
            }

            if (csb == null)
                csb = new MeterBasedCoordinateSystem();

            return csb;
        }