コード例 #1
0
 //SPHEROID["WGS_1984",6378137.0,298.257223563]
 public Spheroid(WktItem wktItem)
 {
     string[] vs = wktItem.Value.Split(',');
     Name              = vs[0].Replace("\"", string.Empty);
     SemimajorAxis     = double.Parse(vs[1]);
     InverseFlattening = double.Parse(vs[2]);
 }
コード例 #2
0
        public WktItem GetWktItem(string name)
        {
            WktItem item = null;

            GetWktItem(name, this, ref item);
            return(item);
        }
コード例 #3
0
 public GeographicCoordSystem(WktItem wktItem)
 {
     _name              = wktItem.Value.Split(',')[0].Replace("\"", string.Empty);
     _angularUnit       = new AngularUnit(wktItem.GetWktItem("UNIT"));
     _primeMeridian     = new PrimeMeridian(wktItem.GetWktItem("PRIMEM"));
     _datum             = new Datum(wktItem.GetWktItem("DATUM"));
     _oracleSpatialSRID = int.MinValue;
 }
コード例 #4
0
 private void GetWktItem(string name, WktItem beginWktItem, List <WktItem> items)
 {
     if (beginWktItem.Name.ToUpper() == name.ToUpper())
     {
         items.Add(beginWktItem);
     }
     if (beginWktItem.Items.Count > 0)
     {
         foreach (WktItem it in beginWktItem.Items)
         {
             GetWktItem(name, it, items);
         }
     }
 }
コード例 #5
0
 private void GetWktItem(string name, WktItem beginWktItem, ref WktItem item)
 {
     if (beginWktItem.Name.ToUpper() == name.ToUpper())
     {
         item = beginWktItem;
         return;
     }
     if (beginWktItem.Items.Count > 0)
     {
         foreach (WktItem it in beginWktItem.Items)
         {
             GetWktItem(name, it, ref item);
         }
     }
 }
コード例 #6
0
ファイル: WktParserBase.cs プロジェクト: configare/hispeed
        public ISpatialReference Parse(string wkt)
        {
            _rootWktItem = new WktSpliter().Split(wkt);
            bool isPrj = IsProjectionCoordSystem();
            bool isGeo = IsGeographicCoordSystem();

            if (!isPrj && !isGeo)
            {
                throw new Exception("本系统只支持地理坐标系统与投影坐标系统,坐标系统\"" + _rootWktItem.Name + "\"不受支持。");
            }
            IGeographicCoordSystem _geoCoordSystem = null;
            IProjectionCoordSystem _prjCoordSystem = null;

            _geoCoordSystem = ParseGeoCoordSystem(_rootWktItem.GetWktItem(cstGeoCoordSystem));
            _prjCoordSystem = ParseProjectionCoordSystem(_rootWktItem.GetWktItem(cstPrjCoordSystem));
            return(new SpatialReference(_geoCoordSystem, _prjCoordSystem));
        }
コード例 #7
0
        private NameMapItem GetPrjName(WktItem wktItem)
        {
            using (OGCWkt2Proj4Mapper map = new OGCWkt2Proj4Mapper())
            {
                string prjName = wktItem.Value.Split(',')[0].Replace("\"", string.Empty);
                switch (_wktSource)
                {
                case enumWKTSource.EsriPrjFile:
                    return(map.GetPrjNameFromEsriName(prjName));

                case enumWKTSource.GDAL:
                    return(map.GetPrjNameFromWKTName(prjName));

                default:
                    return(map.GetPrjNameFromWKTName(prjName));
                }
            }
        }
コード例 #8
0
        /*
         * PROJECTION["Mercator"],
         * PARAMETER["False_Easting",0.0],
         * PARAMETER["False_Northing",0.0],
         * PARAMETER["Central_Meridian",0.0],
         * PARAMETER["Standard_Parallel_1",0.0],
         * UNIT["Meter",1.0]
         */
        protected override IProjectionCoordSystem ParseProjectionCoordSystem(WktItem wktItem)
        {
            if (wktItem == null)//Is Graphics Coordinate System
            {
                return(null);
            }
            string      name    = wktItem.Value.Split(',')[0].Replace("\"", string.Empty);
            NameMapItem prjName = GetPrjName(wktItem.GetWktItem("PROJECTION"));

            if (prjName == null)
            {
                throw new Exception("投影坐标系统\"" + name + "\"没有在系统中预先配置。");
            }
            NameValuePair[]       parameters = GetPrjParameters(wktItem.GetWktItems("PARAMETER"));
            AngularUnit           unit       = new AngularUnit(wktItem.GetWktItem("UNIT"));
            ProjectionCoordSystem prj        = new ProjectionCoordSystem(prjName, parameters, unit);

            prj.NameDes = name;
            return(prj);
        }
コード例 #9
0
        private NameValuePair[] GetPrjParameters(WktItem[] wktItems)
        {
            List <NameValuePair> values = new List <NameValuePair>();

            using (OGCWkt2Proj4Mapper map = new OGCWkt2Proj4Mapper())
            {
                for (int i = 0; i < wktItems.Length; i++)
                {
                    NameMapItem name   = null;
                    WktItem     witem  = wktItems[i];
                    string[]    vs     = witem.Value.Split(',');
                    string      pname  = vs[0].Replace("\"", string.Empty);
                    double      pvalue = double.Parse(vs[1]);
                    try
                    {
                        switch (_wktSource)
                        {
                        case enumWKTSource.EsriPrjFile:
                            name = map.GetParameterFromEsriName(pname);
                            break;

                        case enumWKTSource.GDAL:
                            name = map.GetParameterFromWKTName(pname);
                            break;

                        default:
                            name = map.GetParameterFromWKTName(pname);
                            break;
                        }
                        if (name != null)
                        {
                            values.Add(new NameValuePair(name, pvalue));
                        }
                    }
                    catch { continue; }
                }
            }
            return(values.Count > 0 ? values.ToArray() : null);
        }
コード例 #10
0
        public WktItem Split(string wkt)
        {
            Stack <char>   stack    = new Stack <char>();
            List <WktItem> subitems = new List <WktItem>();
            bool           hasLeft  = false;

            for (int i = 0; i < wkt.Length; i++)
            {
                stack.Push(wkt[i]);
                if (wkt[i] == ']')
                {
                    string str      = null;
                    bool   passLeft = false;
                    do
                    {
                        char c = stack.Pop();
                        if (c == '[')
                        {
                            passLeft = true;
                        }
                        str = c + str;
                    }while (!(stack.Count == 0 || (passLeft && stack.Peek() == ',')));
                    //
                    WktItem it = new WktItem(str);
                    if (!hasLeft)
                    {
                        it.Items.AddRange(subitems);
                        subitems.Clear();
                    }
                    subitems.Add(it);
                    hasLeft = false;
                }
                else if (wkt[i] == '[')
                {
                    hasLeft = true;
                }
            }
            return(subitems[0]);
        }
コード例 #11
0
 //PRIMEM["Greenwich",0.0]
 public PrimeMeridian(WktItem wktItem)
 {
     string[] vs = wktItem.Value.Split(',');
     Name  = vs[0].Replace("\"", string.Empty);
     Value = double.Parse(vs[1]);
 }
コード例 #12
0
 //UNIT["Degree",0.0174532925199433]
 public AngularUnit(WktItem wktItem)
 {
     string[] vs = wktItem.Value.Split(',');
     Name  = vs[0].Replace("\"", string.Empty);
     Value = double.Parse(vs[1]);
 }
コード例 #13
0
 public void Add(WktItem it)
 {
     Items.Add(it);
 }
コード例 #14
0
ファイル: WktParserBase.cs プロジェクト: configare/hispeed
 protected IGeographicCoordSystem ParseGeoCoordSystem(WktItem wktItem)
 {
     return(new GeographicCoordSystem(wktItem));
 }
コード例 #15
0
ファイル: WktParserBase.cs プロジェクト: configare/hispeed
 protected abstract IProjectionCoordSystem ParseProjectionCoordSystem(WktItem wktItem);
コード例 #16
0
ファイル: Datum.cs プロジェクト: configare/hispeed
 //DATUM["D_WGS_1984",
 //             SPHEROID["WGS_1984",6378137.0,298.257223563]
 //            ]
 public Datum(WktItem wktItem)
 {
     Spheroid = new Spheroid(wktItem.GetWktItem("SPHEROID"));
     Name     = (wktItem.Value.Split(',')[0]).Replace("\"", string.Empty);
 }