Repository navigation
Expand file tree
/
Copy pathheightmapFilePaths.cpp
More file actions
51 lines (46 loc) · 1.49 KB
/
Copy pathheightmapFilePaths.cpp
File metadata and controls
51 lines (46 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <sstream>
#include <iomanip>
#include <fstream>
//tmp
#include <iostream>
#include "heightmapFilePaths.hpp"
std::vector<std::string> GetHeightmapsFilenamesBasedOn(int lat, int lon, int heightmapsInRow) {
std::vector<std::string> heightmaps;
for(int i = 0; i < heightmapsInRow; i++) {
int tmplat = lat - i;
char tmplatDirection = 'N';
if(tmplat < 0) {
tmplatDirection = 'S';
tmplat *= -1;
}
for(int j = 0; j < heightmapsInRow; j++) {
char tmplonDirection = 'E';
int tmplon = lon + j;
if(tmplon < 0) {
tmplonDirection = 'W';
tmplon *= -1;
}
std::string filename = GetHeightmapFileName(tmplat, tmplon, tmplatDirection, tmplonDirection);
heightmaps.push_back(filename);
}
}
return heightmaps;
}
std::string GetHeightmapFileName(int lat, int lon, char latDirection, char lonDirection) {
std::stringstream sstream;
sstream << latDirection
<< std::setfill('0') << std::setw(2) << lat
<< lonDirection
<< std::setw(3) << lon
<< ".hgt";
return sstream.str();
}
std::vector<std::string> GetFilesToDownloadFrom(const std::vector<std::string>& filenames) {
std::vector<std::string> toDownload;
for(auto file: filenames) {
std::ifstream fs("heightmaps/" + file);
if(!fs.is_open())
toDownload.push_back(file);
}
return toDownload;
}