关键性代码整理

 

利用AO将平面坐标转换成大地坐标
//利用AO将平面坐标转换成大地坐标
ISpatialReferenceFactory2 pfactory = new SpatialReferenceEnvironmentClass();
IProjectedCoordinateSystem flatref
= pfactory.CreateProjectedCoordinateSystem(54013);
IGeographicCoordinateSystem earthref
= pfactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983);
IPoint pt
= new PointClass();
double x = Convert.ToDouble(txtX.Text);
double y = Convert.ToDouble(txtY.Text);
pt.PutCoords(x, y);
IGeometry geo
= (IGeometry)pt;
geo.SpatialReference
= flatref;
geo.Project(earthref);

plan.FlyTo(pt.X, pt.Y,
1000, 10000, 0, 0, "FlyToLocation");
MessageBox.Show(pt.X
+ " " + pt.Y);
Skyline通过对象名称对对象进行定位
//通过对象名称对对象进行定位
int itemID = infoTree.FindItem("[Free Hand Drawings]\\Triplane");
string objID = infoTree.GetTerraObjectID(itemID);
plan.FlyToObject(objID, ActionCode.AC_FLYTO);
根据数据库中内容生成二级目录
//根据数据库中内容生成二级目录
OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\Data.mdb");
conn.Open();

OleDbDataAdapter oda
=new OleDbDataAdapter("select * from Type",conn);
DataSet dsType
=new DataSet();
oda.Fill(dsType);
DataView dvType
=dsType.Tables[0].DefaultView;

foreach(DataRowView drv in dvType)
{
TreeNode node
=new TreeNode();
node.Text
=drv["Name"].ToString();

int ID=(int)drv["ID"];
oda.SelectCommand.CommandText
="select * from Content where TypeID="+ID;
DataSet dsContent
=new DataSet();
oda.Fill(dsContent);
if (dsContent.Tables[0].Rows.Count > 0)
{
DataView dvContent
= dsContent.Tables[0].DefaultView;
foreach (DataRowView i_drv in dvContent)
{
TreeNode i_node
= new TreeNode();

i_node.Text
= i_drv["Content"].ToString();
node.Nodes.Add(i_node);
}
}
trvContent.Nodes.Add(node);

你可能感兴趣的:(关键性代码整理)