OpenMining  0.01
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
location.h
Go to the documentation of this file.
1 /*
2  Copyright 2014 Daniel McInnes
3 
4  This file is part of OpenMining.
5 
6  OpenMining is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OpenMining is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OpenMining. If not, see <http://www.gnu.org/licenses/>.
18 
19 */
20 
21 #ifndef LOCATION_H
22 #define LOCATION_H
23 
24 // standard library #includes
25 #include <string>
26 #include <iostream> // cout
27 #include <algorithm> // min_element(...)
28 #include <time.h>
29 
30 // boost #includes
31 #include <boost/archive/text_oarchive.hpp>
32 #include <boost/archive/text_iarchive.hpp>
33 #include <boost/serialization/map.hpp>
34 
35 // Qt #includes
36 #include <QSqlQuery>
37 #include <QSqlRecord>
38 #include <QString>
39 #include <QVariant> // needed for QSqlQuery
40 
41 // my #includes
42 #include "mytypes.h"
43 #include "Cube.h" // 'Cube' member variable
44 
45 class Location
46 {
47 public:
49  Location(const latitude_t& latitude, const longitude_t& longitude, const elevation_t& elevation);
50  Location();
51  bool inside(const Cube& cube);
52 
53  latitude_t m_latitude; // -116788254 = 116.788254 degrees south
54  longitude_t m_longitude;//, m_maxy; // 543654588 = 54.3654588 degrees east
55  elevation_t m_elevation; // 10889 = 108.89m above mean sea level (geoid)
56  std::string toString(void) const;
57 
58 private:
59  // When the class Archive corresponds to an output archive, the
60  // & operator is defined similar to <<. Likewise, when the class Archive
61  // is a type of input archive the & operator is defined similar to >>.
62  template<class Archive>
63  void serialize(Archive& ar, const unsigned int version)
64  {
65  ar & m_latitude;
66  ar & m_longitude;
67  ar & m_elevation;
68  Q_UNUSED(version);
69  }
70 };
71 
72 bool min_latitude(const Location& i, const Location& j);
73 bool min_longitude(const Location& i, const Location& j);
74 bool min_elevation(const Location& i, const Location& j);
75 
76 class Locations
77 {
78 public:
79  Locations(const QStringList& args);
80 
83  static uint32_t m_numInvalidLocations;
85  std::vector<Location> m_locations;
86  // make a map of all longitudes recorded for a given latitude.
87  std::string m_filename;
88 
89  void print(void);
90  void build(QSqlQuery& query);
91  void build(QString& str);
92  bool load(const QStringList& args);
93  void save();
94 
95  //elevation_t elevation(const latitude_t& latitude, const longitude_t& longitude);
96 
97 private:
98  // When the class Archive corresponds to an output archive, the
99  // & operator is defined similar to <<. Likewise, when the class Archive
100  // is a type of input archive the & operator is defined similar to >>.
101  template<class Archive>
102  void serialize(Archive& ar, const unsigned int version)
103  {
105  ar & m_locations;
106  Q_UNUSED(version);
107  }
108  QSqlQuery m_query;
109  const char* m_key = "--locations-filename";
110 };
111 
112 bool isValidLocation(const Location& loc, const latitude_t& minlat, const latitude_t& maxlat, const longitude_t& minlong, const longitude_t& maxlong, const elevation_t& minel, const elevation_t& maxel);
113 
114 #endif
bool isValidLocation(const Location &loc, const latitude_t &minlat, const latitude_t &maxlat, const longitude_t &minlong, const longitude_t &maxlong, const elevation_t &minel, const elevation_t &maxel)
std::string toString(void) const
Definition: location.cpp:212
void build(QSqlQuery &query)
Definition: location.cpp:157
void serialize(Archive &ar, const unsigned int version)
Definition: location.h:63
bool load(const QStringList &args)
Definition: location.cpp:108
void print(void)
Definition: location.cpp:195
void save()
void serialize(Archive &ar, const unsigned int version)
Definition: location.h:102
int32_t latitude_t
Definition: mytypes.h:18
friend class boost::serialization::access
Definition: location.h:81
Cube m_validXYZ
Definition: location.h:82
bool min_latitude(const Location &i, const Location &j)
Definition: location.cpp:87
uint32_t m_dbNumRows
Definition: location.h:84
Locations(const QStringList &args)
Definition: location.cpp:102
Definition: Cube.h:38
uint32_t m_dbRowCount
Definition: location.h:84
std::string m_filename
Definition: location.h:87
bool min_longitude(const Location &i, const Location &j)
Definition: location.cpp:92
int32_t elevation_t
Definition: mytypes.h:20
const char * m_key
Definition: location.h:109
Definition: location.h:76
int32_t longitude_t
Definition: mytypes.h:19
longitude_t m_longitude
Definition: location.h:54
QSqlQuery m_query
Definition: location.h:108
bool inside(const Cube &cube)
Definition: location.cpp:56
latitude_t m_latitude
Definition: location.h:53
friend class boost::serialization::access
Definition: location.h:48
static uint32_t m_numInvalidLocations
Definition: location.h:83
elevation_t m_elevation
Definition: location.h:55
Definition: location.h:45
bool min_elevation(const Location &i, const Location &j)
Definition: location.cpp:97
Location()
Definition: location.cpp:46
std::vector< Location > m_locations
Definition: location.h:85