libosmscout  1.1.1
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
osmscout::MercatorProjection Class Reference

#include <libosmscout/include/osmscout/util/Projection.h>

Inheritance diagram for osmscout::MercatorProjection:
Inheritance graph
[legend]
Collaboration diagram for osmscout::MercatorProjection:
Collaboration graph
[legend]

Public Member Functions

 MercatorProjection ()
 
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, double &lon, double &lat) const override
 
bool PixelToGeo (double x, double y, GeoCoord &coord) const
 
bool GeoToPixel (const GeoCoord &coord, double &x, double &y) 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 ()
 
virtual ~Projection ()=default
 
GeoCoord GetCenter () const
 
double GetLon () const
 
double GetLat () const
 
double GetAngle () const
 
size_t GetWidth () const
 
size_t GetHeight () const
 
Magnification GetMagnification () const
 
double GetDPI () const
 
bool GeoIsIn (double lon, double lat) const
 
bool GeoIsIn (double lonMin, double latMin, double lonMax, double latMax) const
 
GeoBox GetDimensions () const
 
void GetDimensions (GeoBox &boundingBox) const
 
double GetPixelSize () const
 
double GetMeterInPixel () const
 
double GetMeterInMM () const
 
double ConvertWidthToPixel (double width) const
 
double ConvertPixelToWidth (double pixel) 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
 projection is valid More...
 
double latOffset
 Absolute and untransformed screen position of lat coordinate. More...
 
double angleSin
 
double angleCos
 
double angleNegSin
 
double angleNegCos
 
double scale
 
double scaleGradtorad
 Precalculated scale*Gradtorad. More...
 
double scaledLatDeriv
 precalculated derivation of "latToYPixel" function in projection center scaled by gradtorad * scale More...
 
bool useLinearInterpolation
 switch to enable linear interpolation of latitude to pixel computation More...
 
- Protected Attributes inherited from osmscout::Projection
double lon
 Longitude coordinate of the center of the image. More...
 
double lat
 Latitude coordinate of the center of the image. More...
 
double angle
 Display rotation angle in radians, canvas clockwise. More...
 
Magnification magnification
 Current magnification. More...
 
double dpi
 Screen DPI. More...
 
size_t width
 Width of image. More...
 
size_t height
 Height of image. More...
 
double lonMin
 Longitude of the upper left corner of the image. More...
 
double latMin
 Latitude of the upper left corner of the image. More...
 
double lonMax
 Longitude of the lower right corner of the image. More...
 
double latMax
 Latitude of the lower right corner of the image. More...
 
double pixelSize
 Size of a pixel in meter. More...
 
double meterInPixel
 Number of on screen pixel for one meter on the ground. More...
 
double meterInMM
 Number of on screen millimeters for one meter on the ground. More...
 

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()

osmscout::MercatorProjection::MercatorProjection ( )

Member Function Documentation

◆ CanBatch()

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

Implements osmscout::Projection.

◆ GeoToPixel() [1/2]

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

◆ GeoToPixel() [2/2]

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

Implements osmscout::Projection.

◆ IsLinearInterpolationEnabled()

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

◆ 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

◆ PixelToGeo() [1/2]

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

◆ PixelToGeo() [2/2]

bool osmscout::MercatorProjection::PixelToGeo ( double  x,
double  y,
GeoCoord &  coord 
) const
inline

◆ Set() [1/4]

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

◆ Set() [2/4]

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

◆ Set() [3/4]

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

◆ Set() [4/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

◆ 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
protected

◆ angleNegCos

double osmscout::MercatorProjection::angleNegCos
protected

◆ angleNegSin

double osmscout::MercatorProjection::angleNegSin
protected

◆ angleSin

double osmscout::MercatorProjection::angleSin
protected

◆ latOffset

double osmscout::MercatorProjection::latOffset
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
protected

◆ scaledLatDeriv

double osmscout::MercatorProjection::scaledLatDeriv
protected

precalculated derivation of "latToYPixel" function in projection center scaled by gradtorad * scale

◆ scaleGradtorad

double osmscout::MercatorProjection::scaleGradtorad
protected

Precalculated scale*Gradtorad.

◆ useLinearInterpolation

bool osmscout::MercatorProjection::useLinearInterpolation
protected

switch to enable linear interpolation of latitude to pixel computation

◆ valid

bool osmscout::MercatorProjection::valid
protected

projection is valid


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