#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<sstream>
#include<iomanip>
#include <math.h>
using namespace std;
//將字串轉變為數字
double zhuanzhi(string zifuchuan)
{
double b;
stringstream c;
c << zifuchuan;
c >> b;
return b;
}
int main()
{ //讀取資料
ifstream infile;
infile.open("D:\\XYZ2BLHNEU.xyz", ios::in);
if (!infile)
{
cout << "error" << endl;
}
string line, str_temp;
int start, pos;
int n = 14435;
double X[14435], Y[14435], Z[14435], M[14435];
for (int i = 0; i < n; i++)
{
getline(infile, line);
pos = 0;
start = 0;
pos = line.find(",", start);
start = pos + 1;
pos = line.find(",", start);
str_temp = line.substr(start, pos - start);
X[i] = zhuanzhi(str_temp);
start = pos + 1;
pos = line.find(",", start);
str_temp = line.substr(start, pos - start);
Y[i] = zhuanzhi(str_temp);
start = pos + 1;
pos = line.find("/n", start);
str_temp = line.substr(start, pos - start);
Z[i] = zhuanzhi(str_temp);
}
infile.close();
//定義WGS_84的常用常量
double a = 6378137;//單位為m
double b = 6356752.3142;//單位為m
double e2 = 0.00669437999013; //第一偏心率平方
double E2 = 0.00673949674227;//第二偏心率平方
double pi = 3.1415926535897932;
double c = (a * a) / b;
double k = 1 + E2;
double B[14435], L[14435], H[14435], t0[14435], p[14435], N[14435];
for (int j = 0;j < n;j++)
{
M[j] = Y[j] / X[j];
L[j] = atan(M[j]);
t0[j] = Z[j] / sqrt(X[j] * X[j] + Y[j] * Y[j]);
p[j] = c * e2 / sqrt(X[j] * X[j] + Y[j] * Y[j]);
double s = 1,t2 = t0[j],t3 ;
while (s > 0.001)
{
t3 = t0[j] + p[j] * t2 / sqrt(k + t2 * t2);
s = fabs(t3 - t2);
t2 = t3;
}
B[j] = atan(t3);
N[j] = c / sqrt(1 + E2 * cos(B[j] * cos(B[j])));
H[j] = sqrt(X[j] * X[j] + Y[j] * Y[j]) / cos(B[j]) - N[j];
}
//輸出坐標結果到檔案
ofstream outfile;
outfile.open("D:\\BLH.txt");
for (int f = 0;f < n;f++)
{
outfile << f + 1 << setiosflags(ios::fixed) << setprecision(4) << "," << B[f] << "," << L[f] << "," << H[f] << endl;
}
outfile.close();
return 0;
}
為什么系統會
0x00A727B9 處(位于 地心地固坐標系轉換.exe 中)引發的例外: 0xC0000005: 讀取位置 0x01200000 時發生訪問沖突。
的錯誤,求講解!
uj5u.com熱心網友回復:
Linux:行程意外退出會在當前目錄下產生‘core’檔案或形如‘core.數字’的檔案比如‘core.1234’
使用命令
gdb 運行程式名 core或core.數字
進入gdb然后使用bt命令
可以查看行程意外退出前函式呼叫的堆疊,內容為從上到下列出對應從里層到外層的函式呼叫歷史。
如果行程意外退出不產生core檔案,參考“ulimit -c core檔案最大塊大小”命令
Windows:
崩潰的時候在彈出的對話框按相應按鈕進入除錯,按Alt+7鍵查看Call Stack即“呼叫堆疊”里面從上到下列出的對應從里層到外層的函式呼叫歷史。雙擊某一行可將游標定位到此次呼叫的源代碼或匯編指令處,看不懂時雙擊下一行,直到能看懂為止。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/232770.html
標籤:C++ 語言
