Exemple #1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         if (String.IsNullOrEmpty(txtPrjName.Text) || txtPrjName.Text == "<自定义>")
         {
             MessageBox.Show("投影坐标系统名称不能为空!", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txtPrjName.Focus();
             return;
         }
         linearUnit.CollectionAguments();
         projectionParam.CollectionAguments();
         if (geoCoordParamDisplay._dialogResult == System.Windows.Forms.DialogResult.OK)
         {
             _geographicCoordSystem = geoCoordParamDisplay.GeoCoordSystem;
         }
         else
         {
             _geographicCoordSystem = _spatialReference.GeographicsCoordSystem;
         }
     }
     catch
     {
         MessageBox.Show("投影坐标系统参数不完整!", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     CreatProjSystem();
     if (!String.IsNullOrEmpty(txtPrjName.Text) && txtPrjName.Text != "<自定义>")
     {
         _spatialSystemName = txtPrjName.Text;
     }
     _spatialReference.Name = _spatialSystemName;
     DialogResult           = System.Windows.Forms.DialogResult.OK;
 }
 public GeoCoordinateDefine(IGeographicCoordSystem GeoCoordSystem, enumControlType ControlType)
 {
     _geographicCoordSystem = GeoCoordSystem;
     _controlType           = ControlType;
     InitializeComponent();
     Init();
 }
 public bool IsSame(IGeographicCoordSystem geoCoordSys)
 {
     return(_angularUnit != null &&
            _primeMeridian != null &&
            _datum != null &&
            _angularUnit.IsSame(geoCoordSys.AngularUnit) &&
            _primeMeridian.IsSame(geoCoordSys.PrimeMeridian) &&
            _datum.IsSame(geoCoordSys.Datum));
 }
        private void CreatGeoReference()
        {
            AngularUnit   geoAngularUnit   = new AngularUnit(angularUnit.AngularUnitName, angularUnit.AngularUnitValue);
            Datum         geoDatum         = new Datum(datum.DatumName, datum.DatumSpheroid);
            PrimeMeridian geoPrimeMeridian = new PrimeMeridian(primeMeridian.PrimeMeridianName, primeMeridian.PrimeMeridianValue);

            _geographicCoordSystem = new GeographicCoordSystem(_geoSystemName, geoAngularUnit, geoPrimeMeridian, geoDatum);
            _spatialReference      = new SpatialReference(_geographicCoordSystem);
        }
Exemple #5
0
 public SpatialReference(IGeographicCoordSystem geoCoordSystem, IProjectionCoordSystem prjCoordSystem)
     : this(geoCoordSystem)
 {
     _prjCoordSystem = prjCoordSystem;
     if (_prjCoordSystem != null)
     {
         _name = _prjCoordSystem.NameDes;
         _oracleSpatialSRID = _prjCoordSystem.ToOracleSpatialSRID();
     }
 }
 private void ShowGeoCoordSystem()
 {
     if (_spatialReference == null || _spatialReference.GeographicsCoordSystem == null)
     {
         txtShow.Text = "此空间参考错误,地理坐标系统为空";
         return;
     }
     txtShow.Text    = _spatialReference.GeographicsCoordSystem.ToString();
     _geoCoordSystem = _spatialReference.GeographicsCoordSystem;
 }
        private void btnSelect_Click(object sender, EventArgs e)
        {
            GeoSystemTree spatialRefTree = new GeoSystemTree();

            spatialRefTree.ShowDialog();
            if (spatialRefTree.CurrentGeoCoordSystem != null)
            {
                _geoCoordSystem = spatialRefTree.CurrentGeoCoordSystem;
                txtShow.Text    = _geoCoordSystem.ToString();
                _dialogResult   = DialogResult.OK;
            }
        }
 private void TryApplyGeo(GeoCoordinateDefine geoCoordinateDefine)
 {
     geoCoordinateDefine.ShowDialog();
     if (geoCoordinateDefine.DialogResult == System.Windows.Forms.DialogResult.OK)
     {
         if (geoCoordinateDefine.GeographicCoordSystem != null)
         {
             _geoCoordSystem        = geoCoordinateDefine.GeographicCoordSystem;
             _spatialReference      = new SpatialReference(_geoCoordSystem);
             txtSpatialRefInfo.Text = _spatialReference.ToString();
         }
     }
 }
Exemple #9
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (!(tvSpatialRefTree.SelectedNode.Tag as SpatialReferenceFile).IsPrjFile)
     {
         return;
     }
     if ((tvSpatialRefTree.SelectedNode.Tag as SpatialReferenceFile).SpatialReference.GeographicsCoordSystem == null)
     {
         return;
     }
     _currentGeoCoordSystem = (tvSpatialRefTree.SelectedNode.Tag as SpatialReferenceFile).SpatialReference.GeographicsCoordSystem;
     Close();
 }
 public void CollectionArgumentsCreat()
 {
     using (GeoCoordinateDefine geoCoordinateDefine = new GeoCoordinateDefine(_spatialReference, enumControlType.Creat))
     {
         if (geoCoordinateDefine.ShowDialog() == DialogResult.OK)
         {
             _geoCoordSystem = geoCoordinateDefine.GeographicCoordSystem;
         }
         else if (_spatialReference != null)
         {
             _geoCoordSystem = _spatialReference.GeographicsCoordSystem;
         }
     }
 }
Exemple #11
0
        public ISpatialReference Parse(string proj4)
        {
            if (string.IsNullOrEmpty(proj4))
            {
                return(null);
            }
            proj4 = proj4.ToLower();
            string[] parts = proj4.Split('+');
            if (parts.Length < 2)
            {
                return(null);
            }
            Dictionary <string, string> nameValuePairs = new Dictionary <string, string>();

            foreach (string part in parts)
            {
                string[] it = part.Trim().Split('=');
                if (it.Length < 2)
                {
                    continue;
                }
                nameValuePairs.Add(it[0], it[1]);
            }
            if (!nameValuePairs.Keys.Contains("proj"))
            {
                return(null);
            }
            IGeographicCoordSystem geoCoordSystem = GetGeoCoordSystemByProj4(nameValuePairs);

            if (nameValuePairs.ContainsKey("a"))
            {
                geoCoordSystem.Datum.Spheroid.SemimajorAxis = double.Parse(nameValuePairs["a"]);
            }
            if (nameValuePairs.ContainsKey("b"))
            {
                geoCoordSystem.Datum.Spheroid.SemiminorAxis = double.Parse(nameValuePairs["b"]);
            }
            if (nameValuePairs.ContainsKey("f"))
            {
                geoCoordSystem.Datum.Spheroid.InverseFlattening = 1 / double.Parse(nameValuePairs["f"]);
            }
            IProjectionCoordSystem prjCoordSystem   = GetPrjCoordSystemByProj4(nameValuePairs);
            ISpatialReference      spatialReference = new SpatialReference(geoCoordSystem, prjCoordSystem);

            if (prjCoordSystem != null)
            {
                spatialReference.Name = GetSpatialNameByPrjName(prjCoordSystem.Name.Name);
            }
            return(spatialReference);
        }
        public void CollectionArgumentsModify()
        {
            _geoCoordSystem = _spatialReference.GeographicsCoordSystem;
            GeoCoordinateDefine geoCoordinateDefine = new GeoCoordinateDefine(_spatialReference, enumControlType.Modify);

            geoCoordinateDefine.ShowDialog();
            if (geoCoordinateDefine.DialogResult == DialogResult.OK)
            {
                //{
                _geoCoordSystem = geoCoordinateDefine.GeographicCoordSystem;
            }
            // btnModify.Enabled = true;
            // }
            //else if (geoCoordinateDefine.DialogResult == DialogResult.Cancel)
            //    return;
        }
Exemple #13
0
        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));
        }
Exemple #14
0
 public SpatialReference(IGeographicCoordSystem geoCoordSystem)
 {
     _geoCoordSystem    = geoCoordSystem;
     _name              = _geoCoordSystem.Name;
     _oracleSpatialSRID = geoCoordSystem.ToOracleSpatialSRID();
 }