diff --git a/code/file_format.cpp b/code/file_format.cpp index 34af2fc..a0e0143 100644 --- a/code/file_format.cpp +++ b/code/file_format.cpp @@ -41,6 +41,7 @@ int FileFormat::rawSamplesAcross() const { case Value::NED1_ZIP: return 3612; case Value::NED19: return 8112; case Value::HGT: return 1201; + case Value::HGT30: return 3601; case Value::THREEDEP_1M: return 10012; case Value::LIDAR: return 10000; default: @@ -57,7 +58,9 @@ int FileFormat::inMemorySamplesAcross() const { return 10801; case Value::NED1_ZIP: return 3601; case Value::NED19: return 8101; - case Value::HGT: return 1201; + case Value::HGT: // fall through + case Value::HGT30: + return rawSamplesAcross(); case Value::THREEDEP_1M: return 10001; case Value::GLO30: // Fall through case Value::FABDEM: @@ -77,7 +80,9 @@ double FileFormat::degreesAcross() const { return 1.0; case Value::NED1_ZIP: return 1.0; case Value::NED19: return 0.25; - case Value::HGT: return 1.0; + case Value::HGT: // fall through + case Value::HGT30: + return 1.0; case Value::GLO30: // Fall through case Value::FABDEM: return 1.0; @@ -102,7 +107,8 @@ CoordinateSystem *FileFormat::coordinateSystemForOrigin(double lat, double lng, case Value::NED13: case Value::NED1_ZIP: case Value::NED19: - case Value::HGT: + case Value::HGT: + case Value::HGT30: case Value::GLO30: case Value::FABDEM: { // The -1 removes overlap with neighbors @@ -143,6 +149,7 @@ CoordinateSystem *FileFormat::coordinateSystemForOrigin(double lat, double lng, FileFormat *FileFormat::fromName(const string &name) { const std::map fileFormatNames = { { "SRTM", Value::HGT, }, + { "SRTM30", Value::HGT30, }, { "NED1-ZIP", Value::NED1_ZIP, }, { "NED13", Value::NED13, }, { "NED13-ZIP", Value::NED13_ZIP, }, diff --git a/code/file_format.h b/code/file_format.h index 72a3f33..1b074d8 100644 --- a/code/file_format.h +++ b/code/file_format.h @@ -34,7 +34,8 @@ class Tile; class FileFormat { public: enum class Value { - HGT, // SRTM (90m, 3 arcsecond) + HGT, // SRTM (90m, 3 arcsecond) + HGT30, // SRTM (30m, 1 arcsecond) NED19, // FLT file containing NED 1/9 arcsecond data NED13, // FLT file containing NED 1/3 arcsecond data NED13_ZIP, // ZIP file containing FLT NED 1/3 arcsecond data diff --git a/code/hgt_loader.cpp b/code/hgt_loader.cpp index 382c40a..d0d9ba6 100644 --- a/code/hgt_loader.cpp +++ b/code/hgt_loader.cpp @@ -32,13 +32,28 @@ using std::string; -static const int HGT_TILE_SIZE = 1201; static const int16 HGT_NODATA_ELEVATION = -32768; static uint16 swapByteOrder16(uint16 us) { return (us >> 8) | (us << 8); } +HgtLoader::HgtLoader(FileFormat fileFormat) { + switch (fileFormat.value()) { + case FileFormat::Value::HGT: + mTileSize = 1201; + break; + + case FileFormat::Value::HGT30: + mTileSize = 3601; + break; + + default: + LOG(ERROR) << "Tried to load HGT file from unknown file format " << static_cast(fileFormat.value()); + break; + } +} + Tile *HgtLoader::loadTile(const std::string &directory, double minLat, double minLng) { char buf[100]; snprintf(buf, sizeof(buf), "%c%02d%c%03d.hgt", @@ -57,7 +72,7 @@ Tile *HgtLoader::loadTile(const std::string &directory, double minLat, double mi return nullptr; } - int num_samples = HGT_TILE_SIZE * HGT_TILE_SIZE; + int num_samples = mTileSize * mTileSize; int16 *inbuf = (int16 *) malloc(sizeof(int16) * num_samples); @@ -80,7 +95,7 @@ Tile *HgtLoader::loadTile(const std::string &directory, double minLat, double mi } } - retval = new Tile(HGT_TILE_SIZE, HGT_TILE_SIZE, samples); + retval = new Tile(mTileSize, mTileSize, samples); } free(inbuf); diff --git a/code/hgt_loader.h b/code/hgt_loader.h index c3bcba8..778b6ad 100644 --- a/code/hgt_loader.h +++ b/code/hgt_loader.h @@ -26,14 +26,19 @@ #define _HGT_LOADER_H_ #include "tile_loader.h" - +#include "file_format.h" // Load a .hgt tile. This is the format used by SRTM data. class HgtLoader : public TileLoader { public: + explicit HgtLoader(FileFormat fileFormat); + // minLat and minLng name the SW corner of the tile, in degrees virtual Tile *loadTile(const std::string &directory, double minLat, double minLng); + +private: + int mTileSize; }; #endif // _HGT_LOADER_H_ diff --git a/code/prominence.cpp b/code/prominence.cpp index e062552..7b273d2 100644 --- a/code/prominence.cpp +++ b/code/prominence.cpp @@ -55,7 +55,7 @@ static void usage() { printf(" Options:\n"); printf(" -i directory Directory with terrain data\n"); printf(" -o directory Directory for output data\n"); - printf(" -f format \"SRTM\", \"NED13\", \"NED1-ZIP\", \"NED19\", \"3DEP-1M\", \"GLO30\" input files\n"); + printf(" -f format \"SRTM\", \"SRTM30\", \"NED13\", \"NED1-ZIP\", \"NED19\", \"3DEP-1M\", \"GLO30\", \"LIDAR\"\n"); printf(" -k filename File with KML polygon to filter input tiles\n"); printf(" -m min_prominence Minimum prominence threshold for output\n"); printf(" in same units as terrain data, default = 100\n"); diff --git a/code/tile_loading_policy.cpp b/code/tile_loading_policy.cpp index fdde68b..5a53c52 100644 --- a/code/tile_loading_policy.cpp +++ b/code/tile_loading_policy.cpp @@ -77,6 +77,7 @@ Tile *BasicTileLoadingPolicy::loadTile(double minLat, double minLng) const { if (mNeighborEdgeLoadingEnabled) { switch (mFileFormat.value()) { case FileFormat::Value::HGT: // Fall through + case FileFormat::Value::HGT30: case FileFormat::Value::NED19: case FileFormat::Value::NED13: case FileFormat::Value::NED13_ZIP: @@ -116,7 +117,8 @@ Tile *BasicTileLoadingPolicy::loadInternal(double minLat, double minLng) const { switch (mFileFormat.value()) { case FileFormat::Value::HGT: - loader = new HgtLoader(); + case FileFormat::Value::HGT30: + loader = new HgtLoader(mFileFormat); break; case FileFormat::Value::NED13_ZIP: // fall through