QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsgcppoint.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgcppoint.h
3  --------------------------------------
4  Date : February 2022
5  Copyright : (C) 2022 by Nyall Dawson
6  Email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
16 #include "qgsgcppoint.h"
17 #include "qgscoordinatetransform.h"
18 #include "qgsexception.h"
19 #include "qgslogger.h"
20 
21 QgsGcpPoint::QgsGcpPoint( const QgsPointXY &sourcePoint, const QgsPointXY &destinationPoint, const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled )
22  : mSourcePoint( sourcePoint )
23  , mDestinationPoint( destinationPoint )
24  , mDestinationCrs( destinationPointCrs )
25  , mEnabled( enabled )
26 {
27 
28 }
29 
31 {
32  return mDestinationCrs;
33 }
34 
36 {
37  mDestinationCrs = crs;
38 }
39 
41 {
42  const QgsCoordinateTransform transform( mDestinationCrs, targetCrs, context );
43  try
44  {
45  return transform.transform( mDestinationPoint );
46  }
47  catch ( QgsCsException & )
48  {
49  QgsDebugMsg( QStringLiteral( "Error transforming destination point" ) );
50  return mDestinationPoint;
51  }
52 }
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
QgsGcpPoint::setDestinationPointCrs
void setDestinationPointCrs(const QgsCoordinateReferenceSystem &crs)
Sets the crs of the destination point.
Definition: qgsgcppoint.cpp:35
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
qgsgcppoint.h
QgsGcpPoint::transformedDestinationPoint
QgsPointXY transformedDestinationPoint(const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context) const
Returns the destionationPoint() transformed to the given target CRS.
Definition: qgsgcppoint.cpp:40
QgsCsException
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:65
qgscoordinatetransform.h
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
qgsexception.h
qgslogger.h
QgsCoordinateTransform::transform
QgsPointXY transform(const QgsPointXY &point, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward) const SIP_THROW(QgsCsException)
Transform the point from the source CRS to the destination CRS.
Definition: qgscoordinatetransform.cpp:272
QgsGcpPoint::destinationPointCrs
QgsCoordinateReferenceSystem destinationPointCrs() const
Returns the CRS of the destination point.
Definition: qgsgcppoint.cpp:30
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
qgscoordinatereferencesystem.h
QgsGcpPoint::QgsGcpPoint
QgsGcpPoint(const QgsPointXY &sourcePoint, const QgsPointXY &destinationPoint, const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled=true)
Constructor for QgsGcpPoint.
Definition: qgsgcppoint.cpp:21