1)构造完成有限元网格后,产生HV表的数据。。
private void button1_Click_1(object sender, EventArgs e)
{
try{
USTC.OleDbc db = new USTC.OleDbc();
IFeatureCursor fc = null;
for (double height = 6; height < 45; height += 0.1)
{
IFeatureLayer layer = (IFeatureLayer)maptool.GetLayerByName("陈南圩区有限元");
fc = maptool.GetCountyFeature(layer, "Avg_elevat<" + height);
//ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet = featureSelection.SelectionSet;
ESRI.ArcGIS.Geodatabase.IFeature ft;
decimal sumArea = 0;
decimal sumVolume = 0;
while ((ft = fc.NextFeature()) != null)
{
try
{
decimal Area = System.Convert.ToDecimal(ft.get_Value(8));
sumArea += Area;
decimal high = System.Convert.ToDecimal(height) - System.Convert.ToDecimal(ft.get_Value(10));
sumVolume += high * Area;
}
catch (Exception ex1)
{
}
}
db.open(@"Provider=Microsoft.ACE.OLEDB.12.0;Data source=D:/工程项目/芜湖3D/my3d.mdb");
db.getData("insert into HV(H,S,V) values(" + height + "," + sumArea + "," + sumVolume + ")", false);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
MessageBox.Show("ok!");
}
2)调用该关系表数据。
public double getHeight(double Volume)
{
USTC.OleDbc db = new USTC.OleDbc();
db.open(@"Provider=Microsoft.ACE.OLEDB.12.0;Data source=D:/工程项目/芜湖3D/my3d.mdb");
DataSet ds=(DataSet)db.getData("select * from HV WHERE V<="+Volume+" ORDER BY V DESC", false);
db.close();
double h= (double)ds.Tables[0].Rows[0]["H"];
return h;
}