Loading of landsat meta data file and coordinates, displays schematic cuboid
[tecorrec.git] / geo / tcLandsatData.cpp
blobddfd4037eaeb4984902e8e4a5998ecfe769e9ed3
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 /**
21 * @file tcLandsatData.cpp
22 * @brief Landsat image data.
25 #include "tcLandsatData.h"
26 #include "tcLandsatMetaData.h"
28 #include <QFile>
29 #include <QImage>
32 * Constructors + destructor
35 /// Load landsat data given the path.
36 tcLandsatData::tcLandsatData(const QString& path)
37 : tcPhotographyData()
38 , m_meta(0)
40 /// @todo Find name of txt file automatically
41 const QString metaFilePath = path + "L71195028_02819990725_MTL.txt";
43 QFile metaFile(metaFilePath);
44 if (metaFile.open(QIODevice::ReadOnly))
46 m_meta = new tcLandsatMetaData(metaFile);
48 tcLandsatMetaData& productMetadata = (*m_meta)("L1_METADATA_FILE")("PRODUCT_METADATA");
50 // Load coordinates.
51 m_coordinates[0][1] = tcGeo(productMetadata["PRODUCT_UL_CORNER_LON"].toDouble() * M_PI/180.0,
52 productMetadata["PRODUCT_UL_CORNER_LAT"].toDouble() * M_PI/180.0);
53 m_coordinates[1][1] = tcGeo(productMetadata["PRODUCT_UR_CORNER_LON"].toDouble() * M_PI/180.0,
54 productMetadata["PRODUCT_UR_CORNER_LAT"].toDouble() * M_PI/180.0);
55 m_coordinates[0][0] = tcGeo(productMetadata["PRODUCT_LL_CORNER_LON"].toDouble() * M_PI/180.0,
56 productMetadata["PRODUCT_LL_CORNER_LAT"].toDouble() * M_PI/180.0);
57 m_coordinates[1][0] = tcGeo(productMetadata["PRODUCT_LR_CORNER_LON"].toDouble() * M_PI/180.0,
58 productMetadata["PRODUCT_LR_CORNER_LAT"].toDouble() * M_PI/180.0);
60 QString bands = productMetadata["BAND_COMBINATION"].toString();
62 QString band[8];
63 band[0] = productMetadata["BAND1_FILE_NAME"].toString();
67 /// Destructor.
68 tcLandsatData::~tcLandsatData()