Skip to content

Commit

Permalink
clarify altitude
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanMOlson committed Nov 12, 2024
1 parent eb06001 commit d32dc72
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions include/mbgl/map/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct CameraOptions {
center = o;
return *this;
}
CameraOptions& withAlt(const std::optional<double>& o) {
altM = o;
CameraOptions& withCenterAltitude(const std::optional<double>& o) {
centerAltitude = o;
return *this;
}
CameraOptions& withPadding(const std::optional<EdgeInsets>& p) {
Expand Down Expand Up @@ -57,7 +57,7 @@ struct CameraOptions {
/** Coordinate at the center of the map. */
std::optional<LatLng> center;

std::optional<double> altM;
std::optional<double> centerAltitude;

/** Padding around the interior of the view that affects the frame of
reference for `center`. */
Expand All @@ -84,7 +84,7 @@ struct CameraOptions {

constexpr bool operator==(const CameraOptions& a, const CameraOptions& b) {
return a.center == b.center && a.padding == b.padding && a.anchor == b.anchor && a.zoom == b.zoom &&
a.bearing == b.bearing && a.pitch == b.pitch && a.roll == b.roll && a.fov == b.fov && a.altM == b.altM;
a.bearing == b.bearing && a.pitch == b.pitch && a.roll == b.roll && a.fov == b.fov && a.centerAltitude == b.centerAltitude;
}

constexpr bool operator!=(const CameraOptions& a, const CameraOptions& b) {
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/map/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
double bearing = camera.bearing ? util::deg2rad(-*camera.bearing) : getBearing();
double pitch = camera.pitch ? util::deg2rad(*camera.pitch) : getPitch();
double fov = camera.fov ? util::deg2rad(*camera.fov) : getFieldOfView();
double alt_m = camera.altM.value_or(100000);
double center_alt = camera.centerAltitude.value_or(0);
double roll = camera.roll ? util::deg2rad(*camera.roll) : getRoll();

if (std::isnan(zoom) || std::isnan(bearing) || std::isnan(pitch)) {
Expand Down Expand Up @@ -168,7 +168,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
state.setPitch(util::interpolate(startPitch, pitch, t));
}
state.setFieldOfView(fov);
state.setAltM(alt_m);
state.setCenterAltitude(center_alt);
state.setRoll(roll);
},
duration);
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/map/transform_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void TransformState::setViewportMode(ViewportMode val) {
CameraOptions TransformState::getCameraOptions(const std::optional<EdgeInsets>& padding) const {
return CameraOptions()
.withCenter(getLatLng())
.withAlt(getAltM())
.withCenterAltitude(getCenterAltitude())
.withPadding(padding ? padding : edgeInsets)
.withZoom(getZoom())
.withBearing(util::rad2deg(-bearing))
Expand All @@ -456,7 +456,7 @@ LatLng TransformState::getLatLng(LatLng::WrapMode wrapMode) const {
return {util::rad2deg(2 * std::atan(std::exp(y / Cc)) - 0.5 * pi), -x / Bc, wrapMode};
}

double TransformState::getAltM() const {
double TransformState::getCenterAltitude() const {
return z * Projection::getMetersPerPixelAtLatitude(getLatLng().latitude(), getZoom());
}

Expand Down Expand Up @@ -838,7 +838,7 @@ void TransformState::setLatLngZoom(const LatLng& latLng, double zoom) {
setScalePoint(newScale, point);
}

void TransformState::setAltM(double alt_m) {
void TransformState::setCenterAltitude(double alt_m) {
z = alt_m / Projection::getMetersPerPixelAtLatitude(getLatLng().latitude(), getZoom());
requestMatricesUpdate = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/map/transform_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class TransformState {

// Position
LatLng getLatLng(LatLng::WrapMode = LatLng::Unwrapped) const;
double getAltM() const;
double getCenterAltitude() const;
double pixel_x() const;
double pixel_y() const;

Expand Down Expand Up @@ -235,7 +235,7 @@ class TransformState {
point on screen. */
void moveLatLng(const LatLng&, const ScreenCoordinate&);
void setLatLngZoom(const LatLng& latLng, double zoom);
void setAltM(double alt_m);
void setCenterAltitude(double alt_m);

void constrain(double& scale, double& x, double& y) const;
const mat4& getProjectionMatrix() const;
Expand Down

0 comments on commit d32dc72

Please sign in to comment.