summaryrefslogtreecommitdiff
path: root/src/mbgl/map/map.cpp
diff options
context:
space:
mode:
authorzmiao <miao.zhao@mapbox.com>2019-11-07 16:49:00 +0200
committerzmiao <miao.zhao@mapbox.com>2019-11-07 17:15:40 +0200
commit2a728d1346cb89457659c412b8e486bcaa50bf6b (patch)
treee73bd5c629b3357326e663a8405c35c227b36ff2 /src/mbgl/map/map.cpp
parent8c7f2cbe33bf4cb913895afc6d5b70db33bdc87f (diff)
downloadqtlocation-mapboxgl-2a728d1346cb89457659c412b8e486bcaa50bf6b.tar.gz
[core] Take the simple approach
Diffstat (limited to 'src/mbgl/map/map.cpp')
-rw-r--r--src/mbgl/map/map.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 7714227e4d..3ea2fc43c6 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -183,8 +183,8 @@ CameraOptions cameraForLatLngs(const std::vector<LatLng>& latLngs, const Transfo
ScreenCoordinate nePixel = {-INFINITY, -INFINITY};
ScreenCoordinate swPixel = {INFINITY, INFINITY};
double viewportHeight = size.height;
- const std::vector<ScreenCoordinate> pixels = transform.latLngsToScreenCoordinates(latLngs);
- for (const auto& pixel : pixels) {
+ for (LatLng latLng : latLngs) {
+ ScreenCoordinate pixel = transform.latLngToScreenCoordinate(latLng);
swPixel.x = std::min(swPixel.x, pixel.x);
nePixel.x = std::max(nePixel.x, pixel.x);
swPixel.y = std::min(swPixel.y, viewportHeight - pixel.y);
@@ -365,18 +365,21 @@ LatLng Map::latLngForPixel(const ScreenCoordinate& pixel) const {
}
std::vector<ScreenCoordinate> Map::pixelsForLatLngs(const std::vector<LatLng>& latLngs) const {
- std::vector<LatLng> unwrappedLatLngs;
- unwrappedLatLngs.reserve(latLngs.size());
+ std::vector<ScreenCoordinate> ret;
+ ret.reserve(latLngs.size());
for (const auto& latLng : latLngs) {
- LatLng unwrappedLatLng = latLng.wrapped();
- unwrappedLatLng.unwrapForShortestPath(impl->transform.getLatLng());
- unwrappedLatLngs.emplace_back(unwrappedLatLng);
+ ret.emplace_back(pixelForLatLng(latLng));
}
- return impl->transform.latLngsToScreenCoordinates(unwrappedLatLngs);
+ return ret;
}
std::vector<LatLng> Map::latLngsForPixels(const std::vector<ScreenCoordinate>& screenCoords) const {
- return impl->transform.screenCoordinatesToLatLngs(screenCoords);
+ std::vector<LatLng> ret;
+ ret.reserve(screenCoords.size());
+ for (const auto& point : screenCoords) {
+ ret.emplace_back(latLngForPixel(point));
+ }
+ return ret;
}
#pragma mark - Annotations