libosmscout  0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules
osmscout::TileProjection Class Reference

Mercator projection as used by the OpenStreetMap tile rendering code. More...

#include <TileProjection.h>

+ Inheritance diagram for osmscout::TileProjection:

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...
 
TileProjectionoperator= (const TileProjection &)=default
 
TileProjectionoperator= (TileProjection &&)=default
 
bool PixelToGeo (double x, double y, GeoCoord &coord) const override
 Converts a pixel coordinate to a geo coordinate. More...
 
bool Set (const OSMTileId &tile, const Magnification &magnification, double dpi, size_t width, size_t height)
 
bool Set (const OSMTileId &tile, const Magnification &magnification, size_t width, size_t height)
 
bool Set (const OSMTileIdBox &tileBox, const Magnification &magnification, double dpi, size_t width, size_t height)
 
void SetLinearInterpolationUsage (bool b)
 Switch to enable/disable linear interpolation of latitude to pixel computation. More...
 
 TileProjection ()=default
 
 TileProjection (const TileProjection &)=default
 
 TileProjection (TileProjection &&)=default
 
 ~TileProjection () override=default
 
- Public Member Functions inherited from osmscout::Projection
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...
 
Projectionoperator= (const Projection &)=default
 
Projectionoperator= (Projection &&)=default
 
 Projection ()=default
 
 Projection (const Projection &)=default
 
 Projection (Projection &&)=default
 
virtual ~Projection ()=default
 

Protected Member Functions

void GeoToPixel (const BatchTransformer &transformData) const override
 
virtual bool SetInternal (const GeoBox &boundingBox, const Magnification &magnification, double dpi, size_t width, size_t height)
 

Additional Inherited Members

- Protected Attributes inherited from osmscout::Projection
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...
 

Detailed Description

Mercator projection as used by the OpenStreetMap tile rendering code.

The TileProjection simplifies the general Mercator projection code to make sure that there are no effects based on rounding errors or similar.

Constructor & Destructor Documentation

◆ TileProjection() [1/3]

osmscout::TileProjection::TileProjection ( )
default

◆ TileProjection() [2/3]

osmscout::TileProjection::TileProjection ( const TileProjection )
default

◆ TileProjection() [3/3]

osmscout::TileProjection::TileProjection ( TileProjection &&  )
default

◆ ~TileProjection()

osmscout::TileProjection::~TileProjection ( )
overridedefault

Member Function Documentation

◆ CanBatch()

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

Implements osmscout::Projection.

◆ GeoToPixel() [1/2]

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

Implements osmscout::Projection.

◆ GeoToPixel() [2/2]

bool osmscout::TileProjection::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.

References osmscout::Projection::center, osmscout::GeoCoord::GetLat(), osmscout::GeoCoord::GetLon(), osmscout::gradtorad, osmscout::Projection::height, and IsValidFor().

◆ IsLinearInterpolationEnabled()

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

◆ IsValid()

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

Implements osmscout::Projection.

◆ IsValidFor()

bool osmscout::TileProjection::IsValidFor ( const GeoCoord coord) const
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(), and PixelToGeo().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ PixelToGeo()

bool osmscout::TileProjection::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.

References osmscout::gradtorad, osmscout::Projection::height, IsValidFor(), and osmscout::GeoCoord::Set().

◆ Set() [1/3]

bool osmscout::TileProjection::Set ( const OSMTileId tile,
const Magnification magnification,
double  dpi,
size_t  width,
size_t  height 
)

◆ Set() [2/3]

bool osmscout::TileProjection::Set ( const OSMTileId tile,
const Magnification magnification,
size_t  width,
size_t  height 
)
inline

◆ Set() [3/3]

bool osmscout::TileProjection::Set ( const OSMTileIdBox tileBox,
const Magnification magnification,
double  dpi,
size_t  width,
size_t  height 
)

◆ SetInternal()

◆ SetLinearInterpolationUsage()

void osmscout::TileProjection::SetLinearInterpolationUsage ( bool  b)
inline

Switch to enable/disable linear interpolation of latitude to pixel computation.

It speedup GeoToPixel calculation with fractional error on small render area.


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