📄 modelspatialrefprop.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Reflection;
using ESRI.ArcGIS.Geometry;
namespace ChangeXMLPrj
{
public class ModelSpatialRefProp
{
private double Res = Math.Pow(2, 53) - 2;
XMLEditor pxmledit = null;
public ModelSpatialRefProp(XMLEditor xmledit)
{
pxmledit = xmledit;
}
#region 字段
private string pSpatialRef = null;
/// <summary>
/// 无用
/// </summary>
public string SpatialRef
{
get { return pSpatialRef; }
set { pSpatialRef = value; }
}
private string pWKT = null;
public string WKT
{
get { return pWKT; }
set { pWKT = value; }
}
private string pXOrigin = null;
public string XOrigin
{
get { return pXOrigin; }
set { pXOrigin = value; }
}
private string pYOrigin = null;
public string YOrigin
{
get { return pYOrigin; }
set { pYOrigin = value; }
}
private string pXYScale = null;
public string XYScale
{
get { return pXYScale; }
set { pXYScale = value; }
}
private string pZOrigin = null;
public string ZOrigin
{
get { return pZOrigin; }
set { pZOrigin = value; }
}
private string pZScale = null;
public string ZScale
{
get { return pZScale; }
set { pZScale = value; }
}
private string pMOrigin = null;
public string MOrigin
{
get { return pMOrigin; }
set { pMOrigin = value; }
}
private string pMScale = null;
public string MScale
{
get { return pMScale; }
set { pMScale = value; }
}
private string pXYTolerance = null;
public string XYTolerance
{
get { return pXYTolerance; }
set { pXYTolerance = value; }
}
private string pZTolerance = null;
public string ZTolerance
{
get { return pZTolerance; }
set { pZTolerance = value; }
}
private string pMTolerance = null;
public string MTolerance
{
get { return pMTolerance; }
set { pMTolerance = value; }
}
#endregion
private ISpatialReference psp = null;
public ISpatialReference ISpatialRef
{
get { return psp; }
set { psp = value;}
}
private bool hasWKT = false;
private bool hasM = false;
private bool hasZ = false;
#region 获取参照系值
private void CheckSpRefM(XmlNode node)
{
if (hasM)
{
return;
}
if (pMOrigin == null && node[All.tagMOrigin] != null)
{
//hasM = true;
pMOrigin = node[All.tagMOrigin].InnerText;
}
if (pMScale == null && node[All.tagMScale] != null)
{
pMScale = node[All.tagMScale].InnerText;
}
if (pMTolerance == null && node[All.tagMTolerance] != null)
{
pMTolerance = node[All.tagMTolerance].InnerText;
}
}
private void CheckSpRefZ(XmlNode node)
{
if(hasZ )
{
return ;
}
if (pZOrigin == null && node[All.tagZOrigin] != null)
{
hasZ = true;
pZOrigin = node[All.tagZOrigin].InnerText;
}
if (pZScale == null && node[All.tagZScale] != null)
{
pZScale = node[All.tagZScale].InnerText;
}
if (pZTolerance == null && node[All.tagZTolerance] != null)
{
pZTolerance = node[All.tagZTolerance].InnerText;
}
}
private void ParseSpRefNode(XmlNode node)
{
try
{
if (hasWKT)
{
return;
}
if (pSpatialRef == null && node[All.tagSpatialRef] != null)
{
pSpatialRef = node[All.tagSpatialRef].InnerText;
}
if (pWKT == null || node[All.tagWKT] != null)
{
pWKT = node[All.tagWKT].InnerText ;
//hasWKT = true;
}
if (pXOrigin == null || node[All.tagXOrigin] != null)
{
pXOrigin = node[All.tagXOrigin].InnerText;
}
if (pXYScale == null || node[All.tagXYScale] != null)
{
pXYScale = node[All.tagXYScale].InnerText;
}
if (pXYTolerance == null || node[All.tagXYTolerance] != null)
{
pXYTolerance = node[All.tagXYTolerance].InnerText;
}
if (pYOrigin == null || node[All.tagYOrigin] != null)
{
pYOrigin = node[All.tagYOrigin].InnerText;
}
}
catch (Exception ex)
{
//throw new Exception(ex.Message);
}
}
public void ParseSpatialRefNodeToProp(XmlNode[] nodes)
{
double dblxorign=0;
double dblyorign=0;
double dblxmax=0;
double dblymax=0;
psp.GetDomain(out dblxorign, out dblxmax, out dblyorign, out dblymax);
int dblxyscale =Convert.ToInt32( Res / (dblymax - dblyorign));
double dblzorign=0;
double dblzmax=0;
psp.GetZDomain(out dblzorign, out dblzmax);
int dblzscale =Convert.ToInt32( Res / (dblzmax - dblzorign));
double dblmorign = 0;
double dblmmax = 0;
psp.GetMDomain(out dblmorign,out dblmmax );
int dblmscale = Convert.ToInt32( Res / (dblmmax - dblmorign));
#region
for (int i = 0; i < nodes.Length; i++)
{
if (i == 16)
{
}
//ParseSpRefNode(nodes[i]);
//CheckSpRefM(nodes[i]);
//CheckSpRefZ(nodes[i]);
Console.Write("\r\n" + i.ToString() + " #################");
this.PrintArgs();
pxmledit.UpdateXmlRefTypeAttrbution(nodes[i], All.tagAttrvaluePCS);
pxmledit.UpdateChildValue(nodes[i], All.tagWKT , opera.getPrjText());
pxmledit.UpdateChildValue(nodes[i], All.tagXOrigin, dblxorign.ToString());
pxmledit.UpdateChildValue(nodes[i], All.tagYOrigin, dblyorign.ToString());
pxmledit.UpdateChildValue(nodes[i], All.tagXYScale, dblxyscale.ToString());
pxmledit.UpdateChildValue(nodes[i], All.tagZOrigin, dblzorign.ToString());
pxmledit.UpdateChildValue(nodes[i], All.tagZScale, dblzscale.ToString());
pxmledit.UpdateChildValue(nodes[i], All.tagMOrigin, dblmorign.ToString());
pxmledit.UpdateChildValue(nodes[i], All.tagMScale, dblmscale.ToString());
}
#endregion
}
#endregion
/// <summary>
/// 改写值
/// </summary>
/// <param name="nodes"></param>
public void ArgsSetToSpaRef(XmlNode[] nodes)
{
}
/// <summary>
/// 输出参数信息值
/// </summary>
public void PrintArgs()
{
string msg = "\r\n";
PropertyInfo [] flds= this.GetType().GetProperties ();
for (int i = 0; i < flds.Length; i++)
{
object ss=flds[i].GetValue(this,null );
if (ss != null)
{
msg += "\t" + flds[i].Name + "\t" + ss.ToString() + "\r\n";
}
}
Console.WriteLine(msg);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -