Implement map projection functionality (#254)
* Implement map projection functionality * Add missing MGL_EXPORT * Remove the automatic copyright header
This commit is contained in:
committed by
GitHub
parent
ea234edf67
commit
6db27f50ad
39
src/mbgl/map/map_projection.cpp
Normal file
39
src/mbgl/map/map_projection.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <mbgl/map/map_projection.hpp>
|
||||
#include <mbgl/map/map_impl.hpp>
|
||||
#include <mbgl/map/transform.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
MapProjection::MapProjection(const Map& map)
|
||||
: transform(std::make_unique<Transform>(map.getTransfromState())) {}
|
||||
|
||||
MapProjection::~MapProjection() = default;
|
||||
|
||||
ScreenCoordinate MapProjection::pixelForLatLng(const LatLng& latLng) const {
|
||||
// The implementation is just a copy from map.cpp
|
||||
LatLng unwrappedLatLng = latLng.wrapped();
|
||||
unwrappedLatLng.unwrapForShortestPath(transform->getLatLng());
|
||||
return transform->latLngToScreenCoordinate(unwrappedLatLng);
|
||||
}
|
||||
|
||||
LatLng MapProjection::latLngForPixel(const ScreenCoordinate& pixel) const {
|
||||
// The implementation is just a copy from map.cpp
|
||||
return transform->screenCoordinateToLatLng(pixel);
|
||||
}
|
||||
|
||||
void MapProjection::setCamera(const CameraOptions& camera) {
|
||||
transform->jumpTo(camera);
|
||||
}
|
||||
|
||||
CameraOptions MapProjection::getCamera() const {
|
||||
return transform->getCameraOptions(nullopt);
|
||||
}
|
||||
|
||||
void MapProjection::setVisibleCoordinates(const std::vector<LatLng>& latLngs,
|
||||
const EdgeInsets& padding) {
|
||||
transform->jumpTo(mbgl::cameraForLatLngs(latLngs, *transform, padding)
|
||||
.withBearing(-transform->getBearing() * util::RAD2DEG)
|
||||
.withPitch(transform->getPitch() * util::RAD2DEG));
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
Reference in New Issue
Block a user