观测数据的组织 以以下水准网为例

已知高程:
点名 | 高程(m) | 备注 |
BM01 | 11.000 |
|
BM02 | 11.500 |
|
BM03 | 12.008 |
|
观测值:
序号 | 起点 | 终点 | 高差(m) | 距离(km) | 备注 |
1 | BM01 | BP01 | 1.003 | 1.0 |
|
2 | BMP1 | BP02 | 0.5018 | 2.1 |
|
3 | BM03 | BP02 | 0.503 | 2.2 |
|
4 | BM02 | BP01 | 0.505 | 1.2 |
|
数据格式说明:
==========================================================
第一类数据:
水准网信息数据,这里是指第1-2行数据,分别为已知点个数,未知点个数,观测值个数,以及水准网点名信息,具体排序已知点在前,未知点在后面。
第二类数据:
已知点高程信息,这里是第2~4行,包括三个已知点及其高程值。
第三类数据:
观测信息,数据这里是指第5~11行,包括起点号 终点号 高差观测值 距离;高差观测值单位为米,距离的单位为公里。
===================================================================
控制网概况信息表
3 2 4(已知点个数、未知点个数、观测值个数)
BM01 BM02 BM03 BP01 BP02 BP03 (点号名称)
已知点信息
BM01 11.000 (已知点点号 高程)
BM02 11.500
BM03 12.008
观测信息表
(起点点号、终点点号、高差观测值、距离观测值)
1 BM01 BP01 1.0031 1.0
2 BMP1 BP02 0.50181 2.1
3 BM03 BP02 0.5031 2.2
4 BM02 BP01 0.5051 1.2
===================================================
为便于表达和存储水准网数据信息,需要对牵涉到的变量进行事先设计约定,变量约定的原则是便于表达,便于认知水准网信息。
数据文本文件:原始数据文件,计算结果文件。
数据变量命名规则:每个变量的命名尽量由变量名识别变量的含义,便于理解记忆,
因存在多个程序和变量,涉及水准网平差信息的变量在各个子程序之间使用,因此,均设定为全局变量。
这里主要是指:点名、高差、高程距离、测站数等信息。
水准网数据变量的约定表 |
变量名 | 说明 | 备注 |
k1 k2 | 起点 终点数组 |
|
knP | 已知点 |
|
unP | 待定点 |
|
Pn | 点号 |
|
h0 | 已知点高程 |
|
h1 | 高差观测值 |
|
Dis | 距离观测值 |
|
Diffh | 高差观测值 |
|
X0 | 高程近似值 |
|
Delta_X | 高程未知数 |
|
观测数据的由文本文件组成,首先读取控制网信息,然后读取观测值信息,并存入相应的数组。这里涉及到水准网观测信息,已知数据信息,网的概括信息等。
{
//数据读入
string FilePath = null;
Console.WriteLine("请选择文件: ");//这里输入文本所在目录
FilePath = Console.ReadLine();
StreamReader rd = File.OpenText(FilePath);
string BY = rd.ReadLine();
BY = rd.ReadLine();//前两行不要
string s = rd.ReadLine();
string[] ss = s.Split(new char[] {'\t'}, StringSplitOptions.RemoveEmptyEntries);
int s1 = int.Parse(ss[0]); //已知点个数
int s2 = int.Parse(ss[1]); //未知点个数
int s3 = int.Parse(ss[2]);//观测值个数
BY = rd.ReadLine();
BY = rd.ReadLine();
BY = rd.ReadLine();
BY = rd.ReadLine();//舍弃四行
string[] KN = new string[s1];//已知点点号
double[] H0 = new double[s1 + s2];//点的高程
double[,] H00 = new double[s2,1];//未知点的高程
for (int i = 0; i < s1; i++) //读入数据并赋予数组
{
string line = rd.ReadLine();
string[] data = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
KN[i] = data[0];//已知点点号
H0[i] = double.Parse(data[1]);//已知点高程
}
BY = rd.ReadLine();
BY = rd.ReadLine();
BY = rd.ReadLine();//舍弃三行
string[] UN = new string[s2];//未知点点号
s = rd.ReadLine();
UN = s.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
BY = rd.ReadLine();
BY = rd.ReadLine();
BY = rd.ReadLine();
BY = rd.ReadLine();//舍弃四行
string[] K1 = new string[s3]; //起点数组
string[] K2 = new string[s3]; //钟点数组
double[] H1 = new double[s3];//高差观测值
double[] Dis = new double[s3];//距离观测值
for (int i = 0; i < s3; i++)
{
string line = rd.ReadLine();
string[] data = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
K1[i] = data[0];
K2[i] = data[1];
H1[i] = double.Parse(data[2]);
读取数据参考代码
{
//数据读入
string FilePath = null;
Console.WriteLine("请选择文件: ");//这里输入文本所在目录
FilePath = Console.ReadLine();
StreamReader rd = File.OpenText(FilePath);
string BY = rd.ReadLine();
BY = rd.ReadLine();//前两行不要
string s = rd.ReadLine();
string[] ss = s.Split(new char[] {'\t'}, StringSplitOptions.RemoveEmptyEntries);
int s1 = int.Parse(ss[0]); //已知点个数
int s2 = int.Parse(ss[1]); //未知点个数
int s3 = int.Parse(ss[2]);//观测值个数
BY = rd.ReadLine();
BY = rd.ReadLine();
BY = rd.ReadLine();
BY = rd.ReadLine();//舍弃四行
string[] KN = new string[s1];//已知点点号
double[] H0 = new double[s1 + s2];//点的高程
double[,] H00 = new double[s2,1];//未知点的高程
for (int i = 0; i < s1; i++) //读入数据并赋予数组
{
string line = rd.ReadLine();
string[] data = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
KN[i] = data[0];//已知点点号
H0[i] = double.Parse(data[1]);//已知点高程
}
BY = rd.ReadLine();
BY = rd.ReadLine();
BY = rd.ReadLine();//舍弃三行
string[] UN = new string[s2];//未知点点号
s = rd.ReadLine();
UN = s.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
BY = rd.ReadLine();
BY = rd.ReadLine();
BY = rd.ReadLine();
BY = rd.ReadLine();//舍弃四行
string[] K1 = new string[s3]; //起点数组
string[] K2 = new string[s3]; //钟点数组
double[] H1 = new double[s3];//高差观测值
double[] Dis = new double[s3];//距离观测值
for (int i = 0; i < s3; i++)
{
string line = rd.ReadLine();
string[] data = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
K1[i] = data[0];
K2[i] = data[1];
H1[i] = double.Parse(data[2]);
private void button2_Click(object sender, EventArgs e)
{
System.Data.DataTable dataTable = new System.Data.DataTable("观测数据表");
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "数据导入";
ofd.Filter = "文本文档|*.txt";
if (ofd.ShowDialog() == DialogResult.OK)
{
string fileName = ofd.FileName;
InitializeTable(dataTable);
DateOperator.ReadDataFromFile(fileName, dataTable);
MessageBox.Show("导入成功!", "提示");
}
}