示例#1
0
 internal ProjectedCoordinateSystem(
     HorizontalDatum horizontalDatum,
     AxisInfo[] axisInfoArray,
     GeographicCoordinateSystem geographicCoordSystem,
     LinearUnit linearUnit,
     Projection projection,
     string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
     : base(remarks, authority, authorityCode, name, alias, abbreviation)
 {
     if (axisInfoArray == null)
     {
         throw new ArgumentNullException("axisInfoArray");
     }
     if (geographicCoordSystem == null)
     {
         throw new ArgumentNullException("geographicCoordSystem");
     }
     if (projection == null)
     {
         throw new ArgumentNullException("projection");
     }
     if (linearUnit == null)
     {
         throw new ArgumentNullException("linearUnit");
     }
     _horizontalDatum       = horizontalDatum;
     _axisInfoArray         = axisInfoArray;
     _geographicCoordSystem = geographicCoordSystem;
     _projection            = projection;
     _linearUnit            = linearUnit;
 }
示例#2
0
 internal ProjectedCoordinateSystem(
     HorizontalDatum horizontalDatum,
     AxisInfo[] axisInfoArray,
     GeographicCoordinateSystem geographicCoordSystem,
     LinearUnit linearUnit,
     Projection projection)
     : this(horizontalDatum, axisInfoArray, geographicCoordSystem, linearUnit, projection, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty)
 {
 }
 private static void WriteLinearUnit(LinearUnit linearUnit, bool esri, IndentedTextWriter writer)
 {
     writer.WriteLine("UNIT[");
     writer.Indent = writer.Indent + 1;
     writer.WriteLine(String.Format("\"{0}\",{1}", linearUnit.Name, linearUnit.MetersPerUnit.ToString(_nhi)));
     //writer.WriteLine(String.Format("AUTHORITY[\"{0}\",\"{1}\"]", linearUnit.Authority, linearUnit.AuthorityCode));
     WriteAuthority(linearUnit, esri, writer);
     writer.Indent = writer.Indent - 1;
     writer.WriteLine("]");
 }
        private static Ellipsoid ReadEllipsoid(string [] parameters, LinearUnit unit)
        {
            string ellps = ParameterValue(parameters, "+ellps");

            if (ellps != null)
            {
                double majorAxis, minorAxis, invFlattening;
                string name = ProjDB.SpheroidByP4(ellps, out majorAxis, out minorAxis, out invFlattening);

                if (name == String.Empty)
                {
                    throw new NotSupportedException(String.Format("Ellipsoid {0} is not implemented.", ellps));
                }

                string a = ParameterValue(parameters, "+a");
                string b = ParameterValue(parameters, "+b");
                if (a != null)
                {
                    majorAxis = double.Parse(a);
                }
                if (b != null)
                {
                    minorAxis = double.Parse(b);
                }
                if (a != null && b != null)
                {
                    if (majorAxis == minorAxis)
                    {
                        invFlattening = 0;
                    }
                    else
                    {
                        invFlattening = minorAxis / (majorAxis - minorAxis);
                    }
                }

                return(new Ellipsoid(majorAxis, minorAxis, invFlattening, true,
                                     unit, String.Empty, string.Empty, string.Empty,
                                     name, string.Empty, string.Empty));
            }
            else
            {
                string a = ParameterValue(parameters, "+a");
                string b = ParameterValue(parameters, "+b");

                if (a != null && b != null)
                {
                    return(new Ellipsoid(
                               double.Parse(a, _nhi),
                               double.Parse(b, _nhi),
                               0, false, unit));
                }
            }
            return(null);
        }
示例#5
0
 internal VerticalCoordinateSystem(
     string name,
     VerticalDatum verticaldatum,
     string remarks, string authority, string authorityCode, string alias, string abbreviation)
     : base(remarks, authority, authorityCode, name, alias, abbreviation)
 {
     if (verticaldatum == null)
     {
         throw new ArgumentNullException("verticaldatum");
     }
     _verticaldatum = verticaldatum;
     _units         = LinearUnit.Meters;
     _axisinfo      = new AxisInfo[1] {
         AxisInfo.Altitude
     };
 }
示例#6
0
        public VerticalCoordinateSystem(string name,
                                        VerticalDatum verticaldatum,
                                        AxisInfo axisinfo,
                                        LinearUnit linearUnit,
                                        string remarks, string authority, string authorityCode, string alias, string abbreviation)
            : base(remarks, authority, authorityCode, name, alias, abbreviation)
        {
            if (verticaldatum == null)
            {
                throw new ArgumentNullException("verticaldatum");
            }

            _verticaldatum = verticaldatum;
            _axisinfo      = new AxisInfo[1] {
                axisinfo
            };
            _units = linearUnit;
        }
示例#7
0
        internal VerticalCoordinateSystem(string name, VerticalDatum verticaldatum, AxisInfo axisinfo, LinearUnit units)
            : base(name, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty)
        {
            if (verticaldatum == null)
            {
                throw new ArgumentNullException("verticaldatum");
            }
            if (units == null)
            {
                throw new ArgumentNullException("units");
            }

            _name          = name;
            _verticaldatum = verticaldatum;
            _axisinfo      = new AxisInfo[1] {
                axisinfo
            };
            _units = units;
        }
示例#8
0
        internal Ellipsoid(double semiMajorAxis, double semiMinorAxis, double inverseFlattening, bool isIvfDefinitive, LinearUnit linearUnit,
                           string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
            :
            base(remarks, authority, authorityCode, name, alias, abbreviation)
        {
            if (linearUnit == null)
            {
                throw new ArgumentNullException("linearUnit");
            }

            _name            = name;
            _linearUnit      = linearUnit;
            _semiMajorAxis   = semiMajorAxis;
            _isIvfDefinitive = isIvfDefinitive;

            if (_isIvfDefinitive)
            {
                _inverseFlattening = inverseFlattening;
                if (_inverseFlattening == 0.0)
                {
                    _semiMinorAxis = semiMajorAxis;
                }
                else
                {
                    _semiMinorAxis = (1.0 - (1.0 / _inverseFlattening)) * semiMajorAxis;
                }
            }
            else
            {
                _semiMinorAxis = semiMinorAxis;
                if (_semiMajorAxis - _semiMinorAxis != 0.0)
                {
                    _inverseFlattening = _semiMajorAxis / (_semiMajorAxis - _semiMinorAxis);
                }
                else
                {
                    _inverseFlattening = 0.0;
                }
            }
        }
        private static GeographicCoordinateSystem ReadGeographicCoordinateSystem(string[] parameters)
        {
            //+proj=longlat +ellps=intl +pm=ferro +towgs84=145,-187,103,0,0,0,0 +no_defs

            WGS84ConversionInfo wgs84     = ReadWGS84ConversionInfo(ParameterValue(parameters, "+towgs84"));
            LinearUnit          unit      = ReadUnit(parameters) as LinearUnit;
            Ellipsoid           ellipsoid = ReadEllipsoid(parameters, unit);
            HorizontalDatum     datum     = new HorizontalDatum(
                "Unknown",
                DatumType.IHD_Classic,
                ellipsoid,
                wgs84);

            GeographicCoordinateSystem geogrCoordSystem =
                new GeographicCoordinateSystem(
                    "Unknown",
                    new AngularUnit(Math.PI / 180.0, String.Empty, String.Empty, String.Empty, "degree", String.Empty, String.Empty),
                    datum,
                    ReadPrimeMeridian(parameters),
                    new AxisInfo("Geodetic latitude", AxisOrientation.North),
                    new AxisInfo("Geodetic longitude", AxisOrientation.East));

            return(geogrCoordSystem);
        }
示例#10
0
 internal Ellipsoid(double semiMajorAxis, double semiMinorAxis, double inverseFlattening, bool isIvfDefinitive, LinearUnit linearUnit)
     :
     this(semiMajorAxis, semiMinorAxis, inverseFlattening, isIvfDefinitive, linearUnit,
          String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty)
 {
 }
        private static Unit ReadUnit(WktStreamTokenizer tokenizer, bool includeAuthority)
        {
            //UNIT["degree",0.01745329251994433,AUTHORITY["EPSG","9102"]]
            Unit unit = null;

            tokenizer.ReadToken("[");
            string unitName = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.NextToken();
            double unitsPerUnit  = tokenizer.GetNumericValue();
            string authority     = String.Empty;
            string authorityCode = String.Empty;

            if (includeAuthority)
            {
                tokenizer.ReadToken(",");
                tokenizer.ReadAuthority(ref authority, ref authorityCode);
            }
            tokenizer.ReadToken("]");
            switch (unitName.ToUpper())
            {
            // take into account the different spellings of the word meter/metre.
            case "METER":
            case "METRE":
            case "KILOMETRE":
            case "KILOMETER":
                unit = new LinearUnit(unitsPerUnit, String.Empty, authority, authorityCode, unitName, String.Empty, String.Empty);
                break;

            case "DEGREE":
            case "RADIAN":
            case "GRAD":
                unit = new AngularUnit(unitsPerUnit, String.Empty, authority, authorityCode, unitName, String.Empty, String.Empty);
                break;

            //case "CLARKE'S LINK":
            //case "GOLD COAST FOOT":
            //case "US SURVEY FOOT":
            //case "CLARKE'S FOOT":
            //case "FOOT":
            //case "LINK":
            //case "INDIAN YARD":
            //case "GERMAN LEGAL METRE":
            //case "BRITISH CHAIN (SEARS 1922)":
            //case "BRITISH FOOT (SEARS 1922)":
            //case "BRITISH CHAIN (SEARS 1922 TRUNCATED)":
            //case "BRITISH CHAIN (BENOIT 1922 TRUNCATED)":
            //    unit = new LinearUnit(unitsPerUnit, String.Empty, authority, authorityCode, unitName, String.Empty, String.Empty);
            //    break;
            default:
                string u = unitName.ToUpper();
                if (u.Contains("YARD") || u.Contains("CHAIN") ||
                    u.Contains("FOOT") || u.Contains("LINK") ||
                    u.Contains("METRE") || u.Contains("METER") ||
                    u.Contains("KILOMETER") || u.Contains("KILOMETRE"))
                {
                    unit = new LinearUnit(unitsPerUnit, String.Empty, authority, authorityCode, unitName, String.Empty, String.Empty);
                }
                else
                {
                    throw new NotImplementedException(String.Format("{0} is not recognized a unit of measure.", unitName));
                }
                break;
            }
            return(unit);
        }