mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-21 13:53:37 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
39
3party/open-location-code/codearea.cc
Normal file
39
3party/open-location-code/codearea.cc
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "codearea.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace openlocationcode {
|
||||
|
||||
const double kLatitudeMaxDegrees = 90;
|
||||
const double kLongitudeMaxDegrees = 180;
|
||||
|
||||
CodeArea::CodeArea(double latitude_lo, double longitude_lo, double latitude_hi,
|
||||
double longitude_hi, size_t code_length) {
|
||||
latitude_lo_ = latitude_lo;
|
||||
longitude_lo_ = longitude_lo;
|
||||
latitude_hi_ = latitude_hi;
|
||||
longitude_hi_ = longitude_hi;
|
||||
code_length_ = code_length;
|
||||
}
|
||||
|
||||
double CodeArea::GetLatitudeLo() const { return latitude_lo_; }
|
||||
|
||||
double CodeArea::GetLongitudeLo() const { return longitude_lo_; }
|
||||
|
||||
double CodeArea::GetLatitudeHi() const { return latitude_hi_; }
|
||||
|
||||
double CodeArea::GetLongitudeHi() const { return longitude_hi_; }
|
||||
|
||||
size_t CodeArea::GetCodeLength() const { return code_length_; }
|
||||
|
||||
LatLng CodeArea::GetCenter() const {
|
||||
const double latitude_center = std::min(
|
||||
latitude_lo_ + (latitude_hi_ - latitude_lo_) / 2, kLatitudeMaxDegrees);
|
||||
const double longitude_center =
|
||||
std::min(longitude_lo_ + (longitude_hi_ - longitude_lo_) / 2,
|
||||
kLongitudeMaxDegrees);
|
||||
const LatLng center = {latitude_center, longitude_center};
|
||||
return center;
|
||||
}
|
||||
|
||||
} // namespace openlocationcode
|
||||
Reference in New Issue
Block a user