示例#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;
 }
        internal static GeographicCoordinateSystem ReadGeographicCoordinateSystem(WktStreamTokenizer tokenizer, bool includeAuthority)
        {
            //GEOGCS["OSGB 1936",
            //DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]]
            //PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]]
            //UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]]
            //AXIS["Geodetic latitude","NORTH"]
            //AXIS["Geodetic longitude","EAST"]
            //AUTHORITY["EPSG","4277"]
            //]

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

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("DATUM");
            HorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer, includeAuthority);

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("PRIMEM");
            PrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer, includeAuthority);

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("UNIT");
            Unit angularUnit = ReadUnit(tokenizer, includeAuthority);

            AxisInfo axisInfo1 = null, axisInfo2 = null;

            if (tokenizer.TryReadToken(","))
            {
                if (tokenizer.TryReadToken("AXIS"))
                {
                    axisInfo1 = ReadAxisInfo(tokenizer);
                }
                if (tokenizer.TryReadToken(","))
                {
                    if (tokenizer.TryReadToken("AXIS"))
                    {
                        axisInfo2 = ReadAxisInfo(tokenizer);
                    }
                }
            }

            string authority     = String.Empty;
            string authorityCode = String.Empty;

            if (includeAuthority)
            {
                tokenizer.ReadToken(",");
                tokenizer.ReadAuthority(ref authority, ref authorityCode);
            }
            tokenizer.ReadToken("]");

            GeographicCoordinateSystem geographicCS = new GeographicCoordinateSystem(angularUnit as AngularUnit, horizontalDatum,
                                                                                     primeMeridian, axisInfo1, axisInfo2, String.Empty, authority, authorityCode, name, String.Empty, String.Empty);

            return(geographicCS);
        }
示例#3
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)
 {
 }
示例#4
0
 internal GeographicCoordinateSystem(string name,
                                     AngularUnit angularUnit,
                                     HorizontalDatum horizontalDatum,
                                     PrimeMeridian primeMeridian,
                                     AxisInfo axis0,
                                     AxisInfo axis1)
     :
     this(angularUnit, horizontalDatum, primeMeridian, axis0, axis1, String.Empty, String.Empty, String.Empty, name, String.Empty, String.Empty)
 {
 }
 private static void WriteHorizontalDatum(HorizontalDatum horizontalDatum, bool esri, IndentedTextWriter writer)
 {
     writer.WriteLine("DATUM[");
     writer.Indent = writer.Indent + 1;
     writer.WriteLine(String.Format("\"{0}\",", horizontalDatum.Name));
     WriteEllipsoid(horizontalDatum.Ellipsoid, esri, writer);
     WriteWGS84ConversionInfo(horizontalDatum.WGS84Parameters, esri, writer);
     //writer.WriteLine(String.Format("AUTHORITY[\"{0}\",\"{1}\"]", horizontalDatum.Authority, horizontalDatum.AuthorityCode));
     WriteAuthority(horizontalDatum, esri, writer);
     writer.Indent = writer.Indent - 1;
     writer.WriteLine("]");
 }
示例#6
0
 public HorizontalCoordinateSystem(HorizontalDatum horizontalDatum, AxisInfo[] axisInfoArray,
                                   string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
     : base(remarks, authority, authorityCode, name, alias, abbreviation)
 {
     if (horizontalDatum == null)
     {
         throw new ArgumentNullException("horizontalDatum");
     }
     if (axisInfoArray == null)
     {
         throw new ArgumentNullException("axisInfoArray");
     }
     _horizontalDatum = horizontalDatum;
     _axisInfoArray   = axisInfoArray;
 }
示例#7
0
        internal GeographicCoordinateSystem(
            AngularUnit angularUnit,
            HorizontalDatum horizontalDatum,
            PrimeMeridian primeMeridian,
            AxisInfo axis0,
            AxisInfo axis1,
            string remarks, string authority, string authorityCode, string name, string alias, string abbreviation)
            : base(remarks, authority, authorityCode, name, alias, abbreviation)
        {
            _angularUnit     = angularUnit;
            _horizontalDatum = horizontalDatum;
            _primeMeridian   = primeMeridian;
            _axisInfo        = new AxisInfo[] { axis0, axis1 };

            // define the envelope.
            _defaultEnvelope = new Envelope(-180, -90, 180, 90);
        }
        private static HorizontalDatum ReadHorizontalDatum(WktStreamTokenizer tokenizer, bool includeAuthority)
        {
            //DATUM["OSGB 1936",
            //       SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],
            //       TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]]

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

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("SPHEROID");
            Ellipsoid           ellipsoid     = ReadEllipsoid(tokenizer, includeAuthority);
            string              authority     = String.Empty;
            string              authorityCode = String.Empty;
            WGS84ConversionInfo wgsInfo       = new WGS84ConversionInfo();

            wgsInfo.IsInUse = false;

            if (tokenizer.TryReadToken(","))
            {
                if (tokenizer.TryReadToken("TOWGS84"))
                {
                    wgsInfo = ReadWGS84ConversionInfo(tokenizer, includeAuthority);
                }
                if (includeAuthority)
                {
                    tokenizer.ReadToken(",");
                    tokenizer.ReadAuthority(ref authority, ref authorityCode);
                }
            }
            tokenizer.ReadToken("]");
            // make an assumption about the datum type.
            DatumType       datumType       = DatumType.IHD_Geocentric;
            HorizontalDatum horizontalDatum = new HorizontalDatum(name, datumType, ellipsoid, wgsInfo, String.Empty, authority, authorityCode, String.Empty, String.Empty);

            return(horizontalDatum);
        }
        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
 public HorizontalCoordinateSystem(HorizontalDatum horizontalDatum, AxisInfo[] axisInfoArray)
     : this(horizontalDatum, axisInfoArray, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty)
 {
 }
        public static object Create(string wkt)
        {
            object             returnObject     = null;
            bool               includeAuthority = (wkt.ToLower().IndexOf("authority") != -1);
            StringReader       reader           = new StringReader(wkt);
            WktStreamTokenizer tokenizer        = new WktStreamTokenizer(reader);

            tokenizer.NextToken();
            string objectName = tokenizer.GetStringValue();

            switch (objectName)
            {
            case "UNIT":
                Unit unit = ReadUnit(tokenizer, includeAuthority);
                returnObject = unit;
                break;

            case "VERT_DATUM":
                VerticalDatum verticalDatum = ReadVerticalDatum(tokenizer, includeAuthority);
                returnObject = verticalDatum;
                break;

            case "SPHEROID":
                Ellipsoid ellipsoid = ReadEllipsoid(tokenizer, includeAuthority);
                returnObject = ellipsoid;
                break;

            case "TOWGS84":
                WGS84ConversionInfo wgsInfo = ReadWGS84ConversionInfo(tokenizer, includeAuthority);
                returnObject = wgsInfo;
                break;

            case "DATUM":
                HorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer, includeAuthority);
                returnObject = horizontalDatum;
                break;

            case "PRIMEM":
                PrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer, includeAuthority);
                returnObject = primeMeridian;
                break;

            case "VERT_CS":
                VerticalCoordinateSystem verticalCS = ReadVerticalCoordinateSystem(tokenizer, includeAuthority);
                returnObject = verticalCS;
                break;

            case "GEOGCS":
                GeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer, includeAuthority);
                returnObject = geographicCS;
                break;

            case "PROJCS":
                ProjectedCoordinateSystem projectedCS = ReadProjectedCoordinateSystem(tokenizer, includeAuthority);
                returnObject = projectedCS;
                break;

            case "COMPD_CS":
                CompoundCoordinateSystem compoundCS = ReadCompoundCoordinateSystem(tokenizer, includeAuthority);
                returnObject = compoundCS;
                break;

            case "GEOCCS":
            case "FITTED_CS":
            case "LOCAL_CS":
                throw new NotSupportedException(String.Format("{0} is not implemented.", objectName));

            default:
                throw new ParseException(String.Format("'{0'} is not recongnized.", objectName));
            }
            reader.Close();
            return(returnObject);
        }