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

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

#include <Projection.h>

+ Inheritance diagram for osmscout::TileProjection:

Public Member Functions

bool CanBatch () const
 
bool GeoToPixel (const GeoCoord &coord, double &x, double &y) const
 Converts a geo coordinate to a pixel coordinate. More...
 
bool IsLinearInterpolationEnabled ()
 
bool IsValid () const
 
bool IsValidFor (const GeoCoord &coord) const
 Return true if given coordinate is valid for this projection. More...
 
bool PixelToGeo (double x, double y, double &lon, double &lat) const
 Converts a pixel coordinate to a geo coordinate. More...
 
bool Set (const OSMTileId &tile, const Magnification &magnification, size_t width, size_t height)
 
bool Set (const OSMTileId &tile, const Magnification &magnification, double dpi, 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 ()
 
- Public Member Functions inherited from osmscout::Projection
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...
 
bool GeoIsIn (double lon, double lat) const
 Returns true, if the given geo coordinate is in the bounding box. More...
 
bool GeoIsIn (double lonMin, double latMin, double lonMax, double latMax) const
 Returns true, if the given bounding box is completely within the projection bounding box. More...
 
double GetAngle () const
 Returns the angle ([0..2*PI[) of the display in relation to the north. More...
 
GeoCoord GetCenter () const
 
void GetDimensions (GeoBox &boundingBox) const
 Returns the bounding box of the area covered. More...
 
double GetDPI () const
 Return the DPI as part of the projection. More...
 
size_t GetHeight () const
 Returns the height of the screen. More...
 
double GetLat () const
 Returns latitude coordinate of the region center. More...
 
double GetLon () const
 Returns longitude coordinate of the region center. 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...
 
size_t GetWidth () const
 Returns the width of the screen. More...
 
 Projection ()
 
virtual ~Projection ()
 

Protected Member Functions

void GeoToPixel (const BatchTransformer &transformData) const
 
virtual bool SetInternal (double lonMin, double latMin, double lonMax, double latMax, const Magnification &magnification, double dpi, size_t width, size_t height)
 

Protected Attributes

double latOffset
 
double lonOffset
 
double scale
 
double scaledLatDeriv
 precalculated derivation of "latToYPixel" function in projection center scaled by gradtorad * scale More...
 
double scaleGradtorad
 Precalculated scale*Gradtorad. More...
 
bool useLinearInterpolation
 switch to enable linear interpolation of latitude to pixel computation More...
 
bool valid
 projection is valid More...
 
- Protected Attributes inherited from osmscout::Projection
double angle
 Display rotation angle. More...
 
double dpi
 Screen DPI. More...
 
size_t height
 Height of image. More...
 
double lat
 Latitude coordinate of the center of the image. More...
 
double latMax
 Latitude of the lower right corner of the image. More...
 
double latMin
 Latitude of the upper left corner of the image. More...
 
double lon
 Longitude coordinate of the center of the image. More...
 
double lonMax
 Longitude of the lower right corner of the image. More...
 
double lonMin
 Longitude of the upper left corner of the image. More...
 
Magnification magnification
 Current magnification. More...
 
double meterInMM
 Number of on screen millimeters for one meter on the ground. More...
 
double meterInPixel
 Number of on screen pixel for one meter on the ground. More...
 
double pixelSize
 Size of a pixel in meter. More...
 
size_t width
 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

osmscout::TileProjection::TileProjection ( )

Member Function Documentation

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

Implements osmscout::Projection.

bool osmscout::TileProjection::GeoToPixel ( const GeoCoord &  coord,
double &  x,
double &  y 
) const
virtual

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 atanh(), osmscout::gradtorad, osmscout::Projection::height, IsValidFor(), osmscout::Projection::lat, latOffset, lonOffset, scale, scaledLatDeriv, scaleGradtorad, and useLinearInterpolation.

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

Implements osmscout::Projection.

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

Implements osmscout::Projection.

bool osmscout::TileProjection::IsValidFor ( const GeoCoord &  coord) const
inlinevirtual

Return true if given coordinate is valid for this projection.

Implements osmscout::Projection.

Referenced by GeoToPixel(), and PixelToGeo().

bool osmscout::TileProjection::PixelToGeo ( double  x,
double  y,
double &  lon,
double &  lat 
) const
virtual

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(), latOffset, lonOffset, and scale.

bool osmscout::TileProjection::Set ( const OSMTileId &  tile,
const Magnification magnification,
size_t  width,
size_t  height 
)
inline
bool osmscout::TileProjection::Set ( const OSMTileId &  tile,
const Magnification magnification,
double  dpi,
size_t  width,
size_t  height 
)
bool osmscout::TileProjection::Set ( const OSMTileIdBox &  tileBox,
const Magnification magnification,
double  dpi,
size_t  width,
size_t  height 
)
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.

Member Data Documentation

double osmscout::TileProjection::latOffset
protected

Referenced by GeoToPixel(), PixelToGeo(), and SetInternal().

double osmscout::TileProjection::lonOffset
protected

Referenced by GeoToPixel(), PixelToGeo(), and SetInternal().

double osmscout::TileProjection::scale
protected

Referenced by GeoToPixel(), PixelToGeo(), and SetInternal().

double osmscout::TileProjection::scaledLatDeriv
protected

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

Referenced by GeoToPixel(), and SetInternal().

double osmscout::TileProjection::scaleGradtorad
protected

Precalculated scale*Gradtorad.

Referenced by GeoToPixel(), and SetInternal().

bool osmscout::TileProjection::useLinearInterpolation
protected

switch to enable linear interpolation of latitude to pixel computation

Referenced by GeoToPixel().

bool osmscout::TileProjection::valid
protected

projection is valid

Referenced by SetInternal().


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