410 lines
14 KiB
C++
410 lines
14 KiB
C++
|
|
#include "WindDataFileOperator.h"
|
|||
|
|
#include <iostream>
|
|||
|
|
#include <string>
|
|||
|
|
#include <vector>
|
|||
|
|
#include <algorithm>
|
|||
|
|
#include <filesystem>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* <EFBFBD>糡<EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>ʽ˵<EFBFBD><EFBFBD>
|
|||
|
|
* 'LAMPWINDDASASET', Height , Width , TIMENUM ,// : int64_t
|
|||
|
|
* 'GEOTRANSFORMER',ESPGCODE,T1,T2,T3,T4,T5,T6
|
|||
|
|
* "WINUV" , TIMELB, UArr[HxWxN],Varr[HxWxN] // double
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#define LAMP_WIND_SIGNAL_NUM 15
|
|||
|
|
#define LAMP_WIND_GEOTRANSFORMER_NUM 14
|
|||
|
|
#define LAMP_WIND_WINUV_NUM 6
|
|||
|
|
|
|||
|
|
LAMPWindDataDLL DataFileInfo getDataFileInfo(const char* filepath)
|
|||
|
|
{
|
|||
|
|
DataFileInfo info = { 0 };
|
|||
|
|
info.Height=-1;
|
|||
|
|
info.Width = -1;
|
|||
|
|
info.Num = -1;
|
|||
|
|
info.firstTimestamp = -1;
|
|||
|
|
info.lastTimestamp = -1;
|
|||
|
|
info.minLon=-1;
|
|||
|
|
info.maxLon=-1;
|
|||
|
|
info.minLat=-1;
|
|||
|
|
info.maxLat=-1;
|
|||
|
|
info.ESPGCODE = -1;
|
|||
|
|
info.T11=-1;
|
|||
|
|
info.T12=-1;
|
|||
|
|
info.T13=-1;
|
|||
|
|
info.T21=-1;
|
|||
|
|
info.T22=-1;
|
|||
|
|
info.T23=-1;
|
|||
|
|
info.fileSize = -1;
|
|||
|
|
|
|||
|
|
|
|||
|
|
std::ifstream file(filepath, std::ios::binary);
|
|||
|
|
|
|||
|
|
if (!file.is_open()) {
|
|||
|
|
std::cerr << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>: " << filepath << std::endl;
|
|||
|
|
return info;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С
|
|||
|
|
file.seekg(0, std::ios::end);
|
|||
|
|
info.fileSize = file.tellg();
|
|||
|
|
file.seekg(0, std::ios::beg);
|
|||
|
|
|
|||
|
|
const char Fileheader[LAMP_WIND_SIGNAL_NUM]={ 0x4C, 0x41, 0x4D ,0x50, 0x57, 0x49, 0x4E, 0x44, 0x44 ,0x41, 0x53 ,0x41 ,0x53, 0x45 ,0x54 }; // LAMPWINDDASASET
|
|||
|
|
const char GeoTransHeader[LAMP_WIND_GEOTRANSFORMER_NUM] = { 0x47 ,0x45 ,0x4F ,0x54 ,0x52 ,0x41 ,0x4E ,0x53 ,0x46 ,0x4F ,0x52 ,0x4D ,0x45 ,0x52 }; // GEOTRANSFORMER
|
|||
|
|
const char WindUVHeader[LAMP_WIND_WINUV_NUM] = { 0x57 ,0x49 ,0x4E ,0x44 ,0x55 ,0x56 }; // WINDUV
|
|||
|
|
|
|||
|
|
|
|||
|
|
char labelchar = '\0';
|
|||
|
|
|
|||
|
|
for (int64_t i = 0; i < LAMP_WIND_SIGNAL_NUM; i++) { // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD>
|
|||
|
|
file.read(reinterpret_cast<char*>(&labelchar), 1);
|
|||
|
|
if (labelchar != Fileheader[i]) {
|
|||
|
|
file.close();
|
|||
|
|
return info;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
file.read(reinterpret_cast<char*>(&info.Height), sizeof(int64_t)); // H
|
|||
|
|
file.read(reinterpret_cast<char*>(&info.Width), sizeof(int64_t)); // W
|
|||
|
|
file.read(reinterpret_cast<char*>(&info.Num), sizeof(int64_t)); // N
|
|||
|
|
|
|||
|
|
if (info.Num == 0 || info.Height == 0 || info.Width == 0) {
|
|||
|
|
file.close();
|
|||
|
|
return info;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>任<EFBFBD><E4BBBB><EFBFBD><EFBFBD>
|
|||
|
|
for (int64_t i = 0; i < LAMP_WIND_GEOTRANSFORMER_NUM; i++) { // <20><>ȡ<EFBFBD><C8A1>ʶ
|
|||
|
|
file.read(reinterpret_cast<char*>(&labelchar), 1);
|
|||
|
|
if (labelchar != GeoTransHeader[i]) {
|
|||
|
|
file.close();
|
|||
|
|
return info;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
file.read(reinterpret_cast<char*>(&info.ESPGCODE), sizeof(int64_t));
|
|||
|
|
file.read(reinterpret_cast<char*>(&info.T11), sizeof(double));
|
|||
|
|
file.read(reinterpret_cast<char*>(&info.T12), sizeof(double));
|
|||
|
|
file.read(reinterpret_cast<char*>(&info.T13), sizeof(double));
|
|||
|
|
file.read(reinterpret_cast<char*>(&info.T21), sizeof(double));
|
|||
|
|
file.read(reinterpret_cast<char*>(&info.T22), sizeof(double));
|
|||
|
|
file.read(reinterpret_cast<char*>(&info.T23), sizeof(double));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>㾭γ<E3BEAD>ȷ<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD>任<EFBFBD><E4BBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㣩
|
|||
|
|
info.minLon = info.T11;
|
|||
|
|
info.maxLon = info.T11 + info.Width * info.T12;
|
|||
|
|
info.minLat = info.T21 + info.Height * info.T23;
|
|||
|
|
info.maxLat = info.T21;
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD>ȡ
|
|||
|
|
for (int64_t i = 0; i < LAMP_WIND_WINUV_NUM; i++) {
|
|||
|
|
file.read(reinterpret_cast<char*>(&labelchar), 1);
|
|||
|
|
if (labelchar != WindUVHeader[i]) {
|
|||
|
|
file.close();
|
|||
|
|
return info;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::vector<int64_t> timeArr(info.Num);
|
|||
|
|
for (int64_t t = 0; t < info.Num; t++) {
|
|||
|
|
file.read(reinterpret_cast<char*>(&timeArr[t]), sizeof(int64_t));
|
|||
|
|
int64_t datalen = int64_t(info.Height) * int64_t(info.Width) * 2 * sizeof(double);
|
|||
|
|
file.seekg(datalen, std::ios::cur);
|
|||
|
|
if (file.eof()) {
|
|||
|
|
if (t == info.Num - 1) { // <20><><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
file.close();
|
|||
|
|
return info;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {}
|
|||
|
|
}
|
|||
|
|
std::vector<int64_t>::iterator minIter = std::min_element(timeArr.begin(),timeArr.end());
|
|||
|
|
std::vector<int64_t>::iterator maxIter = std::max_element(timeArr.begin(),timeArr.end());
|
|||
|
|
|
|||
|
|
info.firstTimestamp = *minIter;
|
|||
|
|
info.lastTimestamp = *maxIter;
|
|||
|
|
|
|||
|
|
file.close();
|
|||
|
|
return info;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
LAMPWindDataDLL int32_t get_WindDataFileTimeArr(const char* filepath, DataFileInfo info, int64_t* outtimeArr)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (info.Num <= 0 || outtimeArr == nullptr) {
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::ifstream file(filepath, std::ios::binary);
|
|||
|
|
if (!file.is_open()) {
|
|||
|
|
return -2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
int64_t offset = LAMP_WIND_SIGNAL_NUM // LAMPWINDDASASET
|
|||
|
|
+ 3 * sizeof(int64_t)
|
|||
|
|
+ LAMP_WIND_GEOTRANSFORMER_NUM // GEOTRANSFORMER
|
|||
|
|
+ sizeof(int64_t)
|
|||
|
|
+ sizeof(double) * 6
|
|||
|
|
+ LAMP_WIND_WINUV_NUM; // WINUV
|
|||
|
|
|
|||
|
|
|
|||
|
|
file.seekg(offset, std::ios::beg);
|
|||
|
|
for (int64_t t = 0; t < info.Num; t++) {
|
|||
|
|
file.read(reinterpret_cast<char*>(&outtimeArr[t]), sizeof(int64_t));
|
|||
|
|
int64_t datalen = int64_t(info.Height) * int64_t(info.Width) * 2 * sizeof(double);
|
|||
|
|
file.seekg(datalen, std::ios::cur);
|
|||
|
|
if (file.eof()) {
|
|||
|
|
if (t == info.Num - 1) { // <20><><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
file.close();
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
file.close();
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
LAMPWindDataDLL int32_t Read_WindDataFile(const char* filepath, DataFileInfo info, int32_t timeID, double* UArr, double* VArr)
|
|||
|
|
{
|
|||
|
|
if (timeID < 0 || timeID >= info.Num || UArr == nullptr || VArr == nullptr) {
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::ifstream file(filepath, std::ios::binary);
|
|||
|
|
if (!file.is_open()) {
|
|||
|
|
return -2;
|
|||
|
|
}
|
|||
|
|
// <20>ж<EFBFBD><D0B6><EFBFBD>Ϣ
|
|||
|
|
file.seekg(0, std::ios::end);
|
|||
|
|
int64_t fileSize = file.tellg();
|
|||
|
|
file.seekg(0, std::ios::beg);
|
|||
|
|
|
|||
|
|
if (fileSize != info.fileSize) {
|
|||
|
|
file.close();
|
|||
|
|
return -3;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
int64_t Headeroffset = LAMP_WIND_SIGNAL_NUM // LAMPWINDDASASET
|
|||
|
|
+ 3 * sizeof(int64_t)
|
|||
|
|
+ LAMP_WIND_GEOTRANSFORMER_NUM // GEOTRANSFORMER
|
|||
|
|
+ sizeof(int64_t)
|
|||
|
|
+ sizeof(double) * 6
|
|||
|
|
+ LAMP_WIND_WINUV_NUM; // WINUV
|
|||
|
|
|
|||
|
|
int64_t U_block_len= int64_t(info.Height) * int64_t(info.Width)* sizeof(double);
|
|||
|
|
int64_t V_block_len= int64_t(info.Height) * int64_t(info.Width)* sizeof(double);
|
|||
|
|
|
|||
|
|
int64_t datalen = sizeof(int64_t) // Time
|
|||
|
|
+ U_block_len
|
|||
|
|
+ V_block_len;
|
|||
|
|
|
|||
|
|
int64_t dataOffset = timeID * datalen;
|
|||
|
|
int64_t sumOffset = Headeroffset + dataOffset;
|
|||
|
|
|
|||
|
|
if(sumOffset+datalen<=fileSize){}
|
|||
|
|
else {
|
|||
|
|
file.close();
|
|||
|
|
return -4;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
file.seekg(sumOffset, std::ios::beg);
|
|||
|
|
|
|||
|
|
int64_t timeInt = 0;
|
|||
|
|
file.read(reinterpret_cast<char*>(&timeInt), sizeof(int64_t));
|
|||
|
|
file.read(reinterpret_cast<char*>(UArr), U_block_len);
|
|||
|
|
file.read(reinterpret_cast<char*>(VArr), V_block_len);
|
|||
|
|
|
|||
|
|
file.close();
|
|||
|
|
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
LAMPWindDataDLL int32_t Write_WindDataFile(const char* filepath, DataFileInfo info, int64_t timeInt,int32_t timeID, double* UArr, double* VArr)
|
|||
|
|
{
|
|||
|
|
const char Fileheader[LAMP_WIND_SIGNAL_NUM] = { 0x4C, 0x41, 0x4D ,0x50, 0x57, 0x49, 0x4E, 0x44, 0x44 ,0x41, 0x53 ,0x41 ,0x53, 0x45 ,0x54 }; // LAMPWINDDASASET
|
|||
|
|
const char GeoTransHeader[LAMP_WIND_GEOTRANSFORMER_NUM] = { 0x47 ,0x45 ,0x4F ,0x54 ,0x52 ,0x41 ,0x4E ,0x53 ,0x46 ,0x4F ,0x52 ,0x4D ,0x45 ,0x52 }; // GEOTRANSFORMER
|
|||
|
|
const char WindUVHeader[LAMP_WIND_WINUV_NUM] = { 0x57 ,0x49 ,0x4E ,0x44 ,0x55 ,0x56 }; // WINDUV
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (timeID < 0 || timeID >= info.Num || UArr == nullptr || VArr == nullptr) {
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ж<EFBFBD><D0B6>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (! std::filesystem::exists(filepath)) { // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
std::fstream file(filepath, std::ios::binary | std::ios::in | std::ios::out);
|
|||
|
|
if (!file.is_open()) { // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ
|
|||
|
|
file.open(filepath, std::ios::binary | std::ios::out);
|
|||
|
|
if (!file.is_open()) {
|
|||
|
|
return -2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// д<><D0B4><EFBFBD>ļ<EFBFBD>ͷ
|
|||
|
|
for (int64_t i = 0; i < LAMP_WIND_SIGNAL_NUM; i++) {
|
|||
|
|
file.write(reinterpret_cast<const char*>(&Fileheader[i]), sizeof(char));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// д<><D0B4><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϣ
|
|||
|
|
file.write(reinterpret_cast<const char*>(&info.Height), sizeof(int64_t)); // H
|
|||
|
|
file.write(reinterpret_cast<const char*>(&info.Width), sizeof(int64_t)); // W
|
|||
|
|
file.write(reinterpret_cast<const char*>(&info.Num), sizeof(int64_t)); // N
|
|||
|
|
|
|||
|
|
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>任<EFBFBD><E4BBBB><EFBFBD><EFBFBD>
|
|||
|
|
for (int64_t i = 0; i < LAMP_WIND_GEOTRANSFORMER_NUM; i++) {
|
|||
|
|
file.write(reinterpret_cast<const char*>(&GeoTransHeader[i]), sizeof(char));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
file.write(reinterpret_cast<const char*>(&info.ESPGCODE), sizeof(int64_t));
|
|||
|
|
file.write(reinterpret_cast<const char*>(&info.T11), sizeof(double));
|
|||
|
|
file.write(reinterpret_cast<const char*>(&info.T12), sizeof(double));
|
|||
|
|
file.write(reinterpret_cast<const char*>(&info.T13), sizeof(double));
|
|||
|
|
file.write(reinterpret_cast<const char*>(&info.T21), sizeof(double));
|
|||
|
|
file.write(reinterpret_cast<const char*>(&info.T22), sizeof(double));
|
|||
|
|
file.write(reinterpret_cast<const char*>(&info.T23), sizeof(double));
|
|||
|
|
|
|||
|
|
// д<><D0B4><EFBFBD>糡<EFBFBD><E7B3A1><EFBFBD>ݱ<EFBFBD>ǩ
|
|||
|
|
for (int64_t i = 0; i < LAMP_WIND_WINUV_NUM; i++) {
|
|||
|
|
file.write(reinterpret_cast<const char*>(&WindUVHeader[i]), sizeof(char));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// д<><D0B4><EFBFBD>糡<EFBFBD><E7B3A1>
|
|||
|
|
std::vector<double> blockData(info.Width);
|
|||
|
|
for (int64_t i = 0; i < info.Width; i++) {
|
|||
|
|
blockData[i] = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int64_t tid = 0; tid < info.Num; tid++) {
|
|||
|
|
int64_t timeValue = 0;
|
|||
|
|
if (tid == timeID) { //
|
|||
|
|
timeValue = timeInt;
|
|||
|
|
file.write(reinterpret_cast<const char*>(&timeValue), sizeof(int64_t));
|
|||
|
|
file.write(reinterpret_cast<const char*>(UArr), info.Height*info.Width * sizeof(double));
|
|||
|
|
file.write(reinterpret_cast<const char*>(VArr), info.Height*info.Width * sizeof(double));
|
|||
|
|
timeValue = 0;
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
file.write(reinterpret_cast<const char*>(&timeValue), sizeof(int64_t));
|
|||
|
|
for (int64_t i = 0; i < info.Height; i++) { // U
|
|||
|
|
file.write(reinterpret_cast<const char*>(blockData.data()), info.Width*sizeof(double));
|
|||
|
|
}
|
|||
|
|
for (int64_t i = 0; i < info.Height; i++) { // V
|
|||
|
|
file.write(reinterpret_cast<const char*>(blockData.data()), info.Width*sizeof(double));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
file.close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
std::fstream file(filepath, std::ios::binary | std::ios::in | std::ios::out);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD><CEAC>
|
|||
|
|
int64_t Headeroffset = LAMP_WIND_SIGNAL_NUM // LAMPWINDDASASET
|
|||
|
|
+ 3 * sizeof(int64_t)
|
|||
|
|
+ LAMP_WIND_GEOTRANSFORMER_NUM // GEOTRANSFORMER
|
|||
|
|
+ sizeof(int64_t)
|
|||
|
|
+ sizeof(double) * 6
|
|||
|
|
+ LAMP_WIND_WINUV_NUM; // WINUV
|
|||
|
|
|
|||
|
|
|
|||
|
|
file.seekp(LAMP_WIND_SIGNAL_NUM, std::ios::beg);
|
|||
|
|
int64_t height = 0;
|
|||
|
|
int64_t width = 0;
|
|||
|
|
int64_t num = 0;
|
|||
|
|
file.read(reinterpret_cast<char*>(&height), sizeof(int64_t));
|
|||
|
|
file.read(reinterpret_cast<char*>(&width), sizeof(int64_t));
|
|||
|
|
file.read(reinterpret_cast<char*>(&num), sizeof(int64_t));
|
|||
|
|
|
|||
|
|
if (info.Width != width || info.Height != height||info.Num<num) {
|
|||
|
|
return -3;
|
|||
|
|
}
|
|||
|
|
if (info.Num > num) { // <20>ij<DEB8><C4B3><EFBFBD>
|
|||
|
|
int64_t offset = LAMP_WIND_SIGNAL_NUM +2 * sizeof(int64_t);
|
|||
|
|
file.seekg(offset, std::ios::beg);
|
|||
|
|
file.write(reinterpret_cast<char*>(&info.Num), sizeof(int64_t)); // <20>ij<DEB8><C4B3><EFBFBD>
|
|||
|
|
|
|||
|
|
offset = LAMP_WIND_SIGNAL_NUM // LAMPWINDDASASET
|
|||
|
|
+ 3 * sizeof(int64_t)
|
|||
|
|
+ LAMP_WIND_GEOTRANSFORMER_NUM // GEOTRANSFORMER
|
|||
|
|
+ sizeof(int64_t)
|
|||
|
|
+ sizeof(double) * 6
|
|||
|
|
+ LAMP_WIND_WINUV_NUM
|
|||
|
|
+ int64_t(sizeof(int64_t) + int64_t(info.Width) * int64_t(info.Height) * sizeof(double) * 2) * num;
|
|||
|
|
|
|||
|
|
file.seekg(offset, std::ios::beg);// <20>ƶ<EFBFBD><C6B6><EFBFBD> [n-1] >>|<<[n] <20><>
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
std::vector<double> blockData(info.Width);
|
|||
|
|
for (int64_t i = 0; i < info.Width; i++) {
|
|||
|
|
blockData[i] = 0;
|
|||
|
|
}
|
|||
|
|
for (int64_t tid = num; tid < info.Num; tid++) {
|
|||
|
|
int64_t timeValue = 0;
|
|||
|
|
if (tid == timeID) { //
|
|||
|
|
timeValue = timeInt;
|
|||
|
|
file.write(reinterpret_cast<const char*>(&timeValue), sizeof(int64_t));
|
|||
|
|
file.write(reinterpret_cast<const char*>(UArr), info.Height * info.Width * sizeof(double));
|
|||
|
|
file.write(reinterpret_cast<const char*>(VArr), info.Height * info.Width * sizeof(double));
|
|||
|
|
timeValue = 0;
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
file.write(reinterpret_cast<const char*>(&timeValue), sizeof(int64_t));
|
|||
|
|
for (int64_t i = 0; i < info.Height; i++) { // U
|
|||
|
|
file.write(reinterpret_cast<const char*>(blockData.data()), info.Width * sizeof(double));
|
|||
|
|
}
|
|||
|
|
for (int64_t i = 0; i < info.Height; i++) { // V
|
|||
|
|
file.write(reinterpret_cast<const char*>(blockData.data()), info.Width * sizeof(double));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else {}
|
|||
|
|
|
|||
|
|
// <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>ƶ<EFBFBD>Ϊ
|
|||
|
|
int64_t writeoffset = LAMP_WIND_SIGNAL_NUM // LAMPWINDDASASET
|
|||
|
|
+ 3 * sizeof(int64_t)
|
|||
|
|
+ LAMP_WIND_GEOTRANSFORMER_NUM // GEOTRANSFORMER
|
|||
|
|
+ sizeof(int64_t)
|
|||
|
|
+ sizeof(double) * 6
|
|||
|
|
+ LAMP_WIND_WINUV_NUM
|
|||
|
|
+ int64_t(sizeof(int64_t) + int64_t(info.Width) * int64_t(info.Height) * sizeof(double) * 2) * timeID;
|
|||
|
|
|
|||
|
|
file.seekg(writeoffset, std::ios::beg);
|
|||
|
|
|
|||
|
|
file.write(reinterpret_cast<const char*>(&timeInt), sizeof(int64_t));
|
|||
|
|
file.write(reinterpret_cast<const char*>(UArr), int64_t(info.Width)* int64_t(info.Height) * sizeof(double));
|
|||
|
|
file.write(reinterpret_cast<const char*>(VArr), int64_t(info.Width)* int64_t(info.Height) * sizeof(double));
|
|||
|
|
|
|||
|
|
file.close();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|