![]() |
Mapper
0.9.0
API documentation
|
A Georeferencing defines a mapping between "map coordinates" (as measured on paper) and coordinates in the real world. More...
#include <georeferencing.h>
Public Types | |
enum | State { Local = 1, Normal = 2 } |
Georeferencing state. More... | |
Signals | |
void | stateChanged () |
Indicates a change of the state property. More... | |
void | transformationChanged () |
Indicates a change to the transformation rules between map coordinates and projected coordinates. More... | |
void | projectionChanged () |
Indicates a change to the projection rules between geographic coordinates and projected coordinates. More... | |
void | declinationChanged () |
Indicates a change of the declination. More... | |
Public Member Functions | |
Georeferencing () | |
Constructs a scale-only georeferencing. More... | |
Georeferencing (const Georeferencing &other) | |
Constructs a georeferencing which is a copy of an existing georeferencing. More... | |
~Georeferencing () override | |
Cleans up memory allocated by the georeferencing. More... | |
void | save (QXmlStreamWriter &xml) const |
Saves the georeferencing to an XML stream. More... | |
void | load (QXmlStreamReader &xml, bool load_scale_only) |
Creates a georeferencing from an XML stream. More... | |
Georeferencing & | operator= (const Georeferencing &other) |
Assigns the properties of another Georeferencing to this one. More... | |
bool | isValid () const |
Returns if the georeferencing settings are valid. More... | |
bool | isLocal () const |
Returns true if this georeferencing is local. More... | |
bool | isGeographic () const |
Returns true if the "projected CRS" is actually geographic. More... | |
State | getState () const |
Returns the georeferencing state. More... | |
void | setState (State value) |
Sets the georeferencing state. More... | |
unsigned int | getScaleDenominator () const |
Returns the principal scale denominator. More... | |
void | setScaleDenominator (int value) |
Sets the principal scale denominator. More... | |
double | getGridScaleFactor () const |
Returns the grid scale factor. More... | |
void | setGridScaleFactor (double value) |
Sets the grid scale factor. More... | |
double | getDeclination () const |
Returns the magnetic declination (in degrees). More... | |
void | setDeclination (double value) |
Sets the magnetic declination (in degrees). More... | |
double | getGrivation () const |
Returns the grivation. More... | |
double | getGrivationError () const |
Returns the deviation of the grivation from the one given in pre-0.6 files. More... | |
void | setGrivation (double value) |
Sets the grivation (in degrees). More... | |
MapCoord | getMapRefPoint () const |
Returns the map coordinates of the reference point. More... | |
void | setMapRefPoint (const MapCoord &point) |
Defines the map coordinates of the reference point. More... | |
QPointF | getProjectedRefPoint () const |
Returns the projected coordinates of the reference point. More... | |
void | setProjectedRefPoint (const QPointF &point, bool update_grivation=true) |
Defines the projected coordinates of the reference point. More... | |
QString | getProjectedCRSId () const |
Returns the unique id of the projected CRS. More... | |
QString | getProjectedCRSName () const |
Returns the name of the coordinate reference system (CRS) of the projected coordinates. More... | |
QString | getProjectedCoordinatesName () const |
Returns the name of the projected coordinates. More... | |
const std::vector< QString > & | getProjectedCRSParameters () const |
Returns the array of projected crs parameter values. More... | |
QString | getProjectedCRSSpec () const |
Returns the specification of the coordinate reference system (CRS) of the projected coordinates. More... | |
bool | setProjectedCRS (const QString &id, QString spec, std::vector< QString > params=std::vector< QString >()) |
Sets the coordinate reference system (CRS) of the projected coordinates. More... | |
double | getConvergence () const |
Calculates the meridian convergence at the reference point. More... | |
LatLon | getGeographicRefPoint () const |
Returns the geographic coordinates of the reference point. More... | |
void | setGeographicRefPoint (LatLon lat_lon, bool update_grivation=true) |
Defines the geographic coordinates of the reference point. More... | |
QPointF | toProjectedCoords (const MapCoord &map_coords) const |
Transforms map (paper) coordinates to projected coordinates. More... | |
QPointF | toProjectedCoords (const MapCoordF &map_coords) const |
Transforms map (paper) coordinates to projected coordinates. More... | |
MapCoord | toMapCoords (const QPointF &projected_coords) const |
Transforms projected coordinates to map (paper) coordinates. More... | |
MapCoordF | toMapCoordF (const QPointF &projected_coords) const |
Transforms projected coordinates to map (paper) coordinates. More... | |
LatLon | toGeographicCoords (const MapCoordF &map_coords, bool *ok=0) const |
Transforms map (paper) coordinates to geographic coordinates (lat/lon). More... | |
LatLon | toGeographicCoords (const QPointF &projected_coords, bool *ok=0) const |
Transforms CRS coordinates to geographic coordinates (lat/lon). More... | |
QPointF | toProjectedCoords (const LatLon &lat_lon, bool *ok=0) const |
Transforms geographic coordinates (lat/lon) to CRS coordinates. More... | |
MapCoord | toMapCoords (const LatLon &lat_lon, bool *ok=nullptr) const |
Transforms geographic coordinates (lat/lon) to map coordinates. More... | |
MapCoordF | toMapCoordF (const LatLon &lat_lon, bool *ok=nullptr) const |
Transforms geographic coordinates (lat/lon) to map coordinates. More... | |
MapCoordF | toMapCoordF (const Georeferencing *other, const MapCoordF &map_coords, bool *ok=nullptr) const |
Transforms map coordinates from the other georeferencing to map coordinates of this georeferencing, if possible. More... | |
QString | getErrorText () const |
Returns the current error text. More... | |
void | updateTransformation () |
Updates the transformation parameters between map coordinates and projected coordinates from the current projected reference point coordinates, the grivation and the scale. More... | |
void | updateGrivation () |
Updates the grivation. More... | |
void | initDeclination () |
Initializes the declination. More... | |
void | setTransformationDirectly (const QTransform &transform) |
Sets the transformation matrix from map coordinates to projected coordinates directly. More... | |
const QTransform & | mapToProjected () const |
const QTransform & | projectedToMap () const |
![]() | |
virtual const QMetaObject * | metaObject () const const |
QObject (QObject *parent) | |
virtual | ~QObject () |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
QString | objectName () const const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
bool | signalsBlocked () const const |
bool | blockSignals (bool block) |
QThread * | thread () const const |
void | moveToThread (QThread *targetThread) |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
void | killTimer (int id) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
const QObjectList & | children () const const |
void | setParent (QObject *parent) |
void | installEventFilter (QObject *filterObj) |
void | removeEventFilter (QObject *obj) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectTree () |
void | dumpObjectInfo () |
void | dumpObjectTree () const const |
void | dumpObjectInfo () const const |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const const |
QList< QByteArray > | dynamicPropertyNames () const const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
bool | inherits (const char *className) const const |
void | deleteLater () |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
T | qobject_cast (QObject *object) |
T | qobject_cast (const QObject *object) |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
Q_CLASSINFO (Name, Value) | |
Q_INTERFACES (...) | |
Q_PROPERTY (...) | |
Q_ENUMS (...) | |
Q_FLAGS (...) | |
Q_ENUM (...) | |
Q_FLAG (...) | |
Q_ENUM_NS (...) | |
Q_FLAG_NS (...) | |
Q_OBJECT Q_OBJECT | |
Q_GADGET Q_GADGET | |
Q_NAMESPACE Q_NAMESPACE | |
Q_SIGNALS Q_SIGNALS | |
Q_SIGNAL Q_SIGNAL | |
Q_SLOTS Q_SLOTS | |
Q_SLOT Q_SLOT | |
Q_EMIT Q_EMIT | |
Q_INVOKABLE Q_INVOKABLE | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
Static Public Member Functions | |
static constexpr unsigned int | scaleFactorPrecision () |
Returns the precision of the grid scale factor. More... | |
static double | roundScaleFactor (double value) |
Rounds according to the defined precision of the grid scale factor. More... | |
static constexpr unsigned int | declinationPrecision () |
Returns the precision of declination/grivation/convergence. More... | |
static double | roundDeclination (double) |
Rounds according to the defined precision of declination/grivation/convergence. More... | |
static double | radToDeg (double val) |
Converts a value from radians to degrees. More... | |
static double | degToRad (double val) |
Converts a value from degrees to radians. More... | |
static QString | degToDMS (double val) |
Converts a value from degrees to a D°M'S" string. More... | |
![]() | |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
Static Public Attributes | |
static const QString | geographic_crs_spec |
A shared PROJ specification of a WGS84 geographic CRS. More... | |
Friends | |
QDebug | operator<< (QDebug dbg, const Georeferencing &georef) |
Dumps a Georeferencing to the debug output. More... | |
Additional Inherited Members | |
![]() | |
typedef | QObjectList |
![]() | |
QObject * | sender () const const |
int | senderSignalIndex () const const |
int | receivers (const char *signal) const const |
bool | isSignalConnected (const QMetaMethod &signal) const const |
virtual void | timerEvent (QTimerEvent *event) |
virtual void | childEvent (QChildEvent *event) |
virtual void | customEvent (QEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
![]() | |
objectName | |
A Georeferencing defines a mapping between "map coordinates" (as measured on paper) and coordinates in the real world.
It provides functions for converting coordinates from one coordinate system to another.
Conversions between map coordinates and "projected coordinates" (flat metric coordinates in a projected coordinate reference system) are made as affine transformation based on the map scale (principal scale), grid scale factor, the grivation and a defined reference point.
Conversions between projected coordinates and geographic coordinates (here: latitude/longitude for the WGS84 datum) are made based on a specification of the coordinate reference system of the projected coordinates. The actual geographic transformation is done by the PROJ library for geographic projections.
If no (valid) specification is given, the projected coordinates are regarded as local coordinates. Local coordinates cannot be converted to other geographic coordinate systems. The georeferencing is "local".
Conversions between "map coordinates" and "geographic coordinates" use the projected coordinates as intermediate step.
Georeferencing state.
Enumerator | |
---|---|
Local | Only conversions between map and local projected coordinates are possible. |
Normal | All coordinate conversions are possible (if there is no error in the crs specification). |
OpenOrienteering::Georeferencing::Georeferencing | ( | ) |
Constructs a scale-only georeferencing.
OpenOrienteering::Georeferencing::Georeferencing | ( | const Georeferencing & | other | ) |
Constructs a georeferencing which is a copy of an existing georeferencing.
Note: Since QObjects may not be copied, this is better understood as creating a new object with the same settings.
|
overridedefault |
Cleans up memory allocated by the georeferencing.
|
signal |
Indicates a change of the declination.
The declination has no direct influence on projection or transformation. That's why there is an independent signal.
|
inlinestatic |
Returns the precision of declination/grivation/convergence.
The precision is given in number of decimal places, i.e. digits after the decimal point.
All values set as declination or grivation will be rounded to this precisison.
|
static |
Converts a value from degrees to a D°M'S" string.
|
static |
Converts a value from degrees to radians.
double OpenOrienteering::Georeferencing::getConvergence | ( | ) | const |
Calculates the meridian convergence at the reference point.
The meridian convergence is the angle between grid north and true north.
|
inline |
Returns the magnetic declination (in degrees).
QString OpenOrienteering::Georeferencing::getErrorText | ( | ) | const |
Returns the current error text.
|
inline |
Returns the geographic coordinates of the reference point.
|
inline |
Returns the grid scale factor.
The grid scale factor is the ratio between a length in the grid and the length on the earth model. It is applied as a factor to ground distances to get grid plane distances.
Mapper doesn't explicitly deal with any other factors (elevation factor, unit of measurement). Technically, this property can be used as a combined factor.
|
inline |
Returns the grivation.
|
inline |
Returns the deviation of the grivation from the one given in pre-0.6 files.
Only valid immediately after loading a georeferencing from a file. Returns 0.0 in any other context.
Files from Mapper versions before 0.6 may have used any number of decimal places for grivation. Since version 0.6, grivation is rounded to the number of decimal places defined by declinationPrecision(). When this rounding takes place (i.e. only when opening a file which has not been saved by 0.6 or later), the difference between the original value and the rounded value is temporarily provided by this function. This value can be used to for correcting dependent data. Any changes to declination or grivation will invalidate this value.
|
inline |
Returns the map coordinates of the reference point.
QString OpenOrienteering::Georeferencing::getProjectedCoordinatesName | ( | ) | const |
Returns the name of the projected coordinates.
|
inline |
Returns the unique id of the projected CRS.
QString OpenOrienteering::Georeferencing::getProjectedCRSName | ( | ) | const |
Returns the name of the coordinate reference system (CRS) of the projected coordinates.
|
inline |
Returns the array of projected crs parameter values.
|
inline |
Returns the specification of the coordinate reference system (CRS) of the projected coordinates.
|
inline |
Returns the projected coordinates of the reference point.
|
inline |
Returns the principal scale denominator.
The principal scale - or representative fraction - is the ratio between units on the printed map and units on ground.
|
inline |
Returns the georeferencing state.
void OpenOrienteering::Georeferencing::initDeclination | ( | ) |
Initializes the declination.
The new value is calculated from the grivation and the convergence. For a local georeferencing, the convergence is zero, and declination is set to the same value as grivation.
bool OpenOrienteering::Georeferencing::isGeographic | ( | ) | const |
Returns true if the "projected CRS" is actually geographic.
|
inline |
Returns true if this georeferencing is local.
A georeferencing is local if no (valid) coordinate system specification is given for the projected coordinates. A local georeferencing cannot convert coordinates from and to geographic coordinate systems.
|
inline |
Returns if the georeferencing settings are valid.
This means that coordinates can be converted between map and projected coordinates. isLocal() can be checked to determine if a conversion to geographic coordinates is also possible.
void OpenOrienteering::Georeferencing::load | ( | QXmlStreamReader & | xml, |
bool | load_scale_only | ||
) |
Creates a georeferencing from an XML stream.
const QTransform & OpenOrienteering::Georeferencing::mapToProjected | ( | ) | const |
Georeferencing & OpenOrienteering::Georeferencing::operator= | ( | const Georeferencing & | other | ) |
Assigns the properties of another Georeferencing to this one.
Having this method in a QObject is in contradiction to Qt conventions. But we really need to assign properties from one object to another, where each object maintains its own identity.
const QTransform & OpenOrienteering::Georeferencing::projectedToMap | ( | ) | const |
|
signal |
Indicates a change to the projection rules between geographic coordinates and projected coordinates.
|
static |
Converts a value from radians to degrees.
|
inlinestatic |
Rounds according to the defined precision of declination/grivation/convergence.
|
inlinestatic |
Rounds according to the defined precision of the grid scale factor.
void OpenOrienteering::Georeferencing::save | ( | QXmlStreamWriter & | xml | ) | const |
Saves the georeferencing to an XML stream.
|
inlinestatic |
Returns the precision of the grid scale factor.
The precision is given in number of decimal places, i.e. digits after the decimal point.
void OpenOrienteering::Georeferencing::setDeclination | ( | double | value | ) |
Sets the magnetic declination (in degrees).
Magnetic declination is the angle between magnetic north and true north. In the context of OpenOrienteering Mapper, it is the angle between the y axis of map coordinates and the latitude axis of geographic coordinates.
This will also affect the grivation value and the transformations.
void OpenOrienteering::Georeferencing::setGeographicRefPoint | ( | LatLon | lat_lon, |
bool | update_grivation = true |
||
) |
Defines the geographic coordinates of the reference point.
This may trigger changes of the projected coordinates of the reference point, the convergence, the grivation and the transformations.
void OpenOrienteering::Georeferencing::setGridScaleFactor | ( | double | value | ) |
Sets the grid scale factor.
void OpenOrienteering::Georeferencing::setGrivation | ( | double | value | ) |
Sets the grivation (in degrees).
Grivation is the angle between magnetic north and grid north. In the context of OpenOrienteering Mapper, it is the angle between the y axes of map coordinates and projected coordinates.
This will also affect the declination value and the transformations.
void OpenOrienteering::Georeferencing::setMapRefPoint | ( | const MapCoord & | point | ) |
Defines the map coordinates of the reference point.
This will not update the map and geographic coordinates of the reference point.
bool OpenOrienteering::Georeferencing::setProjectedCRS | ( | const QString & | id, |
QString | spec, | ||
std::vector< QString > | params = std::vector<QString>() |
||
) |
Sets the coordinate reference system (CRS) of the projected coordinates.
This will not touch any of the reference points, the declination, the grivation. It is up to the user to decide how to reestablish a valid configuration of geographic reference point, projected reference point, declination and grivation.
id | an identifier |
spec | the PROJ specification of the CRS |
params | parameter values (ignore for empty spec) |
void OpenOrienteering::Georeferencing::setProjectedRefPoint | ( | const QPointF & | point, |
bool | update_grivation = true |
||
) |
Defines the projected coordinates of the reference point.
This may trigger changes of the geographic coordinates of the reference point, the convergence, the grivation and the transformations.
void OpenOrienteering::Georeferencing::setScaleDenominator | ( | int | value | ) |
Sets the principal scale denominator.
void OpenOrienteering::Georeferencing::setState | ( | Georeferencing::State | value | ) |
Sets the georeferencing state.
This is only necessary to decrease the state to Local, as otherwise it will be automatically changed when setting the respective values.
void OpenOrienteering::Georeferencing::setTransformationDirectly | ( | const QTransform & | transform | ) |
Sets the transformation matrix from map coordinates to projected coordinates directly.
|
signal |
Indicates a change of the state property.
LatLon OpenOrienteering::Georeferencing::toGeographicCoords | ( | const MapCoordF & | map_coords, |
bool * | ok = 0 |
||
) | const |
Transforms map (paper) coordinates to geographic coordinates (lat/lon).
LatLon OpenOrienteering::Georeferencing::toGeographicCoords | ( | const QPointF & | projected_coords, |
bool * | ok = 0 |
||
) | const |
Transforms CRS coordinates to geographic coordinates (lat/lon).
Transforms projected coordinates to map (paper) coordinates.
MapCoordF OpenOrienteering::Georeferencing::toMapCoordF | ( | const LatLon & | lat_lon, |
bool * | ok = nullptr |
||
) | const |
Transforms geographic coordinates (lat/lon) to map coordinates.
MapCoordF OpenOrienteering::Georeferencing::toMapCoordF | ( | const Georeferencing * | other, |
const MapCoordF & | map_coords, | ||
bool * | ok = nullptr |
||
) | const |
Transforms map coordinates from the other georeferencing to map coordinates of this georeferencing, if possible.
Transforms projected coordinates to map (paper) coordinates.
MapCoord OpenOrienteering::Georeferencing::toMapCoords | ( | const LatLon & | lat_lon, |
bool * | ok = nullptr |
||
) | const |
Transforms geographic coordinates (lat/lon) to map coordinates.
Transforms map (paper) coordinates to projected coordinates.
Transforms map (paper) coordinates to projected coordinates.
QPointF OpenOrienteering::Georeferencing::toProjectedCoords | ( | const LatLon & | lat_lon, |
bool * | ok = 0 |
||
) | const |
Transforms geographic coordinates (lat/lon) to CRS coordinates.
|
signal |
Indicates a change to the transformation rules between map coordinates and projected coordinates.
void OpenOrienteering::Georeferencing::updateGrivation | ( | ) |
Updates the grivation.
The new value is calculated from the declination and the convergence. For a local georeferencing, the convergence is zero, and grivation is set to the same value as declination.
void OpenOrienteering::Georeferencing::updateTransformation | ( | ) |
Updates the transformation parameters between map coordinates and projected coordinates from the current projected reference point coordinates, the grivation and the scale.
|
friend |
Dumps a Georeferencing to the debug output.
Note that this requires a reference, not a pointer.
|
static |
A shared PROJ specification of a WGS84 geographic CRS.