hivemind 1.0.0
Loading...
Searching...
No Matches
height_manager.h
Go to the documentation of this file.
1#pragma once
2
3#include "core/types.h"
4#include <array>
5#include <iostream>
6#include <vector>
7
9{
10
12 {
13 public:
15 {
16 double x;
17 double y;
18 double z;
19 };
20
21 /// \brief Constructor of HeightManager class.
22 ///
23 /// \returns No object.
25
26 /// \brief Function to update the origin point. Running this will also
27 /// trigger the population of height data for the chosen subset of the
28 /// GeoTiff file.
29 ///
30 /// \param x X coordinate used for GeoTiff subset origin.
31 /// \param y Y coordinate used for GeoTiff subset origin.
32 /// \returns No object, but will update the origin for this instance of
33 /// HeightManager and will populate the instance with height data.
34 void UpdateOrigin(Core::UTMCoordinate UTMCoord, int size);
35
36 /// \brief Function to return the whole "height_management" for a given
37 /// point.
38 ///
39 /// \param inputRelativeX The X coordinate in the relative system (where
40 /// 0,0 is the top left corner of the system). \param inputRelativeY The
41 /// Y coordinate in the relative system. \returns A height_management,
42 /// containing the geographic (absolute) x, y and z coordinates.
43 bool GetVertex(int inputRelativeX, int inputRelativeY,
44 heightdata& vertex);
45
46 /// \brief Function to return height, given relative coordinates (from a
47 /// system where 0, 0 is in the upper left corner)
48 ///
49 /// \param inputRelativeX The relative X value of the point.
50 /// \param inputRelativeY The relative Y value of the point.
51 /// \returns A float containing the height value of the point in metres.
52 bool GetHeight(int inputRelativeX, int inputRelativeY, float& height);
53
54 /// \brief Function to get the height_management of an absolute
55 /// (geographic) coordinate, using the same coordinate system of the
56 /// dataset.
57 ///
58 /// \param inputX The absolute X value of the point.
59 /// \param inputY The absolute Y value of the point.
60 /// \returns A float containing the height of the point in metres.
61 bool GetVertexAbsolute(double inputX, double inputY,
62 heightdata& vertex);
63
64 /// \brief Function to get the height of an absolute (geographic)
65 /// coordinate, using the same coordinate system of the dataset.
66 ///
67 /// \param inputX The absolute X value of the point.
68 /// \param inputY The absolute Y value of the point.
69 /// \returns A float containing the height of the point in metres.
70 float GetHeightAbsolute(double inputX, double inputY);
71
72 /// \brief Function to allow user to change GeoTiff file used in
73 /// planning. If this function is not run, the user can still update the
74 /// origin and Hivemind will run using the cached GeoTiff file.
75 ///
76 /// \param filePath Complete file path of the file to be used.
77 /// \param x X coordinate used for GeoTiff subset origin. Height data
78 /// will be populated in a 500x500 pixel centered on the origin point.
79 /// This is hard coded into the class. \param y Y coordinate used for
80 /// GeoTiff subset origin. \returns No object, but will update the path
81 /// for the cached tif.
82 void LoadTif(const char* filePath, double x, double y);
83
84 private:
85 /// \brief Function that will open the GeoTiff file and extract all
86 /// heights for the given subset of the dataset used.
87 ///
88 /// \returns No object, but after this has run, all heights will have
89 /// been imported into the instance of the class and the various
90 /// GetHeight methods can be run.
91 void PopulateVertices();
92
93 /// \brief Function to test whether a point exists within the scope of
94 /// the selected data subset.
95 ///
96 /// \param x the X value of the coordinate to be tested.
97 /// \param y the Y value of the coordinate to be tested.
98 /// \returns A bool indicating whether or not the input exists in the
99 /// subset and is valid.
100 bool ValidInput(int x, int y);
101
102 /// \brief Function to test whether a point exists within the scope of
103 /// the elected data subset. Overloaded version of ValidInput() that
104 /// takes doubles.
105 ///
106 /// \param x The X value of the coordinate to be tested.
107 /// \param y The Y value of the coordinate to be tested.
108 /// \returns A bool indicating whether or not the input exists in the
109 /// subset and is valid.
110 bool ValidInput(double x, double y);
111
112 /// \brief Function that tests whether the selected origin point is
113 /// within the bounds of the currently active data set, given the buffer
114 /// size required to extract the subset.
115 ///
116 /// \param x The X value of the origin point.
117 /// \param y The Y value of the origin point.
118 /// \returns A bool indicating whether or not the origin point is within
119 /// bounds.
120 bool OrigoWithinBounds(double x, double y);
121
122 /// \brief Function to update the corner coordinates saved within the
123 /// member instance of the chosen dataset.
124 ///
125 /// \returns No object, but the corner coordinates will be updated,
126 /// given there were no problems opening the GeoTiff file.
127 void UpdateCornerCoords();
128
129 private:
130 const char* m_CachedTifName = "../res/Kongsberg.tif";
131 const char* m_CoordinateSystem{ "UTM33" };
132 int m_Resolution{ 1 };
139 heightdata m_Origo{ 0, 0, 0 };
141 };
142
143} // namespace HeightManagement
bool GetVertexAbsolute(double inputX, double inputY, heightdata &vertex)
Function to get the height_management of an absolute (geographic) coordinate, using the same coordina...
void UpdateCornerCoords()
Function to update the corner coordinates saved within the member instance of the chosen dataset.
void PopulateVertices()
Function that will open the GeoTiff file and extract all heights for the given subset of the dataset ...
HeightManager()
Constructor of HeightManager class.
void LoadTif(const char *filePath, double x, double y)
Function to allow user to change GeoTiff file used in planning.
bool GetHeight(int inputRelativeX, int inputRelativeY, float &height)
Function to return height, given relative coordinates (from a system where 0, 0 is in the upper left ...
void UpdateOrigin(Core::UTMCoordinate UTMCoord, int size)
Function to update the origin point.
bool GetVertex(int inputRelativeX, int inputRelativeY, heightdata &vertex)
Function to return the whole "height_management" for a given point.
bool ValidInput(int x, int y)
Function to test whether a point exists within the scope of the selected data subset.
float GetHeightAbsolute(double inputX, double inputY)
Function to get the height of an absolute (geographic) coordinate, using the same coordinate system o...
bool OrigoWithinBounds(double x, double y)
Function that tests whether the selected origin point is within the bounds of the currently active da...
\ A structure that represents a coordinate in the Universal Transverse Mercator coordinate system
Definition: types.h:46