MCPcopy Create free account
hub / github.com/comaps/comaps / Init

Method Init

generator/srtm_parser.cpp:58–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void SrtmTile::Init(std::string const & dir, ms::LatLon const & coord)
59{
60 Invalidate();
61
62 std::string const base = GetBase(coord);
63 std::string const cont = GetSrtmContFileName(dir, base);
64 std::string file = base + ".hgt";
65
66 // Original files are stored in zip archives. Alternatively, they can be loaded
67 // from uncompressed files like "N34E012.hgt".
68 static bool const loadFromZip = static_cast<bool>(std::ifstream(cont));
69 if (loadFromZip)
70 {
71 UnzipMemDelegate delegate(m_data);
72 try
73 {
74 ZipFileReader::UnzipFile(cont, file, delegate);
75 }
76 catch (ZipFileReader::LocateZipException const &)
77 {
78 // Sometimes packed file has different name. See N39E051 measure.
79 file = base + ".SRTMGL1.hgt";
80
81 ZipFileReader::UnzipFile(cont, file, delegate);
82 }
83
84 if (!delegate.m_completed)
85 {
86 LOG(LWARNING, ("Can't decompress SRTM file:", cont));
87 Invalidate();
88 return;
89 }
90 }
91 else
92 {
93 m_data = base::ReadFile(base::JoinPath(dir, file));
94 }
95
96 if (m_data.size() != kSrtmTileSize)
97 {
98 LOG(LWARNING, ("Bad decompressed SRTM file size:", cont, m_data.size()));
99 Invalidate();
100 return;
101 }
102
103 m_valid = true;
104}
105
106// static
107ms::LatLon SrtmTile::GetCoordInSeconds(ms::LatLon const & coord)

Callers 1

srtm_parser.cppFile · 0.45

Calls 5

GetBaseFunction · 0.85
GetSrtmContFileNameFunction · 0.85
JoinPathFunction · 0.85
ReadFileFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected