UE snap02 解析ASCII文本文件
示例数据data.dat
11389477.2714892 3364559.73645693 0
11389471.5162524 3364567.8860295 0
11389471.5162524 3365813.09618369 0
11388329.6082659 3366184.85895869 0
11388320.4775297 3366197.78833087 0
11388270.6882384 3366214.84811269 0
11388002.8778118 3366302.11473086 0
11387997.4076579 3366303.9056727 0
11387384.8339758 3366503.50145564 0
11387380.6581128 3366513.70979389 0
11387134.3355798 3367376.95843306 0
11387119.1215479 3367119.81430385 0
11387077.7033874 3367570.395508 0
11387077.1245603 3367572.37023947 0
11387033.4883937 3367730.15674309 0
11387000.0871094 3367845.7129394 0
TArray<FVector> UGeoJsonComponentParser::ParseXYZPoint(const FString& InPath)
{TArray<uint8> FileData;TArray<FVector>OutVertices;bool isOk = FFileHelper::LoadFileToArray(FileData, *InPath);if (!isOk){return OutVertices;}FString RawData;FFileHelper::BufferToString(RawData, FileData.GetData(), FileData.Num());TArray<FString> DataLineArr;if(RawData.Find(TEXT("\r\n"))>0)RawData.ParseIntoArray(DataLineArr, TEXT("\r\n"));elseRawData.ParseIntoArray(DataLineArr, TEXT("\n"));FVector newVertex;for (size_t i = 0; i < DataLineArr.Num(); ++i){TArray<FString> Items;DataLineArr[i].ParseIntoArray(Items, TEXT(" "));newVertex.X = FCString::Atod(*Items[0]) - CoordOffset.X;newVertex.Y = FCString::Atod(*Items[1]) - CoordOffset.Y;newVertex.Z = FCString::Atod(*Items[2]) - CoordOffset.Z;newVertex *= FVector(100, -100, 100);OutVertices.Add(newVertex);}return OutVertices;
}