Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
abstract out LatLngBounds::extend
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Mar 17, 2015
1 parent 5551f0a commit 6eea1ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 7 additions & 0 deletions include/mbgl/util/geo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ struct LatLngBounds {

inline LatLngBounds(LatLng sw_ = {90, 180}, LatLng ne_ = {-90, -180})
: sw(sw_), ne(ne_) {}

inline void extend(const LatLng& point) {
if (point.latitude < sw.latitude) sw.latitude = point.latitude;
if (point.latitude > ne.latitude) ne.latitude = point.latitude;
if (point.longitude < sw.longitude) sw.longitude = point.longitude;
if (point.longitude > ne.longitude) ne.longitude = point.longitude;
}
};

}
Expand Down
7 changes: 1 addition & 6 deletions src/mbgl/map/annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ Annotation::Annotation(AnnotationType type_, std::vector<AnnotationSegment> geom
if (type == AnnotationType::Point) {
bounds = LatLngBounds(getPoint(), getPoint());
} else {
LatLng sw, ne;
for (auto segment : geometry) {
for (auto point : segment) {
if (point.latitude < sw.latitude) sw.latitude = point.latitude;
if (point.latitude > ne.latitude) ne.latitude = point.latitude;
if (point.longitude < sw.longitude) sw.longitude = point.longitude;
if (point.longitude > ne.longitude) ne.longitude = point.longitude;
bounds.extend(point);
}
}
bounds = LatLngBounds(sw, ne);
}
}

Expand Down

0 comments on commit 6eea1ac

Please sign in to comment.