libosmscout 1.1.1
Loading...
Searching...
No Matches
osmscout::MercatorProjection Class Reference

#include <libosmscout/include/osmscout/projection/MercatorProjection.h>

Inheritance diagram for osmscout::MercatorProjection:
Collaboration diagram for osmscout::MercatorProjection:

Public Member Functions

 MercatorProjection ()=default
 MercatorProjection (const MercatorProjection &)=default
 MercatorProjection (MercatorProjection &&)=default
MercatorProjectionoperator= (const MercatorProjection &)=default
MercatorProjectionoperator= (MercatorProjection &&)=default
 ~MercatorProjection () override=default
bool CanBatch () const override
bool IsValid () const override
bool IsValidFor (const GeoCoord &coord) const override
bool Set (const GeoCoord &coord, const Magnification &magnification, size_t width, size_t height)
bool Set (const GeoCoord &coord, double angle, const Magnification &magnification, size_t width, size_t height)
bool Set (const GeoCoord &coord, const Magnification &magnification, double dpi, size_t width, size_t height)
bool Set (const GeoCoord &coord, double angle, const Magnification &magnification, double dpi, size_t width, size_t height)
bool PixelToGeo (double x, double y, GeoCoord &coord) const override
bool GeoToPixel (const GeoCoord &coord, Vertex2D &pixel) const override
bool Move (double horizPixel, double vertPixel)
bool MoveUp (double pixel)
bool MoveDown (double pixel)
bool MoveLeft (double pixel)
bool MoveRight (double pixel)
bool IsLinearInterpolationEnabled () const
void SetLinearInterpolationUsage (bool useLinearInterpolation)
Public Member Functions inherited from osmscout::Projection
 Projection ()=default
 Projection (const Projection &)=default
 Projection (Projection &&)=default
Projectionoperator= (const Projection &)=default
Projectionoperator= (Projection &&)=default
virtual ~Projection ()=default
GeoCoord GetCenter () const
double GetAngle () const
size_t GetWidth () const
size_t GetHeight () const
ScreenBox GetScreenBox () const
Magnification GetMagnification () const
double GetDPI () const
GeoBox GetDimensions () const
double GetPixelSize () const
double GetMeterInPixel () const
double GetMeterInMM () const
double ConvertWidthToPixel (double width) const
double ConvertPixelToWidth (double pixel) const
bool BoundingBoxToPixel (const GeoBox &boundingBox, ScreenBox &screenBox) const

Static Public Attributes

static const double MaxLat
static const double MinLat
static const double MaxLon
static const double MinLon

Protected Member Functions

void GeoToPixel (const BatchTransformer &transformData) const override

Protected Attributes

bool valid =false
 projection is valid
double latOffset =0.0
 Absolute and untransformed screen position of lat coordinate.
double angleSin =0.0
double angleCos =0.0
double angleNegSin =0.0
double angleNegCos =0.0
double scale =1.0
double scaleGradtorad =0.0
 Precalculated scale*Gradtorad.
double scaledLatDeriv =0.0
 center scaled by gradtorad * scale
bool useLinearInterpolation =false
 switch to enable linear interpolation of latitude to pixel computation
Protected Attributes inherited from osmscout::Projection
GeoCoord center
 Coordinate of the center of the displayed area.
double angle =0.0
 Display rotation angle in radians, canvas clockwise.
Magnification magnification
 Current magnification.
double dpi =0.0
 Screen DPI.
size_t width =0
 Width of image.
size_t height =0
 Height of image.
GeoBox boundingBox
 Bounding box of the current projection on the ground.
double pixelSize =0.0
 Size of a pixel in meter.
double meterInPixel =0.0
 Number of on screen pixel for one meter on the ground.
double meterInMM =0.0
 Number of on screen millimeters for one meter on the ground.

Detailed Description

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.

Constructor & Destructor Documentation

◆ MercatorProjection() [1/3]

osmscout::MercatorProjection::MercatorProjection ( )
default

◆ MercatorProjection() [2/3]

osmscout::MercatorProjection::MercatorProjection ( const MercatorProjection & )
default

◆ MercatorProjection() [3/3]

osmscout::MercatorProjection::MercatorProjection ( MercatorProjection && )
default

◆ ~MercatorProjection()

osmscout::MercatorProjection::~MercatorProjection ( )
overridedefault

Member Function Documentation

◆ CanBatch()

bool osmscout::MercatorProjection::CanBatch ( ) const
inlineoverridevirtual

Implements osmscout::Projection.

◆ GeoToPixel() [1/2]

void osmscout::MercatorProjection::GeoToPixel ( const BatchTransformer & transformData) const
overrideprotectedvirtual

Implements osmscout::Projection.

◆ GeoToPixel() [2/2]

bool osmscout::MercatorProjection::GeoToPixel ( const GeoCoord & coord,
Vertex2D & pixel ) const
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.

◆ IsLinearInterpolationEnabled()

bool osmscout::MercatorProjection::IsLinearInterpolationEnabled ( ) const
inlinenodiscard

◆ IsValid()

bool osmscout::MercatorProjection::IsValid ( ) const
inlineoverridevirtual

Implements osmscout::Projection.

◆ IsValidFor()

bool osmscout::MercatorProjection::IsValidFor ( const GeoCoord & coord) const
inlineoverridevirtual

Return true if given coordinate is valid for this projection

Implements osmscout::Projection.

◆ Move()

bool osmscout::MercatorProjection::Move ( double horizPixel,
double vertPixel )

◆ MoveDown()

bool osmscout::MercatorProjection::MoveDown ( double pixel)
inline

◆ MoveLeft()

bool osmscout::MercatorProjection::MoveLeft ( double pixel)
inline

◆ MoveRight()

bool osmscout::MercatorProjection::MoveRight ( double pixel)
inline

◆ MoveUp()

bool osmscout::MercatorProjection::MoveUp ( double pixel)
inline

◆ operator=() [1/2]

MercatorProjection & osmscout::MercatorProjection::operator= ( const MercatorProjection & )
default

◆ operator=() [2/2]

MercatorProjection & osmscout::MercatorProjection::operator= ( MercatorProjection && )
default

◆ PixelToGeo()

bool osmscout::MercatorProjection::PixelToGeo ( double x,
double y,
GeoCoord & coord ) const
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.

◆ Set() [1/4]

bool osmscout::MercatorProjection::Set ( const GeoCoord & coord,
const Magnification & magnification,
double dpi,
size_t width,
size_t height )
inline

◆ Set() [2/4]

bool osmscout::MercatorProjection::Set ( const GeoCoord & coord,
const Magnification & magnification,
size_t width,
size_t height )
inline

◆ Set() [3/4]

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

◆ Set() [4/4]

bool osmscout::MercatorProjection::Set ( const GeoCoord & coord,
double angle,
const Magnification & magnification,
size_t width,
size_t height )
inline

◆ SetLinearInterpolationUsage()

void osmscout::MercatorProjection::SetLinearInterpolationUsage ( bool useLinearInterpolation)
inline

Switch to enable/disable linear interpolation of latitude to pixel computation. It speedup GeoToPixel calculation with fractional error on small render area.

Member Data Documentation

◆ angleCos

double osmscout::MercatorProjection::angleCos =0.0
protected

◆ angleNegCos

double osmscout::MercatorProjection::angleNegCos =0.0
protected

◆ angleNegSin

double osmscout::MercatorProjection::angleNegSin =0.0
protected

◆ angleSin

double osmscout::MercatorProjection::angleSin =0.0
protected

◆ latOffset

double osmscout::MercatorProjection::latOffset =0.0
protected

Absolute and untransformed screen position of lat coordinate.

◆ MaxLat

const double osmscout::MercatorProjection::MaxLat
static

◆ MaxLon

const double osmscout::MercatorProjection::MaxLon
static

◆ MinLat

const double osmscout::MercatorProjection::MinLat
static

◆ MinLon

const double osmscout::MercatorProjection::MinLon
static

◆ scale

double osmscout::MercatorProjection::scale =1.0
protected

◆ scaledLatDeriv

double osmscout::MercatorProjection::scaledLatDeriv =0.0
protected

center scaled by gradtorad * scale

precalculated derivation of "latToYPixel" function in projection

◆ scaleGradtorad

double osmscout::MercatorProjection::scaleGradtorad =0.0
protected

Precalculated scale*Gradtorad.

◆ useLinearInterpolation

bool osmscout::MercatorProjection::useLinearInterpolation =false
protected

switch to enable linear interpolation of latitude to pixel computation

◆ valid

bool osmscout::MercatorProjection::valid =false
protected

projection is valid


The documentation for this class was generated from the following file: