summaryrefslogtreecommitdiffstats
path: root/library/cpp/geo/bbox.h
diff options
context:
space:
mode:
authorvvvv <[email protected]>2023-07-31 18:21:04 +0300
committervvvv <[email protected]>2023-07-31 18:21:04 +0300
commitdec41c40e51aa407edef81a3c566a5a15780fc49 (patch)
tree4f197b596b32f35eca368121f0dff913419da9af /library/cpp/geo/bbox.h
parent3ca8b54c96e09eb2b65be7f09675623438d559c7 (diff)
YQL-16239 Move purecalc to public
Diffstat (limited to 'library/cpp/geo/bbox.h')
-rw-r--r--library/cpp/geo/bbox.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/library/cpp/geo/bbox.h b/library/cpp/geo/bbox.h
new file mode 100644
index 00000000000..7ec7e6f7d6b
--- /dev/null
+++ b/library/cpp/geo/bbox.h
@@ -0,0 +1,59 @@
+#pragma once
+
+#include <util/generic/utility.h>
+
+#include "point.h"
+
+namespace NGeo {
+
+ class TGeoBoundingBox {
+ public:
+ TGeoBoundingBox()
+
+ = default;
+
+ TGeoBoundingBox(const TGeoPoint& p1, const TGeoPoint& p2) {
+ MinX_ = Min(p1.Lon(), p2.Lon());
+ MaxX_ = Max(p1.Lon(), p2.Lon());
+ MinY_ = Min(p1.Lat(), p2.Lat());
+ MaxY_ = Max(p1.Lat(), p2.Lat());
+ }
+
+ const double& GetMinX() const {
+ return MinX_;
+ }
+
+ const double& GetMaxX() const {
+ return MaxX_;
+ }
+
+ const double& GetMinY() const {
+ return MinY_;
+ }
+
+ const double& GetMaxY() const {
+ return MaxY_;
+ }
+
+ double Width() const {
+ return MaxX_ - MinX_;
+ }
+
+ double Height() const {
+ return MaxY_ - MinY_;
+ }
+
+ private:
+ double MinX_{std::numeric_limits<double>::quiet_NaN()};
+ double MaxX_{std::numeric_limits<double>::quiet_NaN()};
+ double MinY_{std::numeric_limits<double>::quiet_NaN()};
+ double MaxY_{std::numeric_limits<double>::quiet_NaN()};
+ };
+
+ inline bool operator==(const TGeoBoundingBox& a, const TGeoBoundingBox& b) {
+ return a.GetMinX() == b.GetMinX() &&
+ a.GetMinY() == b.GetMinY() &&
+ a.GetMaxX() == b.GetMaxX() &&
+ a.GetMaxY() == b.GetMaxY();
+ }
+} // namespace NGeo