summaryrefslogtreecommitdiff
path: root/src/mbgl/map
diff options
context:
space:
mode:
authorgalinelle <galinelle.mapbox@gmail.com>2020-03-19 18:53:09 +0200
committerGitHub <noreply@github.com>2020-03-19 18:53:09 +0200
commitbc45d65c58692cf0e21b4a932e4ba7bb674f12ba (patch)
treee7740ccd758fb92988902253a04bd1a23c9a002c /src/mbgl/map
parentf3cf85589447765058fab3f67d615d784fd7aa5e (diff)
downloadqtlocation-mapboxgl-bc45d65c58692cf0e21b4a932e4ba7bb674f12ba.tar.gz
Add additional transformState::latLngToScreenCoordinate getter (#16311)
This change adds a latLngToScreenCoordinate overload, to retrieve the projected vec4 in additional to the ScreenCoordinate object, that is useful to detect whether the projected latLng is in front or behind the camera.
Diffstat (limited to 'src/mbgl/map')
-rw-r--r--src/mbgl/map/transform_state.cpp8
-rw-r--r--src/mbgl/map/transform_state.hpp1
2 files changed, 7 insertions, 2 deletions
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp
index c5bb38653a..da21487d67 100644
--- a/src/mbgl/map/transform_state.cpp
+++ b/src/mbgl/map/transform_state.cpp
@@ -81,7 +81,7 @@ void TransformState::getProjMatrix(mat4& projMatrix, uint16_t nearZ, bool aligne
}
const double cameraToCenterDistance = getCameraToCenterDistance();
- auto offset = getCenterOffset();
+ const ScreenCoordinate offset = getCenterOffset();
// Find the Z distance from the viewport center point
// [width/2 + offset.x, height/2 + offset.y] to the top edge; to point
@@ -498,11 +498,15 @@ double TransformState::scaleZoom(double s) const {
}
ScreenCoordinate TransformState::latLngToScreenCoordinate(const LatLng& latLng) const {
+ vec4 p;
+ return latLngToScreenCoordinate(latLng, p);
+}
+
+ScreenCoordinate TransformState::latLngToScreenCoordinate(const LatLng& latLng, vec4& p) const {
if (size.isEmpty()) {
return {};
}
- vec4 p;
Point<double> pt = Projection::project(latLng, scale) / util::tileSize;
vec4 c = {{pt.x, pt.y, 0, 1}};
matrix::transformMat4(p, c, getCoordMatrix());
diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp
index 1561ffc904..183400d417 100644
--- a/src/mbgl/map/transform_state.hpp
+++ b/src/mbgl/map/transform_state.hpp
@@ -196,6 +196,7 @@ public:
// Conversion
ScreenCoordinate latLngToScreenCoordinate(const LatLng&) const;
+ ScreenCoordinate latLngToScreenCoordinate(const LatLng&, vec4&) const;
LatLng screenCoordinateToLatLng(const ScreenCoordinate&, LatLng::WrapMode = LatLng::Unwrapped) const;
// Implements mapbox-gl-js pointCoordinate() : MercatorCoordinate.
TileCoordinate screenCoordinateToTileCoordinate(const ScreenCoordinate&, uint8_t atZoom) const;