libosmscout
0.1
|
Mercator projection that tries to render the resulting map in the same physical size on all devices. More...
#include <MercatorProjection.h>
Public Member Functions | |
bool | CanBatch () const override |
bool | GeoToPixel (const GeoCoord &coord, Vertex2D &pixel) const override |
Converts a geo coordinate to a pixel coordinate. More... | |
bool | IsLinearInterpolationEnabled () const |
bool | IsValid () const override |
bool | IsValidFor (const GeoCoord &coord) const override |
Return true if given coordinate is valid for this projection. More... | |
MercatorProjection ()=default | |
MercatorProjection (const MercatorProjection &)=default | |
MercatorProjection (MercatorProjection &&)=default | |
bool | Move (double horizPixel, double vertPixel) |
bool | MoveDown (double pixel) |
bool | MoveLeft (double pixel) |
bool | MoveRight (double pixel) |
bool | MoveUp (double pixel) |
MercatorProjection & | operator= (const MercatorProjection &)=default |
MercatorProjection & | operator= (MercatorProjection &&)=default |
bool | PixelToGeo (double x, double y, GeoCoord &coord) const override |
Converts a pixel coordinate to a geo coordinate. More... | |
bool | Set (const GeoCoord &coord, const Magnification &magnification, double dpi, size_t width, size_t height) |
bool | Set (const GeoCoord &coord, const Magnification &magnification, size_t width, size_t height) |
bool | Set (const GeoCoord &coord, double angle, const Magnification &magnification, double dpi, size_t width, size_t height) |
Setup projection parameters. More... | |
bool | Set (const GeoCoord &coord, double angle, const Magnification &magnification, size_t width, size_t height) |
void | SetLinearInterpolationUsage (bool useLinearInterpolation) |
Switch to enable/disable linear interpolation of latitude to pixel computation. More... | |
~MercatorProjection () override=default | |
![]() | |
bool | BoundingBoxToPixel (const GeoBox &boundingBox, ScreenBox &screenBox) const |
Converts a valid GeoBox to its on screen pixel coordinates. More... | |
double | ConvertPixelToWidth (double pixel) const |
Convert a width in pixel into the equivalent mm size based on the given DPI. More... | |
double | ConvertWidthToPixel (double width) const |
Convert a width in mm into the equivalent pixel size based on the given DPI. More... | |
double | GetAngle () const |
Returns the angle in radians ([0..2*PI[) of the display in relation to the north. More... | |
GeoCoord | GetCenter () const |
GeoBox | GetDimensions () const |
double | GetDPI () const |
Return the DPI as part of the projection. More... | |
size_t | GetHeight () const |
Returns the height of the screen. More... | |
Magnification | GetMagnification () const |
Return the magnification as part of the projection. More... | |
double | GetMeterInMM () const |
Returns the number of on screen millimeters for one meter on the ground. More... | |
double | GetMeterInPixel () const |
Returns the number of on screen pixel for one meter on the ground. More... | |
double | GetPixelSize () const |
Returns the size of a pixel in meter. More... | |
ScreenBox | GetScreenBox () const |
Return a ScreenBox instance for the screen. More... | |
size_t | GetWidth () const |
Returns the width of the screen. More... | |
Projection & | operator= (const Projection &)=default |
Projection & | operator= (Projection &&)=default |
Projection ()=default | |
Projection (const Projection &)=default | |
Projection (Projection &&)=default | |
virtual | ~Projection ()=default |
Static Public Attributes | |
static const double | MaxLat = +85.0511 |
static const double | MaxLon = +180.0 |
static const double | MinLat = -85.0511 |
static const double | MinLon = -180.0 |
Protected Member Functions | |
void | GeoToPixel (const BatchTransformer &transformData) const override |
Protected Attributes | |
double | angleCos =0.0 |
double | angleNegCos =0.0 |
double | angleNegSin =0.0 |
double | angleSin =0.0 |
double | latOffset =0.0 |
Absolute and untransformed screen position of lat coordinate. More... | |
double | scale =1.0 |
double | scaledLatDeriv =0.0 |
precalculated derivation of "latToYPixel" function in projection More... | |
double | scaleGradtorad =0.0 |
Precalculated scale*Gradtorad. More... | |
bool | useLinearInterpolation =false |
switch to enable linear interpolation of latitude to pixel computation More... | |
bool | valid =false |
projection is valid More... | |
![]() | |
double | angle =0.0 |
Display rotation angle in radians, canvas clockwise. More... | |
GeoBox | boundingBox |
Bounding box of the current projection on the ground. More... | |
GeoCoord | center |
Coordinate of the center of the displayed area. More... | |
double | dpi =0.0 |
Screen DPI. More... | |
size_t | height =0 |
Height of image. More... | |
Magnification | magnification |
Current magnification. More... | |
double | meterInMM =0.0 |
Number of on screen millimeters for one meter on the ground. More... | |
double | meterInPixel =0.0 |
Number of on screen pixel for one meter on the ground. More... | |
double | pixelSize =0.0 |
Size of a pixel in meter. More... | |
size_t | width =0 |
Width of image. More... | |
Mercator projection that tries to render the resulting map in the same physical size on all devices.
If the physical DPI of the device is correctly given, objects on any device has the same size. Bigger devices will show "more" map thus.
Scale is calculated based on the assumption that the original OpenStreetMap tiles were designed for 96 DPI displays.
|
default |
|
default |
|
default |
|
overridedefault |
|
inlineoverridevirtual |
Implements osmscout::Projection.
|
overrideprotectedvirtual |
Implements osmscout::Projection.
|
overridevirtual |
Converts a geo coordinate to a pixel coordinate.
Return true on success, false if given coordinate is not valid for this projection.
Implements osmscout::Projection.
References osmscout::Projection::angle, angleNegCos, angleNegSin, osmscout::Projection::center, osmscout::GeoCoord::GetLat(), osmscout::GeoCoord::GetLon(), osmscout::gradtorad, osmscout::Projection::height, IsValidFor(), latOffset, MaxLat, MinLat, scale, scaledLatDeriv, scaleGradtorad, useLinearInterpolation, valid, and osmscout::Projection::width.
Referenced by osmscout::LockHandler::currentPosition(), Move(), osmscout::IconAnimation::paint(), osmscout::MapWidget::paint(), osmscout::PlaneMapRenderer::RenderMap(), osmscout::TiledRenderingHelper::RenderTiles(), and osmscout::MapWidget::screenPosition().
|
inline |
|
inlineoverridevirtual |
Implements osmscout::Projection.
Referenced by osmscout::MapWidget::paint().
|
inlineoverridevirtual |
Return true if given coordinate is valid for this projection.
Implements osmscout::Projection.
References osmscout::GeoCoord::GetLat(), and osmscout::GeoCoord::GetLon().
Referenced by GeoToPixel(), PixelToGeo(), and Set().
bool osmscout::MercatorProjection::Move | ( | double | horizPixel, |
double | vertPixel | ||
) |
References osmscout::Projection::angle, osmscout::Projection::center, osmscout::Projection::dpi, GeoToPixel(), osmscout::GeoCoord::GetLat(), osmscout::GeoCoord::GetLon(), osmscout::Vertex2D::GetX(), osmscout::Vertex2D::GetY(), osmscout::Projection::height, osmscout::Projection::magnification, PixelToGeo(), Set(), and osmscout::Projection::width.
Referenced by osmscout::MoveHandler::moveNow().
|
inline |
|
inline |
|
inline |
|
inline |
|
default |
|
default |
|
overridevirtual |
Converts a pixel coordinate to a geo coordinate.
Return true on success, false if returned coordinate is not valid for this projection.
Implements osmscout::Projection.
References osmscout::Projection::angle, angleCos, angleSin, osmscout::Projection::center, osmscout::GeoCoord::GetLon(), osmscout::gradtorad, osmscout::Projection::height, IsValidFor(), latOffset, scale, scaleGradtorad, osmscout::GeoCoord::Set(), valid, and osmscout::Projection::width.
Referenced by osmscout::MapWidget::hoverMoveEvent(), Move(), osmscout::PlaneMapRenderer::RenderMap(), osmscout::TiledRenderingHelper::RenderTiles(), Set(), and osmscout::VehicleFollowHandler::vehiclePosition().
|
inline |
|
inline |
Referenced by osmscout::LockHandler::currentPosition(), osmscout::PlaneMapRenderer::DrawMap(), osmscout::MapWidget::getProjection(), osmscout::MapPainterOpenGL::MapPainterOpenGL(), Move(), osmscout::MoveHandler::moveNow(), osmscout::TiledMapRenderer::offlineTileRequest(), osmscout::TiledMapRenderer::onLoadJobFinished(), osmscout::PlaneMapRenderer::RenderMap(), osmscout::TiledRenderingHelper::RenderTiles(), osmscout::LookupModule::requestObjectsOnView(), osmscout::MapPainterOpenGL::SetCenter(), osmscout::MapPainterOpenGL::SetMagnification(), osmscout::PlaneMapRenderer::TriggerMapRendering(), and osmscout::VehicleFollowHandler::vehiclePosition().
bool osmscout::MercatorProjection::Set | ( | const GeoCoord & | coord, |
double | angle, | ||
const Magnification & | magnification, | ||
double | dpi, | ||
size_t | width, | ||
size_t | height | ||
) |
Setup projection parameters.
Return true on success, false if arguments are not valid for Mercator projection, projection parameters are unchanged in such case.
Angle is in radians ([0..2*PI[)
Note that coord (center) have to be valid coordinate in Mercator projection. But it is possible setup dimensions (width and height) that projection will cover area bigger than the one valid for Mercator projection. Bounding box is adjusted then to be valid for projection.
In code:
projection.GetDimensions(bbox); projection.GeoToPixel(bbox.GetMinCoord(),x,y)
may be x >= 0
References osmscout::Projection::angle, angleCos, angleNegCos, angleNegSin, angleSin, osmscout::Projection::boundingBox, osmscout::Projection::center, osmscout::GeoBox::CropTo(), osmscout::Projection::dpi, osmscout::Earth::extentMeter, osmscout::GeoCoord::GetLat(), osmscout::Magnification::GetMagnification(), osmscout::gradtorad, osmscout::Projection::height, osmscout::GeoBox::Include(), IsValidFor(), latOffset, osmscout::Projection::magnification, MaxLat, MaxLon, osmscout::Projection::meterInMM, osmscout::Projection::meterInPixel, MinLat, MinLon, osmscout::Projection::pixelSize, PixelToGeo(), scale, scaledLatDeriv, scaleGradtorad, osmscout::tileDPI, valid, and osmscout::Projection::width.
|
inline |
|
inline |
Switch to enable/disable linear interpolation of latitude to pixel computation.
It speedup GeoToPixel calculation with fractional error on small render area.
Referenced by osmscout::PlaneMapRenderer::DrawMap(), osmscout::TiledMapRenderer::onLoadJobFinished(), osmscout::LookupModule::requestObjectsOnView(), and osmscout::MapPainterOpenGL::SetMagnification().
|
protected |
Referenced by PixelToGeo(), and Set().
|
protected |
Referenced by GeoToPixel(), and Set().
|
protected |
Referenced by GeoToPixel(), and Set().
|
protected |
Referenced by PixelToGeo(), and Set().
|
protected |
Absolute and untransformed screen position of lat coordinate.
Referenced by GeoToPixel(), PixelToGeo(), and Set().
|
static |
Referenced by GeoToPixel(), and Set().
|
static |
Referenced by Set().
|
static |
Referenced by GeoToPixel(), and Set().
|
static |
Referenced by Set().
|
protected |
Referenced by GeoToPixel(), PixelToGeo(), and Set().
|
protected |
precalculated derivation of "latToYPixel" function in projection
center scaled by gradtorad * scale
Referenced by GeoToPixel(), and Set().
|
protected |
Precalculated scale*Gradtorad.
Referenced by GeoToPixel(), PixelToGeo(), and Set().
|
protected |
switch to enable linear interpolation of latitude to pixel computation
Referenced by GeoToPixel().
|
protected |
projection is valid
Referenced by GeoToPixel(), PixelToGeo(), and Set().