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

Mercator projection that tries to render the resulting map in the same physical size on all devices. More...

#include <Projection.h>

+ Inheritance diagram for osmscout::MercatorProjection:

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...
 
 MercatorProjection ()
 
bool Move (double horizPixel, double vertPixel)
 
bool MoveDown (double pixel)
 
bool MoveLeft (double pixel)
 
bool MoveRight (double pixel)
 
bool MoveUp (double pixel)
 
bool PixelToGeo (double x, double y, double &lon, double &lat) const
 Converts a pixel coordinate to a geo coordinate. More...
 
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)
 Setup projection parameters. More...
 
void SetLinearInterpolationUsage (bool useLinearInterpolation)
 Switch to enable/disable linear interpolation of latitude to pixel computation. More...
 
- 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 ()
 

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
 

Protected Attributes

double angleCos
 
double angleNegCos
 
double angleNegSin
 
double angleSin
 
double latOffset
 Absolute and untransformed screen position of lat coordinate. More...
 
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 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

osmscout::MercatorProjection::MercatorProjection ( )

Member Function Documentation

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

Implements osmscout::Projection.

bool osmscout::MercatorProjection::GeoToPixel ( const GeoCoord &  coord,
double &  x,
double &  y 
) const
virtual
void osmscout::MercatorProjection::GeoToPixel ( const BatchTransformer transformData) const
protectedvirtual

Implements osmscout::Projection.

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

Implements osmscout::Projection.

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

Return true if given coordinate is valid for this projection.

Implements osmscout::Projection.

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

bool osmscout::MercatorProjection::MoveDown ( double  pixel)
inline
bool osmscout::MercatorProjection::MoveLeft ( double  pixel)
inline
bool osmscout::MercatorProjection::MoveRight ( double  pixel)
inline
bool osmscout::MercatorProjection::MoveUp ( double  pixel)
inline
bool osmscout::MercatorProjection::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::Projection::angle, angleCos, angleSin, osmscout::gradtorad, osmscout::Projection::height, IsValidFor(), latOffset, scale, scaleGradtorad, valid, and osmscout::Projection::width.

Referenced by MapWidget::hoverMoveEvent(), Move(), and Set().

bool osmscout::MercatorProjection::Set ( const GeoCoord &  coord,
double  angle,
const Magnification magnification,
size_t  width,
size_t  height 
)
inline
bool osmscout::MercatorProjection::Set ( const GeoCoord &  coord,
const Magnification magnification,
double  dpi,
size_t  width,
size_t  height 
)
inline
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 unchnaged in such case.

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, atanh(), osmscout::Projection::dpi, osmscout::earthExtentMeter, osmscout::gradtorad, osmscout::Projection::height, IsValidFor(), osmscout::Projection::lat, osmscout::Projection::latMax, osmscout::Projection::latMin, latOffset, osmscout::Projection::lon, osmscout::Projection::lonMax, osmscout::Projection::lonMin, M_PI, osmscout::Projection::magnification, MaxLat, MaxLon, osmscout::Projection::meterInMM, osmscout::Projection::meterInPixel, MinLat, MinLon, osmscout::Projection::pixelSize, PixelToGeo(), scale, scaledLatDeriv, scaleGradtorad, osmscout::tileDPI, osmscout::tileWidthZoom0Aquator, valid, and osmscout::Projection::width.

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.

Referenced by PlaneMapRenderer::DrawMap(), TiledMapRenderer::onLoadJobFinished(), and LookupModule::requestObjectsOnView().

Member Data Documentation

double osmscout::MercatorProjection::angleCos
protected

Referenced by PixelToGeo(), and Set().

double osmscout::MercatorProjection::angleNegCos
protected

Referenced by GeoToPixel(), and Set().

double osmscout::MercatorProjection::angleNegSin
protected

Referenced by GeoToPixel(), and Set().

double osmscout::MercatorProjection::angleSin
protected

Referenced by PixelToGeo(), and Set().

double osmscout::MercatorProjection::latOffset
protected

Absolute and untransformed screen position of lat coordinate.

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

const double osmscout::MercatorProjection::MaxLat = +85.0511
static

Referenced by Set().

const double osmscout::MercatorProjection::MaxLon = +180.0
static

Referenced by Set().

const double osmscout::MercatorProjection::MinLat = -85.0511
static

Referenced by Set().

const double osmscout::MercatorProjection::MinLon = -180.0
static

Referenced by Set().

double osmscout::MercatorProjection::scale
protected

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

double osmscout::MercatorProjection::scaledLatDeriv
protected

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

Referenced by GeoToPixel(), and Set().

double osmscout::MercatorProjection::scaleGradtorad
protected

Precalculated scale*Gradtorad.

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

bool osmscout::MercatorProjection::useLinearInterpolation
protected

switch to enable linear interpolation of latitude to pixel computation

Referenced by GeoToPixel().

bool osmscout::MercatorProjection::valid
protected

projection is valid

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


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