1 /***************************************************************************
2 * This file is part of Tecorrec. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
5 * Tecorrec is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * Tecorrec is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with Tecorrec. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef _tcSrtmCache_h_
21 #define _tcSrtmCache_h_
25 * @brief Manages cache of SRTM data.
30 #include <QStringList>
35 class tcElevationData
;
37 /** Manages cache of SRTM data.
38 * Obtains SRTM elevation data blocks, downloading from nasa if necessary.
40 * FTP site: ftp://e0srp01u.ecs.nasa.gov/
42 class tcSrtmCache
: public QObject
52 /// Get a list of datasets.
53 static QStringList
dataSets();
56 * Constructors + destructor
59 /// Primary constructor.
60 tcSrtmCache(const QString
& dataSet
);
63 virtual ~tcSrtmCache();
69 /** Load raw SRTM height file.
70 * Download the file if necessary.
71 * @param lon Longitude in degrees.
72 * @param lat Latitude in degrees.
73 * @returns SRTM data for the chunk containing (@p lon, @p lat) or 0.
75 tcSrtmData
* loadData(int lon
, int lat
);
77 /** Load raw SRTM height file.
78 * Download the file if necessary.
79 * @param coord Geographical coordinate.
80 * @returns SRTM data for the chunk containing (@p lon, @p lat) or 0.
82 tcSrtmData
* loadData(const tcGeo
& coord
);
84 /** Find some SRTM height data overlapping an area.
85 * @param swCorner Geographical coordinate of south-west corner.
86 * @param neCorner Geographical coordinate of north-east corner.
87 * @returns An arbitrary SRTM data for a chunk in the lon lat range.
89 tcSrtmData
* findData(const tcGeo
& swCorner
, const tcGeo
& neCorner
);
91 /// Update any samples affected by the elevation field.
92 void updateFromElevationData(const tcElevationData
* elevation
);
100 /// Progress notification.
101 void progressing(const QString
& message
);
109 /// Convert a geographical coordinate into lon lat ints.
110 void toIntLonLat(const tcGeo
& coord
, int* const outLon
, int* const outLat
);
113 tcSrtmData
*& cache(int lon
, int lat
);
121 /// Directory containing elevation data sets.
122 static QDir s_dataDirectory
;
131 /// Cache of data at each grid point.
132 tcSrtmData
* m_cache
[360][180];