tcElevationOptimization: fix typo s/write/read/
[tecorrec.git] / geo / tcSrtmCache.h
blobcaf16db61a425da1782940110de19806f8348982
1 /***************************************************************************
2 * This file is part of Tecorrec. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
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. *
9 * *
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. *
14 * *
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_
23 /**
24 * @file tcSrtmCache.h
25 * @brief Manages cache of SRTM data.
28 #include <QObject>
29 #include <QString>
30 #include <QStringList>
31 #include <QDir>
33 class tcSrtmData;
34 class tcGeo;
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
44 Q_OBJECT
46 public:
49 * Static functions
52 /// Get a list of datasets.
53 static QStringList dataSets();
56 * Constructors + destructor
59 /// Primary constructor.
60 tcSrtmCache(const QString& dataSet);
62 /// Destructor.
63 virtual ~tcSrtmCache();
66 * Main interface
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);
94 signals:
97 * Signals
100 /// Progress notification.
101 void progressing(const QString& message);
103 private:
106 * Private functions
109 /// Convert a geographical coordinate into lon lat ints.
110 void toIntLonLat(const tcGeo& coord, int* const outLon, int* const outLat);
112 /// Cache index.
113 tcSrtmData*& cache(int lon, int lat);
115 private:
118 * Static variables
121 /// Directory containing elevation data sets.
122 static QDir s_dataDirectory;
125 * Variables
128 /// Dataset name.
129 QString m_dataSet;
131 /// Cache of data at each grid point.
132 tcSrtmData* m_cache[360][180];
135 #endif