[core] Use unwrapped longitude for bounds check

This commit is contained in:
Bruno de Oliveira Abinader
2019-02-23 13:22:45 +02:00
parent 7d407175e0
commit e5ed9d9ddf
5 changed files with 212 additions and 54 deletions

View File

@@ -127,15 +127,7 @@ public:
(sw.longitude() + ne.longitude()) / 2);
}
LatLng constrain(const LatLng& p) const {
if (contains(p)) {
return p;
}
return LatLng {
util::clamp(p.latitude(), sw.latitude(), ne.latitude()),
util::clamp(p.longitude(), sw.longitude(), ne.longitude())
};
}
LatLng constrain(const LatLng& p) const;
void extend(const LatLng& point) {
sw = LatLng(std::min(point.latitude(), sw.latitude()),
@@ -171,6 +163,9 @@ private:
LatLngBounds(LatLng sw_, LatLng ne_)
: sw(std::move(sw_)), ne(std::move(ne_)) {}
bool containsLatitude(double latitude) const;
bool containsLongitude(double longitude, LatLng::WrapMode wrap) const;
friend bool operator==(const LatLngBounds& a, const LatLngBounds& b) {
return a.sw == b.sw && a.ne == b.ne;
}