Quetzal-CoaTL
The Coalescence Template Library
Loading...
Searching...
No Matches
extent.hpp
1// Copyright 2021 Arnaud Becheler <abechele@umich.edu>
2
3/*********************************************************************** * This program is free software; you can
4 *redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free
5 *Software Foundation; either version 2 of the License, or * (at your option) any later version. *
6 * *
7 ***************************************************************************/
8
9#pragma once
10
11namespace quetzal::geography
12{
13
18template <typename T> class extent
19{
20
21 public:
23 using value_type = T;
24
25 private:
26 value_type _lat_min;
27 value_type _lat_max;
28 value_type _lon_min;
29 value_type _lon_max;
30
31 public:
34
40 constexpr explicit extent(value_type lat_min, value_type lat_max, value_type lon_min, value_type lon_max)
41 : _lat_min(lat_min), _lat_max(lat_max), _lon_min(lon_min), _lon_max(lon_max)
42 {
43 }
44
46
49
53 constexpr bool operator==(const extent &other) const noexcept
54 {
55 if (lon_min() == other.lon_min() && lon_max() == other.lon_max() && lat_min() == other.lat_min() &&
56 lat_max() == other.lat_max())
57 {
58 return true;
59 }
60 return false;
61 }
62
66 constexpr bool operator!=(const extent &other) const noexcept
67 {
68 return !(operator==(other));
69 }
70
72
75
77 constexpr value_type lat_min() const noexcept
78 {
79 return _lat_min;
80 }
81
83 constexpr value_type lat_max() const noexcept
84 {
85 return _lat_max;
86 }
87
89 constexpr value_type lon_min() const noexcept
90 {
91 return _lon_min;
92 }
93
95 constexpr value_type lon_max() const noexcept
96 {
97 return _lon_max;
98 }
99
101
104
106 constexpr extent &lat_min(value_type val) noexcept
107 {
108 _lat_min = val;
109 return *this;
110 }
111
113 constexpr extent &lat_max(value_type val) noexcept
114 {
115 _lat_max = val;
116 return *this;
117 }
118
120 constexpr extent &lon_min(value_type val) noexcept
121 {
122 _lon_min = val;
123 return *this;
124 }
125
127 constexpr extent &lon_max(value_type val) noexcept
128 {
129 _lon_max = val;
130 return *this;
131 }
132}; // end class extent
133
134} // namespace quetzal::geography
extent of a raster grid object
Definition extent.hpp:19
constexpr value_type lon_min() const noexcept
Minimal longitude of the spatial extent.
Definition extent.hpp:89
constexpr value_type lat_min() const noexcept
Minimal latitude of the spatial extent.
Definition extent.hpp:77
constexpr value_type lon_max() const noexcept
Get the maximal longitude of the spatial extent.
Definition extent.hpp:95
constexpr extent & lon_max(value_type val) noexcept
Maximal longitude of the spatial extent.
Definition extent.hpp:127
constexpr extent & lat_min(value_type val) noexcept
Minimal latitude of the spatial extent.
Definition extent.hpp:106
constexpr extent(value_type lat_min, value_type lat_max, value_type lon_min, value_type lon_max)
Constructor.
Definition extent.hpp:40
constexpr extent & lat_max(value_type val) noexcept
Maximal longitude of the spatial extent.
Definition extent.hpp:113
constexpr extent & lon_min(value_type val) noexcept
Minimal longitude of the spatial extent.
Definition extent.hpp:120
constexpr value_type lat_max() const noexcept
Maximal latitude of the spatial extent.
Definition extent.hpp:83
constexpr bool operator==(const extent &other) const noexcept
Equality comparison.
Definition extent.hpp:53
constexpr bool operator!=(const extent &other) const noexcept
Unequality comparison.
Definition extent.hpp:66
Geospatial data formatting and processing.
Definition geography.hpp:17