/******************** (C) COPYRIGHT 2022 Geek************************************ * File Name : PDR_KmlSupport.cpp * Current Version : V1.0 * Author : logzhan * Date of Issued : 2022.09.15 * Comments : PDR Google地图KML格式输出 ********************************************************************************/ #include "KmlSupport.h" #include using namespace PDR; /**---------------------------------------------------------------------- * Function : KmlWrite * Description : 将pdr算法输出的gps和pdr轨迹写为kml形式 * path : kml文件的输出文件路径 * name : kml文件主体名称 * postfix :在主体名称后面添加的后缀,用于区分类型或者版本 * Date : 2020/11/1 logzhan *---------------------------------------------------------------------**/ void KmlWrite(string path, string name, string postfix, vector& gps, vector& pdr) { string pdrColor = "ff0000ff"; string gpsColor = "ff00ffff"; if (path == "") { return; } string kmlPath = path + name + postfix + ".kml"; string kmlName = name + postfix; FILE* fid = NULL; fopen_s(&fid,kmlPath.c_str(), "w"); if (fid == NULL) { return; } fprintf(fid, "\n"); fprintf(fid, "\n"); fprintf(fid, "\t\n"); fprintf(fid, "\t\t%s\n", kmlName.c_str()); fprintf(fid, "\t\t\n"); fprintf(fid, "\t\tGPS Fixs\n"); // 写gps结果 for (int i = 0; i < gps.size(); i++) { fprintf(fid, "\t\t\n"); fprintf(fid, "\t\t\t\n"); // 写入时间信息 //double h, m, s; //pdr_utc2hms(gps[i].utcTime, &h, &m, &s); //fprintf(fid, "\t\t\t\n"); //fprintf(fid, "\t\t\t\t2021-01-22T%s:%s:%s\n", time2str(h).c_str(), // time2str(m).c_str(), time2str(s).c_str()); //fprintf(fid, "\t\t\t\n"); // 写入描述信息 fprintf(fid, "\t\t\t\n"); fprintf(fid, "\t\t\t\t\n"); fprintf(fid, "\t\t\t\t
East : 0.0 (m/s)
\n"); fprintf(fid, "\t\t\t\t
HDOP : %.2f (m/s)
\n", gps[i].hdop); fprintf(fid, "\t\t\t\t
accuracy : %.2f (m)
\n", gps[i].accuracy); fprintf(fid, "\t\t\t\t
speed : %.2f (m/s)
\n", gps[i].vel); fprintf(fid, "\t\t\t\t
Heading : %.2f (degrees)
\n", gps[i].heading); fprintf(fid, "\t\t\t\t
]]>\n"); fprintf(fid, "\t\t\t
\n"); // 写入坐标信息 fprintf(fid, "\t\t\t\n"); fprintf(fid, "\t\t\t\t%.10f,%.10f\n", gps[i].lon, gps[i].lat); fprintf(fid, "\t\t\t\n"); fprintf(fid, "\t\t
\n"); } fprintf(fid, "\t\t
\n"); fprintf(fid, "\t\t\n"); fprintf(fid, "\t\tPDR Fixs\n"); // 写pdr结果 for (int i = 0; i < pdr.size(); i++) { fprintf(fid, "\t\t\n"); fprintf(fid, "\t\t\t\n"); // 写入时间信息 //double h, m, s; //pdr_utc2hms(resTracks.pdrTrack[i].time, &h, &m, &s); //fprintf(fid, "\t\t\t\n"); //fprintf(fid, "\t\t\t\t2021-01-22T%s:%s:%s\n", time2str(h).c_str(), // time2str(m).c_str(), time2str(s).c_str()); //fprintf(fid, "\t\t\t\n"); // description fprintf(fid, "\t\t\t\n"); fprintf(fid, "\t\t\t\t\n"); fprintf(fid, "\t\t\t\t
East : 0.0 (m/s)
\n"); fprintf(fid, "\t\t\t\t
HDOP : %.2f (m/s)
\n", pdr[i].hdop); //fprintf(fid, "\t\t\t\t
MOTION TYPE : %s (m/s)
\n", // motionType2Str(resTracks.pdrTrack[i].motionType)); fprintf(fid, "\t\t\t\t
accuracy : %.2f (m/s)
\n", pdr[i].accuracy); fprintf(fid, "\t\t\t\t
Heading : %.2f (degrees)
\n", pdr[i].heading); fprintf(fid, "\t\t\t\t
]]>\n"); fprintf(fid, "\t\t\t
\n"); fprintf(fid, "\t\t\t\n"); fprintf(fid, "\t\t\t\t%.10f,%.10f\n", pdr[i].lon, pdr[i].lat); fprintf(fid, "\t\t\t\n"); fprintf(fid, "\t\t
\n"); } fprintf(fid, "\t\t
\n"); fprintf(fid, "\t
\n"); fprintf(fid, "
\n"); fclose(fid); }