diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-02-09 20:56:07 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-01 20:58:54 +0000 |
commit | 4994b3dc574443ad6e24ea1d715e0ebcdbb0f124 (patch) | |
tree | f8b61e5acc88502b740f401deb61679126b1cbd0 /src/mbgl | |
parent | 1ce99d2d7b1921dfac1d302553160184ceac7d3e (diff) | |
download | qtlocation-mapboxgl-4994b3dc574443ad6e24ea1d715e0ebcdbb0f124.tar.gz |
[core] PrecisionPoint is now ScreenCoordinate
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/annotation/point_annotation_impl.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 34 | ||||
-rw-r--r-- | src/mbgl/map/transform.cpp | 70 | ||||
-rw-r--r-- | src/mbgl/map/transform.hpp | 20 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.cpp | 16 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.hpp | 12 | ||||
-rw-r--r-- | src/mbgl/util/geo.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/util/tile_cover.cpp | 18 |
8 files changed, 88 insertions, 88 deletions
diff --git a/src/mbgl/annotation/point_annotation_impl.cpp b/src/mbgl/annotation/point_annotation_impl.cpp index 2eef68a8eb..10e65e4c07 100644 --- a/src/mbgl/annotation/point_annotation_impl.cpp +++ b/src/mbgl/annotation/point_annotation_impl.cpp @@ -13,7 +13,7 @@ void PointAnnotationImpl::updateLayer(const TileID& tileID, AnnotationTileLayer& featureProperties.emplace("sprite", point.icon.empty() ? std::string("default_marker") : point.icon); const uint16_t extent = 4096; - const mbgl::PrecisionPoint pp = point.position.project(); + const mbgl::ScreenCoordinate pp = point.position.project(); const uint32_t z2 = 1 << tileID.z; const uint32_t x = pp.x * z2; const uint32_t y = pp.y * z2; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index fe6a611742..6315dbdef7 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -166,7 +166,7 @@ void Map::flyTo(const CameraOptions& camera, const AnimationOptions& animation) #pragma mark - Position -void Map::moveBy(const PrecisionPoint& point, const Duration& duration) { +void Map::moveBy(const ScreenCoordinate& point, const Duration& duration) { transform->moveBy(point, duration); update(Update::Repaint); } @@ -180,7 +180,7 @@ void Map::setLatLng(const LatLng& latLng, const EdgeInsets& padding, const Durat update(Update::Repaint); } -void Map::setLatLng(const LatLng& latLng, const PrecisionPoint& point, const Duration& duration) { +void Map::setLatLng(const LatLng& latLng, const ScreenCoordinate& point, const Duration& duration) { transform->setLatLng(latLng, point, duration); update(Update::Repaint); } @@ -204,12 +204,12 @@ void Map::resetPosition(const EdgeInsets& padding) { #pragma mark - Scale -void Map::scaleBy(double ds, const PrecisionPoint& point, const Duration& duration) { +void Map::scaleBy(double ds, const ScreenCoordinate& point, const Duration& duration) { transform->scaleBy(ds, point, duration); update(Update::Zoom); } -void Map::setScale(double scale, const PrecisionPoint& point, const Duration& duration) { +void Map::setScale(double scale, const ScreenCoordinate& point, const Duration& duration) { transform->setScale(scale, point, duration); update(Update::Zoom); } @@ -257,11 +257,11 @@ CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const Ed } // Calculate the bounds of the possibly rotated shape with respect to the viewport. - PrecisionPoint nePixel = {-INFINITY, -INFINITY}; - PrecisionPoint swPixel = {INFINITY, INFINITY}; + ScreenCoordinate nePixel = {-INFINITY, -INFINITY}; + ScreenCoordinate swPixel = {INFINITY, INFINITY}; double viewportHeight = getHeight(); for (LatLng latLng : latLngs) { - PrecisionPoint pixel = pixelForLatLng(latLng); + ScreenCoordinate pixel = pixelForLatLng(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); @@ -278,15 +278,15 @@ CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const Ed zoom = util::clamp(zoom, getMinZoom(), getMaxZoom()); // Calculate the center point of a virtual bounds that is extended in all directions by padding. - PrecisionPoint paddedNEPixel = { + ScreenCoordinate paddedNEPixel = { nePixel.x + padding.right / minScale, nePixel.y + padding.top / minScale, }; - PrecisionPoint paddedSWPixel = { + ScreenCoordinate paddedSWPixel = { swPixel.x - padding.left / minScale, swPixel.y - padding.bottom / minScale, }; - PrecisionPoint centerPixel = { + ScreenCoordinate centerPixel = { (paddedNEPixel.x + paddedSWPixel.x) / 2, (paddedNEPixel.y + paddedSWPixel.y) / 2, }; @@ -339,7 +339,7 @@ uint16_t Map::getHeight() const { #pragma mark - Rotation -void Map::rotateBy(const PrecisionPoint& first, const PrecisionPoint& second, const Duration& duration) { +void Map::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const Duration& duration) { transform->rotateBy(first, second, duration); update(Update::Repaint); } @@ -348,7 +348,7 @@ void Map::setBearing(double degrees, const Duration& duration) { setBearing(degrees, EdgeInsets(), duration); } -void Map::setBearing(double degrees, const PrecisionPoint& center, const Duration& duration) { +void Map::setBearing(double degrees, const ScreenCoordinate& center, const Duration& duration) { transform->setAngle(-degrees * util::DEG2RAD, center, duration); update(Update::Repaint); } @@ -374,7 +374,7 @@ void Map::setPitch(double pitch, const Duration& duration) { setPitch(pitch, {NAN, NAN}, duration); } -void Map::setPitch(double pitch, const PrecisionPoint& anchor, const Duration& duration) { +void Map::setPitch(double pitch, const ScreenCoordinate& anchor, const Duration& duration) { transform->setPitch(pitch * util::DEG2RAD, anchor, duration); update(Update::Repaint); } @@ -420,12 +420,12 @@ LatLng Map::latLngForProjectedMeters(const ProjectedMeters& projectedMeters) con return Projection::latLngForProjectedMeters(projectedMeters); } -PrecisionPoint Map::pixelForLatLng(const LatLng& latLng) const { - return transform->latLngToPoint(latLng); +ScreenCoordinate Map::pixelForLatLng(const LatLng& latLng) const { + return transform->latLngToScreenCoordinate(latLng); } -LatLng Map::latLngForPixel(const PrecisionPoint& pixel) const { - return transform->pointToLatLng(pixel); +LatLng Map::latLngForPixel(const ScreenCoordinate& pixel) const { + return transform->screenCoordinateToLatLng(pixel); } #pragma mark - Annotations diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 216b3dc9eb..7e7436b1dc 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -36,7 +36,7 @@ static double _normalizeAngle(double angle, double anchorAngle) return angle; } -inline bool _validPoint(const PrecisionPoint& point) { +inline bool _validPoint(const ScreenCoordinate& point) { return !std::isnan(point.x) && !std::isnan(point.y); } @@ -97,16 +97,16 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim padding = *camera.padding; } const LatLng startLatLng = getLatLng(padding); - const PrecisionPoint startPoint = { + const ScreenCoordinate startPoint = { state.lngX(startLatLng.longitude), state.latY(startLatLng.latitude), }; unwrapLatLng(latLng); - const PrecisionPoint endPoint = { + const ScreenCoordinate endPoint = { state.lngX(latLng.longitude), state.latY(latLng.latitude), }; - PrecisionPoint center = padding.getCenter(state.width, state.height); + ScreenCoordinate center = padding.getCenter(state.width, state.height); center.y = state.height - center.y; // Constrain camera options. @@ -134,7 +134,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim state.rotating = angle != startAngle; startTransition(camera, animation, [=](double t) { - PrecisionPoint framePoint = util::interpolate(startPoint, endPoint, t); + ScreenCoordinate framePoint = util::interpolate(startPoint, endPoint, t); LatLng frameLatLng = { state.yLat(framePoint.y, startWorldSize), state.xLng(framePoint.x, startWorldSize), @@ -180,16 +180,16 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima padding = *camera.padding; } const LatLng startLatLng = getLatLng(padding); - const PrecisionPoint startPoint = { + const ScreenCoordinate startPoint = { state.lngX(startLatLng.longitude), state.latY(startLatLng.latitude), }; unwrapLatLng(latLng); - const PrecisionPoint endPoint = { + const ScreenCoordinate endPoint = { state.lngX(latLng.longitude), state.latY(latLng.latitude), }; - PrecisionPoint center = padding.getCenter(state.width, state.height); + ScreenCoordinate center = padding.getCenter(state.width, state.height); center.y = state.height - center.y; // Constrain camera options. @@ -305,7 +305,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima double us = u(s); // Calculate the current point and zoom level along the flight path. - PrecisionPoint framePoint = util::interpolate(startPoint, endPoint, us); + ScreenCoordinate framePoint = util::interpolate(startPoint, endPoint, us); double frameZoom = startZoom + state.scaleZoom(1 / w(s)); // Convert to geographic coordinates and set the new viewpoint. @@ -344,19 +344,19 @@ void Transform::unwrapLatLng(LatLng& latLng) { #pragma mark - Position -void Transform::moveBy(const PrecisionPoint& offset, const Duration& duration) { +void Transform::moveBy(const ScreenCoordinate& offset, const Duration& duration) { if (!_validPoint(offset)) { return; } - PrecisionPoint centerOffset = { + ScreenCoordinate centerOffset = { offset.x, -offset.y, }; - PrecisionPoint centerPoint = state.latLngToPoint(state.getLatLng()) - centerOffset; + ScreenCoordinate centerPoint = state.latLngToScreenCoordinate(state.getLatLng()) - centerOffset; CameraOptions camera; - camera.center = state.pointToLatLng(centerPoint); + camera.center = state.screenCoordinateToLatLng(centerPoint); easeTo(camera, duration); } @@ -377,7 +377,7 @@ void Transform::setLatLng(const LatLng& latLng, const EdgeInsets& padding, const easeTo(camera, duration); } -void Transform::setLatLng(const LatLng& latLng, const PrecisionPoint& point, const Duration& duration) { +void Transform::setLatLng(const LatLng& latLng, const ScreenCoordinate& point, const Duration& duration) { if (!latLng || !point) { return; } @@ -414,7 +414,7 @@ void Transform::setLatLngZoom(const LatLng& latLng, double zoom, const EdgeInset LatLng Transform::getLatLng(const EdgeInsets& padding) const { if (padding) { - return pointToLatLng(padding.getCenter(state.width, state.height)); + return screenCoordinateToLatLng(padding.getCenter(state.width, state.height)); } else { return state.getLatLng(); } @@ -423,7 +423,7 @@ LatLng Transform::getLatLng(const EdgeInsets& padding) const { #pragma mark - Zoom -void Transform::scaleBy(double ds, const PrecisionPoint& center, const Duration& duration) { +void Transform::scaleBy(double ds, const ScreenCoordinate& center, const Duration& duration) { if (std::isnan(ds)) { return; } @@ -432,12 +432,12 @@ void Transform::scaleBy(double ds, const PrecisionPoint& center, const Duration& setScale(scale, center, duration); } -void Transform::setZoom(double zoom, const PrecisionPoint& anchor, const Duration& duration) { +void Transform::setZoom(double zoom, const ScreenCoordinate& anchor, const Duration& duration) { setScale(state.zoomScale(zoom), anchor, duration); } void Transform::setZoom(double zoom, const EdgeInsets& padding, const Duration& duration) { - const PrecisionPoint center = padding.getCenter(state.width, state.height); + const ScreenCoordinate center = padding.getCenter(state.width, state.height); setZoom(zoom, center, duration); } @@ -449,7 +449,7 @@ double Transform::getScale() const { return state.scale; } -void Transform::setScale(double scale, const PrecisionPoint& anchor, const Duration& duration) { +void Transform::setScale(double scale, const ScreenCoordinate& anchor, const Duration& duration) { if (std::isnan(scale)) { return; } @@ -461,7 +461,7 @@ void Transform::setScale(double scale, const PrecisionPoint& anchor, const Durat } void Transform::setScale(double scale, const EdgeInsets& padding, const Duration& duration) { - const PrecisionPoint center = padding.getCenter(state.width, state.height); + const ScreenCoordinate center = padding.getCenter(state.width, state.height); setScale(scale, center, duration); } @@ -475,15 +475,15 @@ void Transform::setMaxZoom(const double maxZoom) { #pragma mark - Angle -void Transform::rotateBy(const PrecisionPoint& first, const PrecisionPoint& second, const Duration& duration) { +void Transform::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const Duration& duration) { if (!first || !second) { return; } - PrecisionPoint center(state.width, state.height); + ScreenCoordinate center(state.width, state.height); center /= 2; - const PrecisionPoint offset = first - center; + const ScreenCoordinate offset = first - center; const double distance = std::sqrt(std::pow(2, offset.x) + std::pow(2, offset.y)); // If the first click was too close to the center, move the center of rotation by 200 pixels @@ -495,8 +495,8 @@ void Transform::rotateBy(const PrecisionPoint& first, const PrecisionPoint& seco center.y = first.y + std::sin(rotateAngle) * heightOffset; } - const PrecisionPoint newFirst = first - center; - const PrecisionPoint newSecond = second - center; + const ScreenCoordinate newFirst = first - center; + const ScreenCoordinate newSecond = second - center; const double ang = state.angle + util::angle_between(newFirst.x, newFirst.y, newSecond.x, newSecond.y); CameraOptions camera; @@ -508,7 +508,7 @@ void Transform::setAngle(double angle, const Duration& duration) { setAngle(angle, {NAN, NAN}, duration); } -void Transform::setAngle(double angle, const PrecisionPoint& anchor, const Duration& duration) { +void Transform::setAngle(double angle, const ScreenCoordinate& anchor, const Duration& duration) { if (std::isnan(angle)) { return; } @@ -520,7 +520,7 @@ void Transform::setAngle(double angle, const PrecisionPoint& anchor, const Durat } void Transform::setAngle(double angle, const EdgeInsets& padding, const Duration& duration) { - const PrecisionPoint center = padding.getCenter(state.width, state.height); + const ScreenCoordinate center = padding.getCenter(state.width, state.height); setAngle(angle, center, duration); } @@ -534,7 +534,7 @@ void Transform::setPitch(double pitch, const Duration& duration) { setPitch(pitch, {NAN, NAN}, duration); } -void Transform::setPitch(double pitch, const PrecisionPoint& anchor, const Duration& duration) { +void Transform::setPitch(double pitch, const ScreenCoordinate& anchor, const Duration& duration) { if (std::isnan(pitch)) { return; } @@ -585,11 +585,11 @@ void Transform::startTransition(const CameraOptions& camera, view.notifyMapChange(isAnimated ? MapChangeRegionWillChangeAnimated : MapChangeRegionWillChange); // Associate the anchor, if given, with a coordinate. - PrecisionPoint anchor = camera.anchor ? *camera.anchor : PrecisionPoint(NAN, NAN); + ScreenCoordinate anchor = camera.anchor ? *camera.anchor : ScreenCoordinate(NAN, NAN); LatLng anchorLatLng; if (_validPoint(anchor)) { anchor.y = state.getHeight() - anchor.y; - anchorLatLng = state.pointToLatLng(anchor); + anchorLatLng = state.screenCoordinateToLatLng(anchor); } transitionStart = Clock::now(); @@ -664,14 +664,14 @@ void Transform::setGestureInProgress(bool inProgress) { #pragma mark Conversion and projection -PrecisionPoint Transform::latLngToPoint(const LatLng& latLng) const { - PrecisionPoint point = state.latLngToPoint(latLng); +ScreenCoordinate Transform::latLngToScreenCoordinate(const LatLng& latLng) const { + ScreenCoordinate point = state.latLngToScreenCoordinate(latLng); point.y = state.height - point.y; return point; } -LatLng Transform::pointToLatLng(const PrecisionPoint& point) const { - PrecisionPoint flippedPoint = point; +LatLng Transform::screenCoordinateToLatLng(const ScreenCoordinate& point) const { + ScreenCoordinate flippedPoint = point; flippedPoint.y = state.height - flippedPoint.y; - return state.pointToLatLng(flippedPoint); + return state.screenCoordinateToLatLng(flippedPoint); } diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp index 48615421fe..d7f9e6c51a 100644 --- a/src/mbgl/map/transform.hpp +++ b/src/mbgl/map/transform.hpp @@ -41,10 +41,10 @@ public: /** Pans the map by the given amount. @param offset The distance to pan the map by, measured in pixels from top to bottom and from left to right. */ - void moveBy(const PrecisionPoint& offset, const Duration& = Duration::zero()); + void moveBy(const ScreenCoordinate& offset, const Duration& = Duration::zero()); void setLatLng(const LatLng&, const Duration& = Duration::zero()); void setLatLng(const LatLng&, const EdgeInsets&, const Duration& = Duration::zero()); - void setLatLng(const LatLng&, const PrecisionPoint&, const Duration& = Duration::zero()); + void setLatLng(const LatLng&, const ScreenCoordinate&, const Duration& = Duration::zero()); void setLatLngZoom(const LatLng&, double zoom, const Duration& = Duration::zero()); void setLatLngZoom(const LatLng&, double zoom, const EdgeInsets&, const Duration& = Duration::zero()); LatLng getLatLng(const EdgeInsets& = {}) const; @@ -55,12 +55,12 @@ public: @param ds The difference in scale factors to scale the map by. @param anchor A point relative to the top-left corner of the view. If unspecified, the center point is fixed within the view. */ - void scaleBy(double ds, const PrecisionPoint& anchor = {NAN, NAN}, const Duration& = Duration::zero()); + void scaleBy(double ds, const ScreenCoordinate& anchor = {NAN, NAN}, const Duration& = Duration::zero()); /** Sets the scale factor, keeping the given point fixed within the view. @param scale The new scale factor. @param anchor A point relative to the top-left corner of the view. If unspecified, the center point is fixed within the view. */ - void setScale(double scale, const PrecisionPoint& anchor = {NAN, NAN}, const Duration& = Duration::zero()); + void setScale(double scale, const ScreenCoordinate& anchor = {NAN, NAN}, const Duration& = Duration::zero()); /** Sets the scale factor, keeping the center point fixed within the inset view. @param scale The new scale factor. @param padding The viewport padding that affects the fixed center point. */ @@ -69,7 +69,7 @@ public: @param zoom The new zoom level. @param anchor A point relative to the top-left corner of the view. If unspecified, the center point is fixed within the view. */ - void setZoom(double zoom, const PrecisionPoint& anchor = {NAN, NAN}, const Duration& = Duration::zero()); + void setZoom(double zoom, const ScreenCoordinate& anchor = {NAN, NAN}, const Duration& = Duration::zero()); /** Sets the zoom level, keeping the center point fixed within the inset view. @param zoom The new zoom level. @param padding The viewport padding that affects the fixed center point. */ @@ -84,7 +84,7 @@ public: // Angle - void rotateBy(const PrecisionPoint& first, const PrecisionPoint& second, const Duration& = Duration::zero()); + void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const Duration& = Duration::zero()); /** Sets the angle of rotation. @param angle The new angle of rotation, measured in radians counterclockwise from true north. */ @@ -93,7 +93,7 @@ public: @param angle The new angle of rotation, measured in radians counterclockwise from true north. @param anchor A point relative to the top-left corner of the view. */ - void setAngle(double angle, const PrecisionPoint& anchor, const Duration& = Duration::zero()); + void setAngle(double angle, const ScreenCoordinate& anchor, const Duration& = Duration::zero()); /** Sets the angle of rotation, keeping the center point fixed within the inset view. @param angle The new angle of rotation, measured in radians counterclockwise from true north. @@ -113,7 +113,7 @@ public: @param angle The new pitch angle, measured in radians toward the horizon. @param anchor A point relative to the top-left corner of the view. */ - void setPitch(double pitch, const PrecisionPoint& anchor, const Duration& = Duration::zero()); + void setPitch(double pitch, const ScreenCoordinate& anchor, const Duration& = Duration::zero()); double getPitch() const; // North Orientation @@ -140,8 +140,8 @@ public: bool isPanning() const { return state.isPanning(); } // Conversion and projection - PrecisionPoint latLngToPoint(const LatLng&) const; - LatLng pointToLatLng(const PrecisionPoint&) const; + ScreenCoordinate latLngToScreenCoordinate(const LatLng&) const; + LatLng screenCoordinateToLatLng(const ScreenCoordinate&) const; private: void unwrapLatLng(LatLng&); diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index 1ac6b5fbfa..99126809ef 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -249,11 +249,11 @@ double TransformState::worldSize() const { return scale * util::tileSize; } -PrecisionPoint TransformState::latLngToPoint(const LatLng& latLng) const { +ScreenCoordinate TransformState::latLngToScreenCoordinate(const LatLng& latLng) const { return coordinateToPoint(latLngToCoordinate(latLng)); } -LatLng TransformState::pointToLatLng(const PrecisionPoint& point) const { +LatLng TransformState::screenCoordinateToLatLng(const ScreenCoordinate& point) const { return coordinateToLatLng(pointToCoordinate(point)); } @@ -276,7 +276,7 @@ LatLng TransformState::coordinateToLatLng(const TileCoordinate& coord) const { return latLng; } -PrecisionPoint TransformState::coordinateToPoint(const TileCoordinate& coord) const { +ScreenCoordinate TransformState::coordinateToPoint(const TileCoordinate& coord) const { mat4 mat = coordinatePointMatrix(coord.zoom); vec4<double> p; vec4<double> c = { coord.column, coord.row, 0, 1 }; @@ -284,7 +284,7 @@ PrecisionPoint TransformState::coordinateToPoint(const TileCoordinate& coord) co return { p.x / p.w, height - p.y / p.w }; } -TileCoordinate TransformState::pointToCoordinate(const PrecisionPoint& point) const { +TileCoordinate TransformState::pointToCoordinate(const ScreenCoordinate& point) const { float targetZ = 0; const double tileZoom = getZoom(); @@ -366,7 +366,7 @@ void TransformState::constrain(double& scale_, double& x_, double& y_) const { } } -void TransformState::moveLatLng(const LatLng& latLng, const PrecisionPoint& anchor) { +void TransformState::moveLatLng(const LatLng& latLng, const ScreenCoordinate& anchor) { if (!latLng || !anchor) { return; } @@ -395,16 +395,16 @@ void TransformState::setLatLngZoom(const LatLng &latLng, double zoom) { const double m = 1 - 1e-15; const double f = util::clamp(std::sin(util::DEG2RAD * latLng.latitude), -m, m); - PrecisionPoint point = { + ScreenCoordinate point = { -latLng.longitude * Bc, 0.5 * Cc * std::log((1 + f) / (1 - f)), }; setScalePoint(newScale, point); } -void TransformState::setScalePoint(const double newScale, const PrecisionPoint &point) { +void TransformState::setScalePoint(const double newScale, const ScreenCoordinate &point) { double constrainedScale = newScale; - PrecisionPoint constrainedPoint = point; + ScreenCoordinate constrainedPoint = point; constrain(constrainedScale, constrainedPoint.x, constrainedPoint.y); scale = constrainedScale; diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index c57b2b8e1b..f86ba9eed6 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -65,14 +65,14 @@ public: bool isGestureInProgress() const; // Conversion and projection - PrecisionPoint latLngToPoint(const LatLng&) const; - LatLng pointToLatLng(const PrecisionPoint&) const; + ScreenCoordinate latLngToScreenCoordinate(const LatLng&) const; + LatLng screenCoordinateToLatLng(const ScreenCoordinate&) const; TileCoordinate latLngToCoordinate(const LatLng&) const; LatLng coordinateToLatLng(const TileCoordinate&) const; - PrecisionPoint coordinateToPoint(const TileCoordinate&) const; - TileCoordinate pointToCoordinate(const PrecisionPoint&) const; + ScreenCoordinate coordinateToPoint(const TileCoordinate&) const; + TileCoordinate pointToCoordinate(const ScreenCoordinate&) const; private: bool rotatedNorth() const; @@ -100,9 +100,9 @@ private: /** Recenter the map so that the given coordinate is located at the given point on screen. */ - void moveLatLng(const LatLng&, const PrecisionPoint&); + void moveLatLng(const LatLng&, const ScreenCoordinate&); void setLatLngZoom(const LatLng &latLng, double zoom); - void setScalePoint(const double scale, const PrecisionPoint& point); + void setScalePoint(const double scale, const ScreenCoordinate& point); private: ConstrainMode constrainMode; diff --git a/src/mbgl/util/geo.cpp b/src/mbgl/util/geo.cpp index 6a279c823d..f08dca7272 100644 --- a/src/mbgl/util/geo.cpp +++ b/src/mbgl/util/geo.cpp @@ -12,7 +12,7 @@ LatLng::LatLng(const TileID& id) { latitude = util::RAD2DEG * std::atan(0.5 * (std::exp(n) - std::exp(-n))); } -PrecisionPoint LatLng::project() const { +ScreenCoordinate LatLng::project() const { // Clamp to the latitude limits of Mercator. const double constrainedLatitude = ::fmin(::fmax(latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX); @@ -28,7 +28,7 @@ LatLngBounds::LatLngBounds(const TileID& id) ne(TileID{ id.z, id.x + 1, id.y, id.sourceZ }) { } -PrecisionPoint EdgeInsets::getCenter(uint16_t width, uint16_t height) const { +ScreenCoordinate EdgeInsets::getCenter(uint16_t width, uint16_t height) const { return { (width - left - right) / 2.0f + left, (height - top - bottom) / 2.0f + top, diff --git a/src/mbgl/util/tile_cover.cpp b/src/mbgl/util/tile_cover.cpp index e77ea469a7..7af3ebd8b1 100644 --- a/src/mbgl/util/tile_cover.cpp +++ b/src/mbgl/util/tile_cover.cpp @@ -14,8 +14,8 @@ struct edge { double x1 = 0, y1 = 0; double dx = 0, dy = 0; - edge(vec2<double> a, vec2<double> b) { - if (a.y > b.y) { std::swap(a, b); } + edge(ScreenCoordinate a, ScreenCoordinate b) { + if (a.y > b.y) std::swap(a, b); x0 = a.x; y0 = a.y; x1 = b.x; @@ -52,7 +52,7 @@ static void scanSpans(edge e0, edge e1, int32_t ymin, int32_t ymax, ScanLine sca } // scan-line conversion -static void scanTriangle(const mbgl::vec2<double> a, const mbgl::vec2<double> b, const mbgl::vec2<double> c, int32_t ymin, int32_t ymax, ScanLine& scanLine) { +static void scanTriangle(const ScreenCoordinate& a, const ScreenCoordinate& b, const ScreenCoordinate& c, int32_t ymin, int32_t ymax, ScanLine& scanLine) { edge ab = edge(a, b); edge bc = edge(b, c); edge ca = edge(c, a); @@ -76,7 +76,7 @@ int32_t coveringZoomLevel(double zoom, SourceType type, uint16_t tileSize) { } } -static mbgl::vec2<double> zoomTo(const TileCoordinate& c, double z) { +static ScreenCoordinate zoomTo(const TileCoordinate& c, double z) { double scale = std::pow(2, z - c.zoom); return { c.column * scale, c.row * scale }; } @@ -100,11 +100,11 @@ std::vector<TileID> tileCover(const TileCoordinate& tl_, } }; - mbgl::vec2<double> tl = zoomTo(tl_, z); - mbgl::vec2<double> tr = zoomTo(tr_, z); - mbgl::vec2<double> br = zoomTo(br_, z); - mbgl::vec2<double> bl = zoomTo(bl_, z); - mbgl::vec2<double> c = zoomTo(center, z); + const ScreenCoordinate tl(zoomTo(tl_, z)); + const ScreenCoordinate tr(zoomTo(tr_, z)); + const ScreenCoordinate br(zoomTo(br_, z)); + const ScreenCoordinate bl(zoomTo(bl_, z)); + const ScreenCoordinate c(zoomTo(center, z)); // Divide the screen up in two triangles and scan each of them: // \---+ |