mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Move QgsGcpPoint to analysis library
This commit is contained in:
parent
a413b69f0c
commit
8e79a41e7c
@ -1,6 +1,7 @@
|
||||
// Include auto-generated SIP files
|
||||
%Include auto_generated/qgsanalysis.sip
|
||||
%Include auto_generated/georeferencing/qgsgcpgeometrytransformer.sip
|
||||
%Include auto_generated/georeferencing/qgsgcppoint.sip
|
||||
%Include auto_generated/georeferencing/qgsgcptransformer.sip
|
||||
%Include auto_generated/interpolation/qgsgridfilewriter.sip
|
||||
%Include auto_generated/interpolation/qgsidwinterpolator.sip
|
||||
|
6
python/analysis/auto_additions/qgsgcppoint.py
Normal file
6
python/analysis/auto_additions/qgsgcppoint.py
Normal file
@ -0,0 +1,6 @@
|
||||
# The following has been generated automatically from src/analysis/georeferencing/qgsgcppoint.h
|
||||
# monkey patching scoped based enum
|
||||
QgsGcpPoint.PointType.Source.__doc__ = "Source point"
|
||||
QgsGcpPoint.PointType.Destination.__doc__ = "Destination point"
|
||||
QgsGcpPoint.PointType.__doc__ = 'Coordinate point types\n\n' + '* ``Source``: ' + QgsGcpPoint.PointType.Source.__doc__ + '\n' + '* ``Destination``: ' + QgsGcpPoint.PointType.Destination.__doc__
|
||||
# --
|
119
python/analysis/auto_generated/georeferencing/qgsgcppoint.sip.in
Normal file
119
python/analysis/auto_generated/georeferencing/qgsgcppoint.sip.in
Normal file
@ -0,0 +1,119 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/analysis/georeferencing/qgsgcppoint.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsGcpPoint
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
Contains properties of a ground control point (GCP).
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsgcppoint.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
enum class PointType
|
||||
{
|
||||
Source,
|
||||
Destination,
|
||||
};
|
||||
|
||||
QgsGcpPoint( const QgsPointXY &sourcePoint, const QgsPointXY &destinationPoint,
|
||||
const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled );
|
||||
%Docstring
|
||||
Constructor for QgsGcpPoint.
|
||||
|
||||
:param sourceCoordinates: source coordinates. This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
|
||||
:param destinationPoint: destination coordinates
|
||||
:param destinationPointCrs: CRS of destination point
|
||||
:param enabled: whether the point is currently enabled
|
||||
%End
|
||||
|
||||
QgsPointXY sourcePoint() const;
|
||||
%Docstring
|
||||
Returns the source coordinates.
|
||||
|
||||
This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
|
||||
|
||||
.. seealso:: :py:func:`setSourcePoint`
|
||||
%End
|
||||
|
||||
void setSourcePoint( QgsPointXY point );
|
||||
%Docstring
|
||||
Sets the source coordinates.
|
||||
|
||||
This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
|
||||
|
||||
.. seealso:: :py:func:`sourcePoint`
|
||||
%End
|
||||
|
||||
QgsPointXY destinationPoint() const;
|
||||
%Docstring
|
||||
Returns the destination coordinates.
|
||||
|
||||
.. seealso:: :py:func:`setDestinationPoint`
|
||||
%End
|
||||
|
||||
void setDestinationPoint( QgsPointXY point );
|
||||
%Docstring
|
||||
Sets the destination coordinates.
|
||||
|
||||
.. seealso:: :py:func:`destinationPoint`
|
||||
%End
|
||||
|
||||
QgsCoordinateReferenceSystem destinationPointCrs() const;
|
||||
%Docstring
|
||||
Returns the CRS of the destination point.
|
||||
|
||||
.. seealso:: :py:func:`setDestinationCrs`
|
||||
%End
|
||||
|
||||
void setDestinationPointCrs( const QgsCoordinateReferenceSystem &crs );
|
||||
%Docstring
|
||||
Sets the ``crs`` of the destination point.
|
||||
|
||||
.. seealso:: :py:func:`destinationCrs`
|
||||
%End
|
||||
|
||||
QgsPointXY transformedDestinationPoint( const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context ) const;
|
||||
%Docstring
|
||||
Returns the :py:func:`~QgsGcpPoint.destionationPoint` transformed to the given target CRS.
|
||||
%End
|
||||
|
||||
bool isEnabled() const;
|
||||
%Docstring
|
||||
Returns ``True`` if the point is currently enabled.
|
||||
|
||||
.. seealso:: :py:func:`setEnabled`
|
||||
%End
|
||||
|
||||
void setEnabled( bool enabled );
|
||||
%Docstring
|
||||
Sets whether the point is currently enabled.
|
||||
|
||||
.. seealso:: :py:func:`enabled`
|
||||
%End
|
||||
|
||||
bool operator==( const QgsGcpPoint &other ) const;
|
||||
|
||||
bool operator!=( const QgsGcpPoint &other ) const;
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/analysis/georeferencing/qgsgcppoint.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -13,6 +13,7 @@ set(QGIS_ANALYSIS_SRCS
|
||||
${BISON_QgsRasterCalcParser_OUTPUTS}
|
||||
|
||||
georeferencing/qgsgcpgeometrytransformer.cpp
|
||||
georeferencing/qgsgcppoint.cpp
|
||||
georeferencing/qgsgcptransformer.cpp
|
||||
georeferencing/qgsleastsquares.cpp
|
||||
|
||||
@ -305,6 +306,7 @@ set(QGIS_ANALYSIS_HDRS
|
||||
qgsanalysis.h
|
||||
|
||||
georeferencing/qgsgcpgeometrytransformer.h
|
||||
georeferencing/qgsgcppoint.h
|
||||
georeferencing/qgsgcptransformer.h
|
||||
|
||||
interpolation/Bezier3D.h
|
||||
|
54
src/analysis/georeferencing/qgsgcppoint.cpp
Normal file
54
src/analysis/georeferencing/qgsgcppoint.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
qgsgcppoint.h
|
||||
--------------------------------------
|
||||
Date : February 2022
|
||||
Copyright : (C) 2022 by Nyall Dawson
|
||||
Email : nyall dot dawson at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include <QPainter>
|
||||
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include "qgsgcppoint.h"
|
||||
#include "qgscoordinatetransform.h"
|
||||
#include "qgsexception.h"
|
||||
#include "qgslogger.h"
|
||||
|
||||
QgsGcpPoint::QgsGcpPoint( const QgsPointXY &sourcePoint, const QgsPointXY &destinationPoint, const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled )
|
||||
: mSourcePoint( sourcePoint )
|
||||
, mDestinationPoint( destinationPoint )
|
||||
, mDestinationCrs( destinationPointCrs )
|
||||
, mEnabled( enabled )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QgsCoordinateReferenceSystem QgsGcpPoint::destinationPointCrs() const
|
||||
{
|
||||
return mDestinationCrs;
|
||||
}
|
||||
|
||||
void QgsGcpPoint::setDestinationPointCrs( const QgsCoordinateReferenceSystem &crs )
|
||||
{
|
||||
mDestinationCrs = crs;
|
||||
}
|
||||
|
||||
QgsPointXY QgsGcpPoint::transformedDestinationPoint( const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context ) const
|
||||
{
|
||||
const QgsCoordinateTransform transform( mDestinationCrs, targetCrs, context );
|
||||
try
|
||||
{
|
||||
return transform.transform( mDestinationPoint );
|
||||
}
|
||||
catch ( QgsCsException & )
|
||||
{
|
||||
QgsDebugMsg( QStringLiteral( "Error transforming destination point" ) );
|
||||
return mDestinationPoint;
|
||||
}
|
||||
}
|
140
src/analysis/georeferencing/qgsgcppoint.h
Normal file
140
src/analysis/georeferencing/qgsgcppoint.h
Normal file
@ -0,0 +1,140 @@
|
||||
/***************************************************************************
|
||||
qgsgcppoint.h
|
||||
--------------------------------------
|
||||
Date : February 2022
|
||||
Copyright : (C) 2022 by Nyall Dawson
|
||||
Email : nyall dot dawson at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSGCPPOINT_H
|
||||
#define QGSGCPPOINT_H
|
||||
|
||||
#include "qgis_analysis.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
|
||||
class QgsCoordinateTransformContext;
|
||||
|
||||
/**
|
||||
* \ingroup analysis
|
||||
* \brief Contains properties of a ground control point (GCP).
|
||||
*
|
||||
* \since QGIS 3.26
|
||||
*/
|
||||
class ANALYSIS_EXPORT QgsGcpPoint
|
||||
{
|
||||
public:
|
||||
|
||||
//! Coordinate point types
|
||||
enum class PointType
|
||||
{
|
||||
Source, //!< Source point
|
||||
Destination, //!< Destination point
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor for QgsGcpPoint.
|
||||
*
|
||||
* \param sourceCoordinates source coordinates. This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
|
||||
* \param destinationPoint destination coordinates
|
||||
* \param destinationPointCrs CRS of destination point
|
||||
* \param enabled whether the point is currently enabled
|
||||
*/
|
||||
QgsGcpPoint( const QgsPointXY &sourcePoint, const QgsPointXY &destinationPoint,
|
||||
const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled );
|
||||
|
||||
/**
|
||||
* Returns the source coordinates.
|
||||
*
|
||||
* This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
|
||||
*
|
||||
* \see setSourcePoint()
|
||||
*/
|
||||
QgsPointXY sourcePoint() const { return mSourcePoint; }
|
||||
|
||||
/**
|
||||
* Sets the source coordinates.
|
||||
*
|
||||
* This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
|
||||
*
|
||||
* \see sourcePoint()
|
||||
*/
|
||||
void setSourcePoint( QgsPointXY point ) { mSourcePoint = point; }
|
||||
|
||||
/**
|
||||
* Returns the destination coordinates.
|
||||
*
|
||||
* \see setDestinationPoint()
|
||||
*/
|
||||
QgsPointXY destinationPoint() const { return mDestinationPoint; }
|
||||
|
||||
/**
|
||||
* Sets the destination coordinates.
|
||||
*
|
||||
* \see destinationPoint()
|
||||
*/
|
||||
void setDestinationPoint( QgsPointXY point ) { mDestinationPoint = point; }
|
||||
|
||||
/**
|
||||
* Returns the CRS of the destination point.
|
||||
*
|
||||
* \see setDestinationCrs()
|
||||
*/
|
||||
QgsCoordinateReferenceSystem destinationPointCrs() const;
|
||||
|
||||
/**
|
||||
* Sets the \a crs of the destination point.
|
||||
*
|
||||
* \see destinationCrs()
|
||||
*/
|
||||
void setDestinationPointCrs( const QgsCoordinateReferenceSystem &crs );
|
||||
|
||||
/**
|
||||
* Returns the destionationPoint() transformed to the given target CRS.
|
||||
*/
|
||||
QgsPointXY transformedDestinationPoint( const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context ) const;
|
||||
|
||||
/**
|
||||
* Returns TRUE if the point is currently enabled.
|
||||
*
|
||||
* \see setEnabled()
|
||||
*/
|
||||
bool isEnabled() const { return mEnabled; }
|
||||
|
||||
/**
|
||||
* Sets whether the point is currently enabled.
|
||||
*
|
||||
* \see enabled()
|
||||
*/
|
||||
void setEnabled( bool enabled ) { mEnabled = enabled; }
|
||||
|
||||
// TODO c++20 - replace with = default
|
||||
bool operator==( const QgsGcpPoint &other ) const
|
||||
{
|
||||
return mEnabled == other.mEnabled
|
||||
&& mSourcePoint == other.mSourcePoint
|
||||
&& mDestinationPoint == other.mDestinationPoint
|
||||
&& mDestinationCrs == other.mDestinationCrs;
|
||||
}
|
||||
|
||||
bool operator!=( const QgsGcpPoint &other ) const
|
||||
{
|
||||
return !( *this == other );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
QgsPointXY mSourcePoint;
|
||||
QgsPointXY mDestinationPoint;
|
||||
QgsCoordinateReferenceSystem mDestinationCrs;
|
||||
bool mEnabled = true;
|
||||
|
||||
};
|
||||
|
||||
#endif //QGSGCPPOINT_H
|
@ -17,52 +17,8 @@
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsgcpcanvasitem.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
|
||||
|
||||
#include "qgsgeorefdatapoint.h"
|
||||
|
||||
//
|
||||
// QgsGcpPoint
|
||||
//
|
||||
|
||||
QgsGcpPoint::QgsGcpPoint( const QgsPointXY &sourcePoint, const QgsPointXY &destinationPoint, const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled )
|
||||
: mSourcePoint( sourcePoint )
|
||||
, mDestinationPoint( destinationPoint )
|
||||
, mDestinationCrs( destinationPointCrs )
|
||||
, mEnabled( enabled )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QgsCoordinateReferenceSystem QgsGcpPoint::destinationPointCrs() const
|
||||
{
|
||||
return mDestinationCrs;
|
||||
}
|
||||
|
||||
void QgsGcpPoint::setDestinationPointCrs( const QgsCoordinateReferenceSystem &crs )
|
||||
{
|
||||
mDestinationCrs = crs;
|
||||
}
|
||||
|
||||
QgsPointXY QgsGcpPoint::transformedDestinationPoint( const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context ) const
|
||||
{
|
||||
const QgsCoordinateTransform transform( mDestinationCrs, targetCrs, context );
|
||||
try
|
||||
{
|
||||
return transform.transform( mDestinationPoint );
|
||||
}
|
||||
catch ( QgsCsException & )
|
||||
{
|
||||
QgsDebugMsg( QStringLiteral( "Error transforming destination point" ) );
|
||||
return mDestinationPoint;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// QgsGeorefDataPoint
|
||||
//
|
||||
|
||||
QgsGeorefDataPoint::QgsGeorefDataPoint( QgsMapCanvas *srcCanvas, QgsMapCanvas *dstCanvas,
|
||||
const QgsPointXY &sourceCoordinates, const QgsPointXY &destinationPoint,
|
||||
const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled )
|
||||
|
@ -19,124 +19,11 @@
|
||||
#include "qgis_app.h"
|
||||
#include "qgsmapcanvasitem.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include "qgsgcppoint.h"
|
||||
|
||||
class QgsGCPCanvasItem;
|
||||
class QgsCoordinateTransformContext;
|
||||
|
||||
/**
|
||||
* Contains properties of a ground control point (GCP).
|
||||
*/
|
||||
class APP_EXPORT QgsGcpPoint
|
||||
{
|
||||
public:
|
||||
|
||||
//! Coordinate point types
|
||||
enum class PointType
|
||||
{
|
||||
Source, //!< Source point
|
||||
Destination, //!< Destination point
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor for QgsGcpPoint.
|
||||
*
|
||||
* \param sourceCoordinates source coordinates. This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
|
||||
* \param destinationPoint destination coordinates
|
||||
* \param destinationPointCrs CRS of destination point
|
||||
* \param enabled whether the point is currently enabled
|
||||
*/
|
||||
QgsGcpPoint( const QgsPointXY &sourcePoint, const QgsPointXY &destinationPoint,
|
||||
const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled );
|
||||
|
||||
/**
|
||||
* Returns the source coordinates.
|
||||
*
|
||||
* This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
|
||||
*
|
||||
* \see setSourcePoint()
|
||||
*/
|
||||
QgsPointXY sourcePoint() const { return mSourcePoint; }
|
||||
|
||||
/**
|
||||
* Sets the source coordinates.
|
||||
*
|
||||
* This may either be in pixels (for completely non-referenced images) OR in the source layer CRS.
|
||||
*
|
||||
* \see sourcePoint()
|
||||
*/
|
||||
void setSourcePoint( QgsPointXY point ) { mSourcePoint = point; }
|
||||
|
||||
/**
|
||||
* Returns the destination coordinates.
|
||||
*
|
||||
* \see setDestinationPoint()
|
||||
*/
|
||||
QgsPointXY destinationPoint() const { return mDestinationPoint; }
|
||||
|
||||
/**
|
||||
* Sets the destination coordinates.
|
||||
*
|
||||
* \see destinationPoint()
|
||||
*/
|
||||
void setDestinationPoint( QgsPointXY point ) { mDestinationPoint = point; }
|
||||
|
||||
/**
|
||||
* Returns the CRS of the destination point.
|
||||
*
|
||||
* \see setDestinationCrs()
|
||||
*/
|
||||
QgsCoordinateReferenceSystem destinationPointCrs() const;
|
||||
|
||||
/**
|
||||
* Sets the \a crs of the destination point.
|
||||
*
|
||||
* \see destinationCrs()
|
||||
*/
|
||||
void setDestinationPointCrs( const QgsCoordinateReferenceSystem &crs );
|
||||
|
||||
/**
|
||||
* Returns the destionationPoint() transformed to the given target CRS.
|
||||
*/
|
||||
QgsPointXY transformedDestinationPoint( const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context ) const;
|
||||
|
||||
/**
|
||||
* Returns TRUE if the point is currently enabled.
|
||||
*
|
||||
* \see setEnabled()
|
||||
*/
|
||||
bool isEnabled() const { return mEnabled; }
|
||||
|
||||
/**
|
||||
* Sets whether the point is currently enabled.
|
||||
*
|
||||
* \see enabled()
|
||||
*/
|
||||
void setEnabled( bool enabled ) { mEnabled = enabled; }
|
||||
|
||||
// TODO c++20 - replace with = default
|
||||
bool operator==( const QgsGcpPoint &other ) const
|
||||
{
|
||||
return mEnabled == other.mEnabled
|
||||
&& mSourcePoint == other.mSourcePoint
|
||||
&& mDestinationPoint == other.mDestinationPoint
|
||||
&& mDestinationCrs == other.mDestinationCrs;
|
||||
}
|
||||
|
||||
bool operator!=( const QgsGcpPoint &other ) const
|
||||
{
|
||||
return !( *this == other );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
QgsPointXY mSourcePoint;
|
||||
QgsPointXY mDestinationPoint;
|
||||
QgsCoordinateReferenceSystem mDestinationCrs;
|
||||
bool mEnabled = true;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Container for a GCP point and the graphical objects which represent it on the map canvas.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user