Scene coordinate. More...
#include <scenecoordinate.h>
Public Member Functions | |
SceneCoordinate () | |
Constructs a null coordinate. | |
SceneCoordinate (double x, double y) | |
Constructs a coordinate with given x and y. | |
SceneCoordinate (const GeoCoordinate &coordinate) | |
Constructs a coordinate with values converted from the given GeoCoordinate. | |
qreal | azimuthTo (const SceneCoordinate &to) const |
Returns the azimuth from this coordinate to other coordinate. | |
bool | isNull () const |
Check if coordinate is (0.0, 0.0). | |
void | setX (double x) |
Sets the latitude. | |
void | setY (double y) |
Sets the longitude. | |
QPointF | toPointF () const |
Convert to QPointF. | |
double | x () const |
Returns the x value. | |
double | y () const |
Returns the y value. | |
operator QVariant () const | |
Operator for creating QVariant. | |
SceneCoordinate & | operator*= (double factor) |
Multiplies this coordinate's values by the given factor, and returns a reference to this coordinate. | |
SceneCoordinate & | operator+= (const SceneCoordinate &coordinate) |
Adds the given coordinate to this coordinate and returns a reference to this coordinate. | |
SceneCoordinate & | operator-= (const SceneCoordinate &coordinate) |
Subtracts the given coordinate from this coordinate and returns a reference to this coordinate. | |
const SceneCoordinate | operator+ (const SceneCoordinate &other) const |
Returns a SceneCoordinate object that is the sum of the coordinates. | |
const SceneCoordinate | operator- (const SceneCoordinate &other) const |
Returns a SceneCoordinate object that is formed by subtracting the coordinates. | |
Private Member Functions | |
void | convertFrom (const GeoCoordinate &coordinate) |
Convert values from GeoCoordinate. | |
void | normalize (double &value, int min, int max) |
Translate integer part of the given value between min and max. | |
Private Attributes | |
double | m_x |
X value. | |
double | m_y |
Y value. |
Scene coordinate.
SceneCoordinate::SceneCoordinate | ( | double | x, | |
double | y | |||
) |
Constructs a coordinate with given x and y.
x | X value | |
y | Y value |
SceneCoordinate::SceneCoordinate | ( | const GeoCoordinate & | coordinate | ) |
Constructs a coordinate with values converted from the given GeoCoordinate.
Uses convertFrom() method.
coordinate | Geological coordinate |
qreal SceneCoordinate::azimuthTo | ( | const SceneCoordinate & | to | ) | const |
Returns the azimuth from this coordinate to other coordinate.
Zero is pointing to north. Returned value is from 0 to 360.
to | Target coordinate |
void SceneCoordinate::convertFrom | ( | const GeoCoordinate & | coordinate | ) | [private] |
Convert values from GeoCoordinate.
Does run normalize() for the x value after the conversion to make sure that the result is inside the allowed map pixel values.
In horizontal direction: -180º equals scene pixel 0 (first scene pixel) +180º equals -180º
scene has 2^18 * 256 - 1 = 67108864 pixels per side one pixel width is 360º / 67108864 = 0.00000536441802978516º so the last scene pixel is 180º - 0.00000536441802978516º = 179.99999463558197021484º
coordinate | Geological coordinate |
bool SceneCoordinate::isNull | ( | ) | const |
Check if coordinate is (0.0, 0.0).
void SceneCoordinate::normalize | ( | double & | value, | |
int | min, | |||
int | max | |||
) | [private] |
Translate integer part of the given value between min and max.
If given value is not inside the given range (min <= value <= max), then the allowed range is adder or subtracted until the value does fit in the range. Only integer part is compared.
value | Value to be normalized | |
min | Minimum allowed value | |
max | Maximum allowed value |
void SceneCoordinate::setX | ( | double | x | ) |
Sets the latitude.
x | X value |
void SceneCoordinate::setY | ( | double | y | ) |
Sets the longitude.
y | Y value |
QPointF SceneCoordinate::toPointF | ( | ) | const |
Convert to QPointF.
double SceneCoordinate::x | ( | ) | const |
Returns the x value.
double SceneCoordinate::y | ( | ) | const |
Returns the y value.