Пример #1
0
        private int GetSridFromAuthorityNode(EsriPrjTreeNode authorityNode)
        {
            int srid = 0;

            if (authorityNode?.Values?.Count == 2 && authorityNode?.Values?[0] == _epsg)
            {
                int.TryParse(authorityNode.Values[1], out srid);
            }

            return(srid);
        }
Пример #2
0
        public EsriPrjFile(EsriPrjTreeNode root)
        {
            this._root = root;

            //sample: AUTHORITY["EPSG", "4326"]
            //var authorityInfo = root.Children.SingleOrDefault(i => i.Name == _authority)?.Values;

            //int srid = 0;

            //if (authorityInfo != null && authorityInfo.Count == 2 && authorityInfo?[0] == _epsg)
            //{
            //    int.TryParse(authorityInfo[1], out srid);
            //}

            this._srid = GetCrsSrid();
        }
        public EsriPrjTreeNode(IRI.Msh.CoordinateSystem.IEllipsoid ellipsoid, string title, int srid)
        {
            this.Name = EsriPrjFile._geogcs;

            this.Values = new List <string>()
            {
                title ?? $"GCS_{ellipsoid.EsriName}"
            };

            //esri write zero for Inverse Flattening of shperes!
            var inverseFlattening = double.IsInfinity(ellipsoid.InverseFlattening) ? 0 : ellipsoid.InverseFlattening;

            var spheroid = new EsriPrjTreeNode(EsriPrjFile._spheroid, ellipsoid.EsriName, ellipsoid.SemiMajorAxis.Value.AsExactString(), inverseFlattening.AsExactString());

            var datum = new EsriPrjTreeNode(EsriPrjFile._datum, $"D_{ellipsoid.EsriName}")
            {
                Children = new List <EsriPrjTreeNode>()
                {
                    spheroid
                }
            };

            var primem = new EsriPrjTreeNode(EsriPrjFile._primem, EsriPrjFile._greenwich, "0.0");

            var unit = new EsriPrjTreeNode(EsriPrjFile._unit, EsriPrjFile._degree, EsriPrjFile._degreeValue);

            this.Children = new List <EsriPrjTreeNode>()
            {
                datum, primem, unit
            };

            if (srid != 0)
            {
                var authority = new EsriPrjTreeNode(EsriPrjFile._authority, EsriPrjFile._epsg, srid.ToString());

                this.Children.Add(authority);
            }
        }
Пример #4
0
 public static EsriPrjFile Parse(string esriWktPrj)
 {
     return(new EsriPrjFile(EsriPrjTreeNode.Parse(esriWktPrj)));
 }
Пример #5
0
        public EsriPrjFile(string prjFileName)
        {
            this._root = EsriPrjTreeNode.Parse(System.IO.File.ReadAllText(prjFileName));

            this._srid = GetCrsSrid();
        }