[core] PrecisionPoint is now ScreenCoordinate
This commit is contained in:
@@ -22,7 +22,7 @@ struct CameraOptions {
|
||||
|
||||
/** Point of reference for `zoom` and `angle`, assuming an origin at the
|
||||
top-left corner of the view. */
|
||||
optional<PrecisionPoint> anchor;
|
||||
optional<ScreenCoordinate> anchor;
|
||||
|
||||
/** Zero-based zoom level. Constrained to the minimum and maximum zoom
|
||||
levels. */
|
||||
|
||||
@@ -97,16 +97,16 @@ public:
|
||||
void flyTo(const CameraOptions&, const AnimationOptions&);
|
||||
|
||||
// Position
|
||||
void moveBy(const PrecisionPoint&, const Duration& = Duration::zero());
|
||||
void setLatLng(const LatLng&, const PrecisionPoint&, const Duration& = Duration::zero());
|
||||
void moveBy(const ScreenCoordinate&, const Duration& = Duration::zero());
|
||||
void setLatLng(const LatLng&, const ScreenCoordinate&, const Duration& = Duration::zero());
|
||||
void setLatLng(const LatLng&, const EdgeInsets&, const Duration& = Duration::zero());
|
||||
void setLatLng(const LatLng&, const Duration& = Duration::zero());
|
||||
LatLng getLatLng(const EdgeInsets& = {}) const;
|
||||
void resetPosition(const EdgeInsets& = {});
|
||||
|
||||
// Scale
|
||||
void scaleBy(double ds, const PrecisionPoint& = { NAN, NAN }, const Duration& = Duration::zero());
|
||||
void setScale(double scale, const PrecisionPoint& = { NAN, NAN }, const Duration& = Duration::zero());
|
||||
void scaleBy(double ds, const ScreenCoordinate& = { NAN, NAN }, const Duration& = Duration::zero());
|
||||
void setScale(double scale, const ScreenCoordinate& = { NAN, NAN }, const Duration& = Duration::zero());
|
||||
double getScale() const;
|
||||
void setZoom(double zoom, const Duration& = Duration::zero());
|
||||
void setZoom(double zoom, const EdgeInsets&, const Duration& = Duration::zero());
|
||||
@@ -122,9 +122,9 @@ public:
|
||||
double getMaxZoom() const;
|
||||
|
||||
// Rotation
|
||||
void rotateBy(const PrecisionPoint& first, const PrecisionPoint& second, const Duration& = Duration::zero());
|
||||
void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const Duration& = Duration::zero());
|
||||
void setBearing(double degrees, const Duration& = Duration::zero());
|
||||
void setBearing(double degrees, const PrecisionPoint&, const Duration& = Duration::zero());
|
||||
void setBearing(double degrees, const ScreenCoordinate&, const Duration& = Duration::zero());
|
||||
void setBearing(double degrees, const EdgeInsets&, const Duration& = Duration::zero());
|
||||
double getBearing() const;
|
||||
void resetNorth(const Duration& = Milliseconds(500));
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
|
||||
// Pitch
|
||||
void setPitch(double pitch, const Duration& = Duration::zero());
|
||||
void setPitch(double pitch, const PrecisionPoint&, const Duration& = Duration::zero());
|
||||
void setPitch(double pitch, const ScreenCoordinate&, const Duration& = Duration::zero());
|
||||
double getPitch() const;
|
||||
|
||||
// North Orientation
|
||||
@@ -151,8 +151,8 @@ public:
|
||||
double getMetersPerPixelAtLatitude(double lat, double zoom) const;
|
||||
ProjectedMeters projectedMetersForLatLng(const LatLng&) const;
|
||||
LatLng latLngForProjectedMeters(const ProjectedMeters&) const;
|
||||
PrecisionPoint pixelForLatLng(const LatLng&) const;
|
||||
LatLng latLngForPixel(const PrecisionPoint&) const;
|
||||
ScreenCoordinate pixelForLatLng(const LatLng&) const;
|
||||
LatLng latLngForPixel(const ScreenCoordinate&) const;
|
||||
|
||||
// Annotations
|
||||
void addAnnotationIcon(const std::string&, std::shared_ptr<const SpriteImage>);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace mbgl {
|
||||
|
||||
class TileID;
|
||||
|
||||
using PrecisionPoint = vec2<double>;
|
||||
using ScreenCoordinate = vec2<double>;
|
||||
|
||||
class LatLng {
|
||||
public:
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
// Constructs a LatLng object with the top left position of the specified tile.
|
||||
LatLng(const TileID& id);
|
||||
|
||||
PrecisionPoint project() const;
|
||||
ScreenCoordinate project() const;
|
||||
};
|
||||
|
||||
inline bool operator==(const LatLng& a, const LatLng& b) {
|
||||
@@ -195,7 +195,7 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
PrecisionPoint getCenter(uint16_t width, uint16_t height) const;
|
||||
ScreenCoordinate getCenter(uint16_t width, uint16_t height) const;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -732,7 +732,7 @@ void JNICALL nativeMoveBy(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdou
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeMoveBy");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
mbgl::PrecisionPoint center(dx, dy);
|
||||
mbgl::ScreenCoordinate center(dx, dy);
|
||||
nativeMapView->getMap().moveBy(center, mbgl::Milliseconds(duration));
|
||||
}
|
||||
|
||||
@@ -799,7 +799,7 @@ void JNICALL nativeScaleBy(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdo
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeScaleBy");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
mbgl::PrecisionPoint center(cx, cy);
|
||||
mbgl::ScreenCoordinate center(cx, cy);
|
||||
nativeMapView->getMap().scaleBy(ds, center, mbgl::Milliseconds(duration));
|
||||
}
|
||||
|
||||
@@ -808,7 +808,7 @@ void JNICALL nativeSetScale(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jd
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetScale");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
mbgl::PrecisionPoint center(cx, cy);
|
||||
mbgl::ScreenCoordinate center(cx, cy);
|
||||
nativeMapView->getMap().setScale(scale, center, mbgl::Milliseconds(duration));
|
||||
}
|
||||
|
||||
@@ -873,8 +873,8 @@ void JNICALL nativeRotateBy(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jd
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRotateBy");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
mbgl::PrecisionPoint first(sx, sy);
|
||||
mbgl::PrecisionPoint second(ex, ey);
|
||||
mbgl::ScreenCoordinate first(sx, sy);
|
||||
mbgl::ScreenCoordinate second(ex, ey);
|
||||
nativeMapView->getMap().rotateBy(first, second, mbgl::Milliseconds(duration));
|
||||
}
|
||||
|
||||
@@ -892,7 +892,7 @@ void JNICALL nativeSetBearing(JNIEnv *env, jobject obj, jlong nativeMapViewPtr,
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetBearing");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
mbgl::PrecisionPoint center(cx, cy);
|
||||
mbgl::ScreenCoordinate center(cx, cy);
|
||||
nativeMapView->getMap().setBearing(degrees, center);
|
||||
}
|
||||
|
||||
@@ -1559,7 +1559,7 @@ jobject JNICALL nativeLatLngForPixel(JNIEnv *env, jobject obj, jlong nativeMapVi
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mbgl::LatLng latLng = nativeMapView->getMap().latLngForPixel(mbgl::PrecisionPoint(x, y));
|
||||
mbgl::LatLng latLng = nativeMapView->getMap().latLngForPixel(mbgl::ScreenCoordinate(x, y));
|
||||
|
||||
jobject ret = env->NewObject(latLngClass, latLngConstructorId, latLng.latitude, latLng.longitude);
|
||||
if (ret == nullptr) {
|
||||
|
||||
@@ -380,8 +380,8 @@ void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) {
|
||||
double dy = y - view->lastY;
|
||||
if (dx || dy) {
|
||||
view->map->setLatLng(
|
||||
view->map->latLngForPixel(mbgl::PrecisionPoint(x - dx, y - dy)),
|
||||
mbgl::PrecisionPoint(x, y));
|
||||
view->map->latLngForPixel(mbgl::ScreenCoordinate(x - dx, y - dy)),
|
||||
mbgl::ScreenCoordinate(x, y));
|
||||
}
|
||||
} else if (view->rotating) {
|
||||
view->map->rotateBy({ view->lastX, view->lastY }, { x, y });
|
||||
|
||||
@@ -1333,7 +1333,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
gesturePoint = self.userLocationAnnotationViewCenter;
|
||||
}
|
||||
|
||||
mbgl::PrecisionPoint center(gesturePoint.x, gesturePoint.y);
|
||||
mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y);
|
||||
_mbglMap->scaleBy(2, center, MGLDurationInSeconds(MGLAnimationDuration));
|
||||
|
||||
__weak MGLMapView *weakSelf = self;
|
||||
@@ -1365,7 +1365,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
gesturePoint = self.userLocationAnnotationViewCenter;
|
||||
}
|
||||
|
||||
mbgl::PrecisionPoint center(gesturePoint.x, gesturePoint.y);
|
||||
mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y);
|
||||
_mbglMap->scaleBy(0.5, center, MGLDurationInSeconds(MGLAnimationDuration));
|
||||
|
||||
__weak MGLMapView *weakSelf = self;
|
||||
@@ -2166,7 +2166,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
- (mbgl::LatLng)convertPoint:(CGPoint)point toLatLngFromView:(nullable UIView *)view
|
||||
{
|
||||
CGPoint convertedPoint = [self convertPoint:point fromView:view];
|
||||
return _mbglMap->latLngForPixel(mbgl::PrecisionPoint(convertedPoint.x, convertedPoint.y));
|
||||
return _mbglMap->latLngForPixel(mbgl::ScreenCoordinate(convertedPoint.x, convertedPoint.y));
|
||||
}
|
||||
|
||||
- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(nullable UIView *)view
|
||||
|
||||
@@ -899,7 +899,7 @@ public:
|
||||
- (void)scaleBy:(double)scaleFactor atPoint:(NSPoint)point animated:(BOOL)animated {
|
||||
[self willChangeValueForKey:@"centerCoordinate"];
|
||||
[self willChangeValueForKey:@"zoomLevel"];
|
||||
mbgl::PrecisionPoint center(point.x, self.bounds.size.height - point.y);
|
||||
mbgl::ScreenCoordinate center(point.x, self.bounds.size.height - point.y);
|
||||
_mbglMap->scaleBy(scaleFactor, center, MGLDurationInSeconds(animated ? MGLAnimationDuration : 0));
|
||||
[self didChangeValueForKey:@"zoomLevel"];
|
||||
[self didChangeValueForKey:@"centerCoordinate"];
|
||||
@@ -1214,7 +1214,7 @@ public:
|
||||
_directionAtBeginningOfGesture = self.direction;
|
||||
_pitchAtBeginningOfGesture = _mbglMap->getPitch();
|
||||
} else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) {
|
||||
mbgl::PrecisionPoint center(startPoint.x, self.bounds.size.height - startPoint.y);
|
||||
mbgl::ScreenCoordinate center(startPoint.x, self.bounds.size.height - startPoint.y);
|
||||
if (self.rotateEnabled) {
|
||||
CLLocationDirection newDirection = _directionAtBeginningOfGesture - delta.x / 10;
|
||||
[self willChangeValueForKey:@"direction"];
|
||||
@@ -1258,7 +1258,7 @@ public:
|
||||
_scaleAtBeginningOfGesture = _mbglMap->getScale();
|
||||
} else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) {
|
||||
NSPoint zoomInPoint = [gestureRecognizer locationInView:self];
|
||||
mbgl::PrecisionPoint center(zoomInPoint.x, self.bounds.size.height - zoomInPoint.y);
|
||||
mbgl::ScreenCoordinate center(zoomInPoint.x, self.bounds.size.height - zoomInPoint.y);
|
||||
if (gestureRecognizer.magnification > -1) {
|
||||
[self willChangeValueForKey:@"zoomLevel"];
|
||||
[self willChangeValueForKey:@"centerCoordinate"];
|
||||
@@ -1339,7 +1339,7 @@ public:
|
||||
_directionAtBeginningOfGesture = self.direction;
|
||||
} else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) {
|
||||
NSPoint rotationPoint = [gestureRecognizer locationInView:self];
|
||||
mbgl::PrecisionPoint center(rotationPoint.x, self.bounds.size.height - rotationPoint.y);
|
||||
mbgl::ScreenCoordinate center(rotationPoint.x, self.bounds.size.height - rotationPoint.y);
|
||||
_mbglMap->setBearing(_directionAtBeginningOfGesture + gestureRecognizer.rotationInDegrees, center);
|
||||
} else if (gestureRecognizer.state == NSGestureRecognizerStateEnded
|
||||
|| gestureRecognizer.state == NSGestureRecognizerStateCancelled) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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&);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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:
|
||||
// \---+
|
||||
|
||||
@@ -123,19 +123,19 @@ TEST(Transform, PerspectiveProjection) {
|
||||
ASSERT_NEAR(-77, loc.longitude, 0.0001);
|
||||
ASSERT_NEAR(38, loc.latitude, 0.0001);
|
||||
|
||||
loc = transform.getState().pointToLatLng({ 0, 1000 });
|
||||
loc = transform.getState().screenCoordinateToLatLng({ 0, 1000 });
|
||||
ASSERT_NEAR(-77.59198961199148, loc.longitude, 0.0002);
|
||||
ASSERT_NEAR(38.74661326302018, loc.latitude, 0.0001);
|
||||
|
||||
loc = transform.getState().pointToLatLng({ 1000, 0 });
|
||||
loc = transform.getState().screenCoordinateToLatLng({ 1000, 0 });
|
||||
ASSERT_NEAR(-76.75823239205641, loc.longitude, 0.0001);
|
||||
ASSERT_NEAR(37.692872969426375, loc.latitude, 0.0001);
|
||||
|
||||
PrecisionPoint point = transform.getState().latLngToPoint({38.74661326302018, -77.59198961199148});
|
||||
ScreenCoordinate point = transform.getState().latLngToScreenCoordinate({38.74661326302018, -77.59198961199148});
|
||||
ASSERT_NEAR(point.x, 0, 0.01);
|
||||
ASSERT_NEAR(point.y, 1000, 0.01);
|
||||
|
||||
point = transform.getState().latLngToPoint({37.692872969426375, -76.75823239205641});
|
||||
point = transform.getState().latLngToScreenCoordinate({37.692872969426375, -76.75823239205641});
|
||||
ASSERT_NEAR(point.x, 1000, 0.02);
|
||||
ASSERT_NEAR(point.y, 0, 0.02);
|
||||
}
|
||||
@@ -193,8 +193,8 @@ TEST(Transform, Anchor) {
|
||||
ASSERT_DOUBLE_EQ(10, transform.getZoom());
|
||||
ASSERT_DOUBLE_EQ(0, transform.getAngle());
|
||||
|
||||
const PrecisionPoint anchorPoint = {0, 0};
|
||||
const LatLng anchorLatLng = transform.getState().pointToLatLng(anchorPoint);
|
||||
const ScreenCoordinate anchorPoint = {0, 0};
|
||||
const LatLng anchorLatLng = transform.getState().screenCoordinateToLatLng(anchorPoint);
|
||||
transform.setAngle(M_PI_4, anchorPoint);
|
||||
|
||||
ASSERT_NEAR(M_PI_4, transform.getAngle(), 0.000001);
|
||||
@@ -216,7 +216,7 @@ TEST(Transform, Padding) {
|
||||
ASSERT_DOUBLE_EQ(-100, trueCenter.longitude);
|
||||
ASSERT_DOUBLE_EQ(10, transform.getZoom());
|
||||
|
||||
const LatLng manualShiftedCenter = transform.getState().pointToLatLng({
|
||||
const LatLng manualShiftedCenter = transform.getState().screenCoordinateToLatLng({
|
||||
1000.0 / 2.0,
|
||||
1000.0 / 4.0,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user