Cleanup global constants

- Deprecate global geographic crs strings, these should not be used
- Move some global constants to Qgis, and monkey patch for
  API compatibility
- Deprecate global qgsVsiPrefix. Use QgsGdalUtils::vsiPrefixForPath()
  instead
This commit is contained in:
Nyall Dawson 2025-04-01 18:42:37 +10:00
parent a0d434f89d
commit 71420a5628
51 changed files with 385 additions and 299 deletions

View File

@ -251,11 +251,19 @@ QgsBox3d = QgsBox3D
QgsMesh3dAveragingMethod = QgsMesh3DAveragingMethod
QgsMesh3dDataBlock = QgsMesh3DDataBlock
GEOWKT = geoWkt()
GEOWKT = Qgis.geoWkt()
geoWkt = Qgis.geoWkt
GEOPROJ4 = Qgis.geoProj4()
geoProj4 = Qgis.geoProj4
GEO_EPSG_CRS_AUTHID = Qgis.geographicCrsAuthId()
geoEpsgCrsAuthId = Qgis.geographicCrsAuthId
GEO_NONE = Qgis.geoNone()
geoNone = Qgis.geoNone
DEFAULT_POINT_SIZE = Qgis.DEFAULT_POINT_SIZE
DEFAULT_LINE_WIDTH = Qgis.DEFAULT_LINE_WIDTH
DEFAULT_SEGMENT_EPSILON = Qgis.DEFAULT_SEGMENT_EPSILON
PROJECT_SCALES = Qgis.defaultProjectScales()
GEOPROJ4 = geoProj4()
GEO_EPSG_CRS_AUTHID = geoEpsgCrsAuthId()
GEO_NONE = geoNone()
# TODO QGIS 4.0 - remove, require use of explicit getter/setter

View File

@ -11395,8 +11395,8 @@ Qgis.SegmentCalculationMethod.__doc__ = """brief Method used to calculate the nu
# --
Qgis.SegmentCalculationMethod.baseClass = Qgis
try:
Qgis.__attribute_docs__ = {'QGIS_DEV_VERSION': 'The development version', 'DEFAULT_SEARCH_RADIUS_MM': 'Identify search radius in mm', 'DEFAULT_MAPTOPIXEL_THRESHOLD': 'Default threshold between map coordinates and device coordinates for map2pixel simplification', 'DEFAULT_HIGHLIGHT_COLOR': 'Default highlight color. The transparency is expected to only be applied to polygon\nfill. Lines and outlines are rendered opaque.', 'DEFAULT_HIGHLIGHT_BUFFER_MM': 'Default highlight buffer in mm.', 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': 'Default highlight line/stroke minimum width in mm.', 'SCALE_PRECISION': 'Fudge factor used to compare two scales. The code is often going from scale to scale\ndenominator. So it looses precision and, when a limit is inclusive, can lead to errors.\nTo avoid that, use this factor instead of using <= or >=.\n\n.. deprecated:: 3.40\n\n No longer used by QGIS and will be removed in QGIS 4.0.', 'DEFAULT_Z_COORDINATE': 'Default Z coordinate value.\nThis value have to be assigned to the Z coordinate for the vertex.', 'DEFAULT_M_COORDINATE': 'Default M coordinate value.\nThis value have to be assigned to the M coordinate for the vertex.\n\n.. versionadded:: 3.20', 'UI_SCALE_FACTOR': 'UI scaling factor. This should be applied to all widget sizes obtained from font metrics,\nto account for differences in the default font sizes across different platforms.', 'DEFAULT_SNAP_TOLERANCE': 'Default snapping distance tolerance.', 'DEFAULT_SNAP_UNITS': 'Default snapping distance units.'}
Qgis.__annotations__ = {'QGIS_DEV_VERSION': str, 'DEFAULT_SEARCH_RADIUS_MM': float, 'DEFAULT_MAPTOPIXEL_THRESHOLD': float, 'DEFAULT_HIGHLIGHT_COLOR': 'QColor', 'DEFAULT_HIGHLIGHT_BUFFER_MM': float, 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': float, 'SCALE_PRECISION': float, 'DEFAULT_Z_COORDINATE': float, 'DEFAULT_M_COORDINATE': float, 'UI_SCALE_FACTOR': float, 'DEFAULT_SNAP_TOLERANCE': float, 'DEFAULT_SNAP_UNITS': 'Qgis.MapToolUnit'}
Qgis.__attribute_docs__ = {'QGIS_DEV_VERSION': 'The development version', 'DEFAULT_SEARCH_RADIUS_MM': 'Identify search radius in mm', 'DEFAULT_MAPTOPIXEL_THRESHOLD': 'Default threshold between map coordinates and device coordinates for map2pixel simplification', 'DEFAULT_HIGHLIGHT_COLOR': 'Default highlight color. The transparency is expected to only be applied to polygon\nfill. Lines and outlines are rendered opaque.', 'DEFAULT_HIGHLIGHT_BUFFER_MM': 'Default highlight buffer in mm.', 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': 'Default highlight line/stroke minimum width in mm.', 'SCALE_PRECISION': 'Fudge factor used to compare two scales. The code is often going from scale to scale\ndenominator. So it looses precision and, when a limit is inclusive, can lead to errors.\nTo avoid that, use this factor instead of using <= or >=.\n\n.. deprecated:: 3.40\n\n No longer used by QGIS and will be removed in QGIS 4.0.', 'DEFAULT_Z_COORDINATE': 'Default Z coordinate value.\nThis value have to be assigned to the Z coordinate for the vertex.', 'DEFAULT_M_COORDINATE': 'Default M coordinate value.\nThis value have to be assigned to the M coordinate for the vertex.\n\n.. versionadded:: 3.20', 'UI_SCALE_FACTOR': 'UI scaling factor. This should be applied to all widget sizes obtained from font metrics,\nto account for differences in the default font sizes across different platforms.', 'DEFAULT_SNAP_TOLERANCE': 'Default snapping distance tolerance.', 'DEFAULT_SNAP_UNITS': 'Default snapping distance units.', 'USER_CRS_START_ID': 'Minimum ID number for a user-defined projection.', 'DEFAULT_POINT_SIZE': 'The default size (in millimeters) for point marker symbols', 'DEFAULT_LINE_WIDTH': 'The default width (in millimeters) for line symbols', 'DEFAULT_SEGMENT_EPSILON': 'Default snapping tolerance for segments'}
Qgis.__annotations__ = {'QGIS_DEV_VERSION': str, 'DEFAULT_SEARCH_RADIUS_MM': float, 'DEFAULT_MAPTOPIXEL_THRESHOLD': float, 'DEFAULT_HIGHLIGHT_COLOR': 'QColor', 'DEFAULT_HIGHLIGHT_BUFFER_MM': float, 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': float, 'SCALE_PRECISION': float, 'DEFAULT_Z_COORDINATE': float, 'DEFAULT_M_COORDINATE': float, 'UI_SCALE_FACTOR': float, 'DEFAULT_SNAP_TOLERANCE': float, 'DEFAULT_SNAP_UNITS': 'Qgis.MapToolUnit', 'USER_CRS_START_ID': int, 'DEFAULT_POINT_SIZE': float, 'DEFAULT_LINE_WIDTH': float, 'DEFAULT_SEGMENT_EPSILON': float}
Qgis.version = staticmethod(Qgis.version)
Qgis.versionInt = staticmethod(Qgis.versionInt)
Qgis.releaseName = staticmethod(Qgis.releaseName)
@ -11407,5 +11407,9 @@ try:
Qgis.geosVersionMinor = staticmethod(Qgis.geosVersionMinor)
Qgis.geosVersionPatch = staticmethod(Qgis.geosVersionPatch)
Qgis.geosVersion = staticmethod(Qgis.geosVersion)
Qgis.geoNone = staticmethod(Qgis.geoNone)
Qgis.geographicCrsAuthId = staticmethod(Qgis.geographicCrsAuthId)
Qgis.geoWkt = staticmethod(Qgis.geoWkt)
Qgis.geoProj4 = staticmethod(Qgis.geoProj4)
except (NameError, AttributeError):
pass

View File

@ -870,7 +870,7 @@ Searches for the closest vertex in this geometry to the given point.
- atVertex: Receives index of the closest vertex
%End
double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint /Out/, int &nextVertexIndex /Out/, int *leftOrRightOfSegment /Out/ = 0, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint /Out/, int &nextVertexIndex /Out/, int *leftOrRightOfSegment /Out/ = 0, double epsilon = Qgis::DEFAULT_SEGMENT_EPSILON ) const;
%Docstring
Searches for the closest segment of geometry to the given point

View File

@ -3362,6 +3362,16 @@ The development version
static const Qgis::MapToolUnit DEFAULT_SNAP_UNITS;
static const int USER_CRS_START_ID;
static const double DEFAULT_POINT_SIZE;
static const double DEFAULT_LINE_WIDTH;
static const double DEFAULT_SEGMENT_EPSILON;
static QString defaultProjectScales();
%Docstring
A string with default project scales.
@ -3403,6 +3413,40 @@ GEOS string version linked
.. versionadded:: 3.20
%End
static QString geoNone();
%Docstring
Constant that holds the string representation for "No ellipse/No CRS".
.. versionadded:: 3.44
%End
static QString geographicCrsAuthId();
%Docstring
Geographic coordinate system auth:id string for a default geographic CRS
(EPSG:4326).
.. versionadded:: 3.44
%End
static QString geoWkt();
%Docstring
WKT string that represents a geographic coord system
.. deprecated:: 3.44
Will be removed in QGIS 4.0.
%End
static QString geoProj4();
%Docstring
PROJ4 string that represents a geographic coord system.
.. deprecated:: 3.44
Will be removed in QGIS 4.0.
%End
};
@ -3719,24 +3763,24 @@ bool operator< ( const QVariant &v1, const QVariant &v2 );
QString qgsVsiPrefix( const QString &path );
QString qgsVsiPrefix( const QString &path ) /Deprecated="Since 3.44. Use QgsGdalUtils.vsiPrefixForPath() instead."/;
%Docstring
Returns a the vsi prefix which corresponds to a file ``path``, or an
empty string if the path is not associated with a vsi prefix.
.. deprecated:: 3.44
Use :py:func:`QgsGdalUtils.vsiPrefixForPath()` instead.
%End
const long GEOSRID;
const long GEOSRID;
const long GEOCRS_ID;
const long GEOCRS_ID;
const long GEO_EPSG_CRS_ID;
const int USER_CRS_START_ID;
const double DEFAULT_POINT_SIZE;
const double DEFAULT_LINE_WIDTH;
const double DEFAULT_SEGMENT_EPSILON;
const long GEO_EPSG_CRS_ID;
typedef unsigned long long qgssize;
@ -3746,22 +3790,6 @@ typedef unsigned long long qgssize;
QString geoWkt();
%Docstring
Wkt string that represents a geographic coord sys \since QGIS GEOWkt
%End
//! PROJ4 string that represents a geographic coord sys
QString geoProj4();
//! Geographic coord sys from EPSG authority
QString geoEpsgCrsAuthId();
//! Constant that holds the string representation for "No ellips/No CRS"
QString geoNone();
/************************************************************************
* This file has been generated automatically from *
* *

View File

@ -174,7 +174,7 @@ Returns the distance between this point and another point.
.. seealso:: :py:func:`sqrDist`
%End
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint /Out/, double epsilon = DEFAULT_SEGMENT_EPSILON ) const /HoldGIL/;
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint /Out/, double epsilon = Qgis::DEFAULT_SEGMENT_EPSILON ) const /HoldGIL/;
%Docstring
Returns the minimum distance between this point and a segment
%End

View File

@ -260,12 +260,19 @@ QgsBox3d = QgsBox3D
QgsMesh3dAveragingMethod = QgsMesh3DAveragingMethod
QgsMesh3dDataBlock = QgsMesh3DDataBlock
GEOWKT = geoWkt()
PROJECT_SCALES = Qgis.defaultProjectScales()
GEOPROJ4 = geoProj4()
GEO_EPSG_CRS_AUTHID = geoEpsgCrsAuthId()
GEO_NONE = geoNone()
GEOWKT = Qgis.geoWkt()
geoWkt = Qgis.geoWkt
GEOPROJ4 = Qgis.geoProj4()
geoProj4 = Qgis.geoProj4
GEO_EPSG_CRS_AUTHID = Qgis.geographicCrsAuthId()
geoEpsgCrsAuthId = Qgis.geographicCrsAuthId
GEO_NONE = Qgis.geoNone()
geoNone = Qgis.geoNone
DEFAULT_POINT_SIZE = Qgis.DEFAULT_POINT_SIZE
DEFAULT_LINE_WIDTH = Qgis.DEFAULT_LINE_WIDTH
DEFAULT_SEGMENT_EPSILON = Qgis.DEFAULT_SEGMENT_EPSILON
PROJECT_SCALES = Qgis.defaultProjectScales()
# TODO QGIS 4.0 - remove, require use of explicit getter/setter

View File

@ -11336,8 +11336,8 @@ Qgis.VectorRenderingSimplificationFlag.__or__ = lambda flag1, flag2: Qgis.Vector
Qgis.DataProviderReadFlag.__or__ = lambda flag1, flag2: Qgis.DataProviderReadFlags(_force_int(flag1) | _force_int(flag2))
Qgis.VectorProviderCapability.__or__ = lambda flag1, flag2: Qgis.VectorProviderCapabilities(_force_int(flag1) | _force_int(flag2))
try:
Qgis.__attribute_docs__ = {'QGIS_DEV_VERSION': 'The development version', 'DEFAULT_SEARCH_RADIUS_MM': 'Identify search radius in mm', 'DEFAULT_MAPTOPIXEL_THRESHOLD': 'Default threshold between map coordinates and device coordinates for map2pixel simplification', 'DEFAULT_HIGHLIGHT_COLOR': 'Default highlight color. The transparency is expected to only be applied to polygon\nfill. Lines and outlines are rendered opaque.', 'DEFAULT_HIGHLIGHT_BUFFER_MM': 'Default highlight buffer in mm.', 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': 'Default highlight line/stroke minimum width in mm.', 'SCALE_PRECISION': 'Fudge factor used to compare two scales. The code is often going from scale to scale\ndenominator. So it looses precision and, when a limit is inclusive, can lead to errors.\nTo avoid that, use this factor instead of using <= or >=.\n\n.. deprecated:: 3.40\n\n No longer used by QGIS and will be removed in QGIS 4.0.', 'DEFAULT_Z_COORDINATE': 'Default Z coordinate value.\nThis value have to be assigned to the Z coordinate for the vertex.', 'DEFAULT_M_COORDINATE': 'Default M coordinate value.\nThis value have to be assigned to the M coordinate for the vertex.\n\n.. versionadded:: 3.20', 'UI_SCALE_FACTOR': 'UI scaling factor. This should be applied to all widget sizes obtained from font metrics,\nto account for differences in the default font sizes across different platforms.', 'DEFAULT_SNAP_TOLERANCE': 'Default snapping distance tolerance.', 'DEFAULT_SNAP_UNITS': 'Default snapping distance units.'}
Qgis.__annotations__ = {'QGIS_DEV_VERSION': str, 'DEFAULT_SEARCH_RADIUS_MM': float, 'DEFAULT_MAPTOPIXEL_THRESHOLD': float, 'DEFAULT_HIGHLIGHT_COLOR': 'QColor', 'DEFAULT_HIGHLIGHT_BUFFER_MM': float, 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': float, 'SCALE_PRECISION': float, 'DEFAULT_Z_COORDINATE': float, 'DEFAULT_M_COORDINATE': float, 'UI_SCALE_FACTOR': float, 'DEFAULT_SNAP_TOLERANCE': float, 'DEFAULT_SNAP_UNITS': 'Qgis.MapToolUnit'}
Qgis.__attribute_docs__ = {'QGIS_DEV_VERSION': 'The development version', 'DEFAULT_SEARCH_RADIUS_MM': 'Identify search radius in mm', 'DEFAULT_MAPTOPIXEL_THRESHOLD': 'Default threshold between map coordinates and device coordinates for map2pixel simplification', 'DEFAULT_HIGHLIGHT_COLOR': 'Default highlight color. The transparency is expected to only be applied to polygon\nfill. Lines and outlines are rendered opaque.', 'DEFAULT_HIGHLIGHT_BUFFER_MM': 'Default highlight buffer in mm.', 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': 'Default highlight line/stroke minimum width in mm.', 'SCALE_PRECISION': 'Fudge factor used to compare two scales. The code is often going from scale to scale\ndenominator. So it looses precision and, when a limit is inclusive, can lead to errors.\nTo avoid that, use this factor instead of using <= or >=.\n\n.. deprecated:: 3.40\n\n No longer used by QGIS and will be removed in QGIS 4.0.', 'DEFAULT_Z_COORDINATE': 'Default Z coordinate value.\nThis value have to be assigned to the Z coordinate for the vertex.', 'DEFAULT_M_COORDINATE': 'Default M coordinate value.\nThis value have to be assigned to the M coordinate for the vertex.\n\n.. versionadded:: 3.20', 'UI_SCALE_FACTOR': 'UI scaling factor. This should be applied to all widget sizes obtained from font metrics,\nto account for differences in the default font sizes across different platforms.', 'DEFAULT_SNAP_TOLERANCE': 'Default snapping distance tolerance.', 'DEFAULT_SNAP_UNITS': 'Default snapping distance units.', 'USER_CRS_START_ID': 'Minimum ID number for a user-defined projection.', 'DEFAULT_POINT_SIZE': 'The default size (in millimeters) for point marker symbols', 'DEFAULT_LINE_WIDTH': 'The default width (in millimeters) for line symbols', 'DEFAULT_SEGMENT_EPSILON': 'Default snapping tolerance for segments'}
Qgis.__annotations__ = {'QGIS_DEV_VERSION': str, 'DEFAULT_SEARCH_RADIUS_MM': float, 'DEFAULT_MAPTOPIXEL_THRESHOLD': float, 'DEFAULT_HIGHLIGHT_COLOR': 'QColor', 'DEFAULT_HIGHLIGHT_BUFFER_MM': float, 'DEFAULT_HIGHLIGHT_MIN_WIDTH_MM': float, 'SCALE_PRECISION': float, 'DEFAULT_Z_COORDINATE': float, 'DEFAULT_M_COORDINATE': float, 'UI_SCALE_FACTOR': float, 'DEFAULT_SNAP_TOLERANCE': float, 'DEFAULT_SNAP_UNITS': 'Qgis.MapToolUnit', 'USER_CRS_START_ID': int, 'DEFAULT_POINT_SIZE': float, 'DEFAULT_LINE_WIDTH': float, 'DEFAULT_SEGMENT_EPSILON': float}
Qgis.version = staticmethod(Qgis.version)
Qgis.versionInt = staticmethod(Qgis.versionInt)
Qgis.releaseName = staticmethod(Qgis.releaseName)
@ -11348,5 +11348,9 @@ try:
Qgis.geosVersionMinor = staticmethod(Qgis.geosVersionMinor)
Qgis.geosVersionPatch = staticmethod(Qgis.geosVersionPatch)
Qgis.geosVersion = staticmethod(Qgis.geosVersion)
Qgis.geoNone = staticmethod(Qgis.geoNone)
Qgis.geographicCrsAuthId = staticmethod(Qgis.geographicCrsAuthId)
Qgis.geoWkt = staticmethod(Qgis.geoWkt)
Qgis.geoProj4 = staticmethod(Qgis.geoProj4)
except (NameError, AttributeError):
pass

View File

@ -870,7 +870,7 @@ Searches for the closest vertex in this geometry to the given point.
- atVertex: Receives index of the closest vertex
%End
double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint /Out/, int &nextVertexIndex /Out/, int *leftOrRightOfSegment /Out/ = 0, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint /Out/, int &nextVertexIndex /Out/, int *leftOrRightOfSegment /Out/ = 0, double epsilon = Qgis::DEFAULT_SEGMENT_EPSILON ) const;
%Docstring
Searches for the closest segment of geometry to the given point

View File

@ -3362,6 +3362,16 @@ The development version
static const Qgis::MapToolUnit DEFAULT_SNAP_UNITS;
static const int USER_CRS_START_ID;
static const double DEFAULT_POINT_SIZE;
static const double DEFAULT_LINE_WIDTH;
static const double DEFAULT_SEGMENT_EPSILON;
static QString defaultProjectScales();
%Docstring
A string with default project scales.
@ -3403,6 +3413,40 @@ GEOS string version linked
.. versionadded:: 3.20
%End
static QString geoNone();
%Docstring
Constant that holds the string representation for "No ellipse/No CRS".
.. versionadded:: 3.44
%End
static QString geographicCrsAuthId();
%Docstring
Geographic coordinate system auth:id string for a default geographic CRS
(EPSG:4326).
.. versionadded:: 3.44
%End
static QString geoWkt();
%Docstring
WKT string that represents a geographic coord system
.. deprecated:: 3.44
Will be removed in QGIS 4.0.
%End
static QString geoProj4();
%Docstring
PROJ4 string that represents a geographic coord system.
.. deprecated:: 3.44
Will be removed in QGIS 4.0.
%End
};
@ -3719,24 +3763,24 @@ bool operator< ( const QVariant &v1, const QVariant &v2 );
QString qgsVsiPrefix( const QString &path );
QString qgsVsiPrefix( const QString &path ) /Deprecated="Since 3.44. Use QgsGdalUtils.vsiPrefixForPath() instead."/;
%Docstring
Returns a the vsi prefix which corresponds to a file ``path``, or an
empty string if the path is not associated with a vsi prefix.
.. deprecated:: 3.44
Use :py:func:`QgsGdalUtils.vsiPrefixForPath()` instead.
%End
const long GEOSRID;
const long GEOSRID;
const long GEOCRS_ID;
const long GEOCRS_ID;
const long GEO_EPSG_CRS_ID;
const int USER_CRS_START_ID;
const double DEFAULT_POINT_SIZE;
const double DEFAULT_LINE_WIDTH;
const double DEFAULT_SEGMENT_EPSILON;
const long GEO_EPSG_CRS_ID;
typedef unsigned long long qgssize;
@ -3746,22 +3790,6 @@ typedef unsigned long long qgssize;
QString geoWkt();
%Docstring
Wkt string that represents a geographic coord sys \since QGIS GEOWkt
%End
//! PROJ4 string that represents a geographic coord sys
QString geoProj4();
//! Geographic coord sys from EPSG authority
QString geoEpsgCrsAuthId();
//! Constant that holds the string representation for "No ellips/No CRS"
QString geoNone();
/************************************************************************
* This file has been generated automatically from *
* *

View File

@ -174,7 +174,7 @@ Returns the distance between this point and another point.
.. seealso:: :py:func:`sqrDist`
%End
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint /Out/, double epsilon = DEFAULT_SEGMENT_EPSILON ) const /HoldGIL/;
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint /Out/, double epsilon = Qgis::DEFAULT_SEGMENT_EPSILON ) const /HoldGIL/;
%Docstring
Returns the minimum distance between this point and a segment
%End

View File

@ -562,11 +562,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
break;
}
QString myLayerDefaultCrs = mSettings->value( QStringLiteral( "/Projections/layerDefaultCrs" ), geoEpsgCrsAuthId() ).toString();
QString myLayerDefaultCrs = mSettings->value( QStringLiteral( "/Projections/layerDefaultCrs" ), Qgis::geographicCrsAuthId() ).toString();
mLayerDefaultCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( myLayerDefaultCrs );
leLayerGlobalCrs->setCrs( mLayerDefaultCrs );
const QString defaultProjectCrs = mSettings->value( QStringLiteral( "/projections/defaultProjectCrs" ), geoEpsgCrsAuthId(), QgsSettings::App ).toString();
const QString defaultProjectCrs = mSettings->value( QStringLiteral( "/projections/defaultProjectCrs" ), Qgis::geographicCrsAuthId(), QgsSettings::App ).toString();
leProjectGlobalCrs->setOptionVisible( QgsProjectionSelectionWidget::DefaultCrs, false );
leProjectGlobalCrs->setOptionVisible( QgsProjectionSelectionWidget::CrsNotSet, true );
leProjectGlobalCrs->setNotSetText( tr( "No projection (or unknown/non-Earth projection)" ) );

View File

@ -636,7 +636,7 @@ static void customSrsValidation_( QgsCoordinateReferenceSystem &srs )
return;
case QgsOptions::UnknownLayerCrsBehavior::UseDefaultCrs:
srs.createFromOgcWmsCrs( QgsSettings().value( QStringLiteral( "Projections/layerDefaultCrs" ), geoEpsgCrsAuthId() ).toString() );
srs.createFromOgcWmsCrs( QgsSettings().value( QStringLiteral( "Projections/layerDefaultCrs" ), Qgis::geographicCrsAuthId() ).toString() );
break;
case QgsOptions::UnknownLayerCrsBehavior::PromptUserForCrs:
@ -893,7 +893,7 @@ void QgisApp::validateCrs( QgsCoordinateReferenceSystem &srs )
case QgsOptions::UnknownLayerCrsBehavior::UseDefaultCrs:
{
srs.createFromOgcWmsCrs( QgsSettings().value( QStringLiteral( "Projections/layerDefaultCrs" ), geoEpsgCrsAuthId() ).toString() );
srs.createFromOgcWmsCrs( QgsSettings().value( QStringLiteral( "Projections/layerDefaultCrs" ), Qgis::geographicCrsAuthId() ).toString() );
sAuthId = srs.authid();
visibleMessageBar()->pushMessage( tr( "CRS was undefined" ), tr( "defaulting to CRS %1" ).arg( srs.userFriendlyIdentifier() ), Qgis::MessageLevel::Warning );
break;
@ -5812,12 +5812,12 @@ bool QgisApp::fileNew( bool promptToSaveFlag, bool forceBlank )
mScaleWidget->updateScales();
// set project CRS
const QgsCoordinateReferenceSystem srs = QgsCoordinateReferenceSystem( settings.value( QStringLiteral( "/projections/defaultProjectCrs" ), geoEpsgCrsAuthId(), QgsSettings::App ).toString() );
const QgsCoordinateReferenceSystem srs = QgsCoordinateReferenceSystem( settings.value( QStringLiteral( "/projections/defaultProjectCrs" ), Qgis::geographicCrsAuthId(), QgsSettings::App ).toString() );
// write the projections _proj string_ to project settings
const bool planimetric = settings.value( QStringLiteral( "measure/planimetric" ), true, QgsSettings::Core ).toBool();
prj->setCrs( srs, !planimetric ); // If the default ellipsoid is not planimetric, set it from the default crs
if ( planimetric )
prj->setEllipsoid( geoNone() );
prj->setEllipsoid( Qgis::geoNone() );
/* New Empty Project Created
(before attempting to load custom project templates/filepaths) */

View File

@ -116,7 +116,7 @@ void QgsMeasureDialog::projChanged()
{
if ( mCartesian->isChecked() )
{
mDa.setEllipsoid( geoNone() );
mDa.setEllipsoid( Qgis::geoNone() );
}
else
{
@ -169,7 +169,7 @@ void QgsMeasureDialog::updateSettings()
if ( mCartesian->isChecked() || !mCanvas->mapSettings().destinationCrs().isValid() || ( mCanvas->mapSettings().destinationCrs().mapUnits() == Qgis::DistanceUnit::Degrees && mDistanceUnits == Qgis::DistanceUnit::Degrees ) )
{
mDa.setEllipsoid( geoNone() );
mDa.setEllipsoid( Qgis::geoNone() );
}
else
{
@ -507,14 +507,14 @@ void QgsMeasureDialog::updateUi()
toolTip += "<br> * " + tr( "Units are unknown." );
mConvertToDisplayUnits = false;
}
mDa.setEllipsoid( geoNone() );
mDa.setEllipsoid( Qgis::geoNone() );
}
else if ( mCanvas->mapSettings().destinationCrs().mapUnits() == Qgis::DistanceUnit::Degrees
&& ( mAreaUnits == Qgis::AreaUnit::SquareDegrees || mAreaUnits == Qgis::AreaUnit::Unknown ) )
{
//both source and destination units are degrees
toolTip += "<br> * " + tr( "Both project CRS (%1) and measured area are in degrees, so area is calculated using Cartesian calculations in square degrees." ).arg( mCanvas->mapSettings().destinationCrs().userFriendlyIdentifier() );
mDa.setEllipsoid( geoNone() );
mDa.setEllipsoid( Qgis::geoNone() );
mConvertToDisplayUnits = false; //not required since we will be measuring in degrees
}
else
@ -578,14 +578,14 @@ void QgsMeasureDialog::updateUi()
toolTip += "<br> * " + tr( "Units are unknown." );
mConvertToDisplayUnits = false;
}
mDa.setEllipsoid( geoNone() );
mDa.setEllipsoid( Qgis::geoNone() );
}
else if ( mCanvas->mapSettings().destinationCrs().mapUnits() == Qgis::DistanceUnit::Degrees
&& mDistanceUnits == Qgis::DistanceUnit::Degrees )
{
//both source and destination units are degrees
toolTip += "<br> * " + tr( "Both project CRS (%1) and measured length are in degrees, so distance is calculated using Cartesian calculations in degrees." ).arg( mCanvas->mapSettings().destinationCrs().userFriendlyIdentifier() );
mDa.setEllipsoid( geoNone() );
mDa.setEllipsoid( Qgis::geoNone() );
mConvertToDisplayUnits = false; //not required since we will be measuring in degrees
}
else

View File

@ -2421,7 +2421,7 @@ void QgsProjectProperties::addWmtsGrid( const QString &crsStr )
{
// calculate top, left and scale based on CRS bounds
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( crsStr );
QgsCoordinateTransform crsTransform( QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() ), crs, QgsProject::instance() );
QgsCoordinateTransform crsTransform( QgsCoordinateReferenceSystem::fromOgcWmsCrs( Qgis::geographicCrsAuthId() ), crs, QgsProject::instance() );
crsTransform.setBallparkTransformsAreAppropriate( true );
try
{
@ -2490,7 +2490,7 @@ void QgsProjectProperties::populateEllipsoidList()
//
EllipsoidDefs myItem;
myItem.acronym = geoNone();
myItem.acronym = Qgis::geoNone();
myItem.description = tr( GEO_NONE_DESC );
myItem.semiMajor = 0.0;
myItem.semiMinor = 0.0;
@ -2563,7 +2563,7 @@ void QgsProjectProperties::updateEllipsoidUI( int newIndex )
leSemiMajor->setToolTip( tr( "Select %1 from pull-down menu to adjust radii" ).arg( tr( "Custom" ) ) );
leSemiMinor->setToolTip( tr( "Select %1 from pull-down menu to adjust radii" ).arg( tr( "Custom" ) ) );
}
if ( mEllipsoidList[mEllipsoidIndex].acronym != geoNone() )
if ( mEllipsoidList[mEllipsoidIndex].acronym != Qgis::geoNone() )
{
leSemiMajor->setText( QLocale().toString( myMajor, 'f', 3 ) );
leSemiMinor->setText( QLocale().toString( myMinor, 'f', 3 ) );

View File

@ -432,7 +432,7 @@ QgsDistanceArea *QgsExpression::geomCalculator()
{
// calculator IS required, so initialize it now...
d->mCalc = std::shared_ptr<QgsDistanceArea>( new QgsDistanceArea() );
d->mCalc->setEllipsoid( d->mDaEllipsoid.isEmpty() ? geoNone() : d->mDaEllipsoid );
d->mCalc->setEllipsoid( d->mDaEllipsoid.isEmpty() ? Qgis::geoNone() : d->mDaEllipsoid );
d->mCalc->setSourceCrs( *d->mDaCrs.get(), *d->mDaTransformContext.get() );
}

View File

@ -904,7 +904,7 @@ class CORE_EXPORT QgsGeometry
* \param epsilon epsilon for segment snapping
* \returns The squared Cartesian distance is also returned in sqrDist, negative number on error
*/
double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint SIP_OUT, int &nextVertexIndex SIP_OUT, int *leftOrRightOfSegment SIP_OUT = nullptr, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint SIP_OUT, int &nextVertexIndex SIP_OUT, int *leftOrRightOfSegment SIP_OUT = nullptr, double epsilon = Qgis::DEFAULT_SEGMENT_EPSILON ) const;
/**
* Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.

View File

@ -101,7 +101,7 @@ QgsPoint QgsGeometryUtils::closestPoint( const QgsAbstractGeometry &geometry, co
{
QgsPoint closestPoint;
QgsVertexId vertexAfter;
geometry.closestSegment( point, closestPoint, vertexAfter, nullptr, DEFAULT_SEGMENT_EPSILON );
geometry.closestSegment( point, closestPoint, vertexAfter, nullptr, Qgis::DEFAULT_SEGMENT_EPSILON );
if ( vertexAfter.isValid() )
{
const QgsPoint pointAfter = geometry.vertexAt( vertexAfter );

View File

@ -75,7 +75,7 @@ class CORE_EXPORT QgsMeshRendererMeshSettings
private:
bool mEnabled = false;
double mLineWidth = DEFAULT_LINE_WIDTH;
double mLineWidth = Qgis::DEFAULT_LINE_WIDTH;
Qgis::RenderUnit mLineWidthUnit = Qgis::RenderUnit::Millimeters;
QColor mColor = Qt::black;
};
@ -686,7 +686,7 @@ class CORE_EXPORT QgsMeshRendererVectorSettings
Symbology mDisplayingMethod = Arrows;
double mLineWidth = DEFAULT_LINE_WIDTH; //in millimeters
double mLineWidth = Qgis::DEFAULT_LINE_WIDTH; //in millimeters
QgsColorRampShader mColorRampShader;
QColor mColor = Qt::black;
QgsInterpolatedLineColor::ColoringMethod mColoringMethod = QgsInterpolatedLineColor::SingleColor;

View File

@ -640,7 +640,7 @@ bool QgsCoordinateReferenceSystem::createFromSrsId( const long id )
}
}
bool result = loadFromDatabase( id < USER_CRS_START_ID ? QgsApplication::srsDatabaseFilePath() :
bool result = loadFromDatabase( id < Qgis::USER_CRS_START_ID ? QgsApplication::srsDatabaseFilePath() :
QgsApplication::qgisUserDatabaseFilePath(),
QStringLiteral( "srs_id" ), QString::number( id ) );
@ -707,7 +707,7 @@ bool QgsCoordinateReferenceSystem::loadFromDatabase( const QString &db, const QS
wkt = statement.columnAsText( 8 );
d->mAxisInvertedDirty = true;
if ( d->mSrsId >= USER_CRS_START_ID && ( d->mAuthId.isEmpty() || d->mAuthId == QChar( ':' ) ) )
if ( d->mSrsId >= Qgis::USER_CRS_START_ID && ( d->mAuthId.isEmpty() || d->mAuthId == QChar( ':' ) ) )
{
d->mAuthId = QStringLiteral( "USER:%1" ).arg( d->mSrsId );
}
@ -1017,7 +1017,7 @@ bool QgsCoordinateReferenceSystem::createFromWktInternal( const QString &wkt, co
{
// lastly, try a tolerant match of the created proj object against all user CRSes (allowing differences in parameter order during the comparison)
long id = matchToUserCrs();
if ( id >= USER_CRS_START_ID )
if ( id >= Qgis::USER_CRS_START_ID )
{
createFromSrsId( id );
}
@ -1113,19 +1113,19 @@ bool QgsCoordinateReferenceSystem::createFromProj( const QString &projString, co
if ( !myRecord.empty() )
{
id = myRecord[QStringLiteral( "srs_id" )].toLong();
if ( id >= USER_CRS_START_ID )
if ( id >= Qgis::USER_CRS_START_ID )
{
createFromSrsId( id );
}
}
if ( id < USER_CRS_START_ID )
if ( id < Qgis::USER_CRS_START_ID )
{
// no direct matches, so go ahead and create a new proj object based on the proj string alone.
setProjString( myProj4String );
// lastly, try a tolerant match of the created proj object against all user CRSes (allowing differences in parameter order during the comparison)
id = matchToUserCrs();
if ( id >= USER_CRS_START_ID )
if ( id >= Qgis::USER_CRS_START_ID )
{
createFromSrsId( id );
}
@ -1673,7 +1673,7 @@ void QgsCoordinateReferenceSystem::updateDefinition()
if ( !d->mIsValid )
return;
if ( d->mSrsId >= USER_CRS_START_ID )
if ( d->mSrsId >= Qgis::USER_CRS_START_ID )
{
// user CRS, so update to new definition
createFromSrsId( d->mSrsId );
@ -2053,8 +2053,8 @@ bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSyste
if ( !qgsNanCompatibleEquals( d->mCoordinateEpoch, srs.d->mCoordinateEpoch ) )
return false;
const bool isUser = d->mSrsId >= USER_CRS_START_ID;
const bool otherIsUser = srs.d->mSrsId >= USER_CRS_START_ID;
const bool isUser = d->mSrsId >= Qgis::USER_CRS_START_ID;
const bool otherIsUser = srs.d->mSrsId >= Qgis::USER_CRS_START_ID;
if ( isUser != otherIsUser )
return false;
@ -2135,7 +2135,7 @@ bool QgsCoordinateReferenceSystem::readXml( const QDomNode &node )
QDomNode node;
if ( ok && srsid > 0 && srsid < USER_CRS_START_ID )
if ( ok && srsid > 0 && srsid < Qgis::USER_CRS_START_ID )
{
node = srsNode.namedItem( QStringLiteral( "authid" ) );
if ( !node.isNull() )
@ -2316,7 +2316,7 @@ QString QgsCoordinateReferenceSystem::projFromSrsId( const int srsId )
// Determine if this is a user projection or a system on
// user projection defs all have srs_id >= 100000
//
if ( srsId >= USER_CRS_START_ID )
if ( srsId >= Qgis::USER_CRS_START_ID )
{
myDatabaseFileName = QgsApplication::qgisUserDatabaseFilePath();
QFileInfo myFileInfo;
@ -2603,7 +2603,7 @@ QList<long> QgsCoordinateReferenceSystem::userSrsIds()
return results;
}
QString sql = QStringLiteral( "select srs_id from tbl_srs where srs_id >= %1" ).arg( USER_CRS_START_ID );
QString sql = QStringLiteral( "select srs_id from tbl_srs where srs_id >= %1" ).arg( Qgis::USER_CRS_START_ID );
int rc;
statement = database.prepare( sql, rc );
while ( true )
@ -3442,8 +3442,8 @@ bool operator> ( const QgsCoordinateReferenceSystem &c1, const QgsCoordinateRefe
if ( c1.d->mIsValid && !c2.d->mIsValid )
return true;
const bool c1IsUser = c1.d->mSrsId >= USER_CRS_START_ID;
const bool c2IsUser = c2.d->mSrsId >= USER_CRS_START_ID;
const bool c1IsUser = c1.d->mSrsId >= Qgis::USER_CRS_START_ID;
const bool c2IsUser = c2.d->mSrsId >= Qgis::USER_CRS_START_ID;
if ( c1IsUser && !c2IsUser )
return true;
@ -3491,8 +3491,8 @@ bool operator< ( const QgsCoordinateReferenceSystem &c1, const QgsCoordinateRefe
if ( !c1.d->mIsValid && c2.d->mIsValid )
return true;
const bool c1IsUser = c1.d->mSrsId >= USER_CRS_START_ID;
const bool c2IsUser = c2.d->mSrsId >= USER_CRS_START_ID;
const bool c1IsUser = c1.d->mSrsId >= Qgis::USER_CRS_START_ID;
const bool c2IsUser = c2.d->mSrsId >= Qgis::USER_CRS_START_ID;
if ( !c1IsUser && c2IsUser )
return true;

View File

@ -110,7 +110,7 @@ long QgsCoordinateReferenceSystemRegistry::addUserCrs( const QgsCoordinateRefere
if ( QgsCoordinateReferenceSystem::getRecordCount() == 0 )
{
mySql = "insert into tbl_srs (srs_id,description,projection_acronym,ellipsoid_acronym,parameters,is_geo,wkt) values ("
+ QString::number( USER_CRS_START_ID )
+ QString::number( Qgis::USER_CRS_START_ID )
+ ',' + QgsSqliteUtils::quotedString( name )
+ ',' + ( !crs.d->mProjectionAcronym.isEmpty() ? QgsSqliteUtils::quotedString( crs.d->mProjectionAcronym ) : QStringLiteral( "''" ) )
+ ',' + quotedEllipsoidString

View File

@ -985,9 +985,9 @@ QString QgsProject::ellipsoid() const
QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL
if ( !crs().isValid() )
return geoNone();
return Qgis::geoNone();
return readEntry( QStringLiteral( "Measure" ), QStringLiteral( "/Ellipsoid" ), geoNone() );
return readEntry( QStringLiteral( "Measure" ), QStringLiteral( "/Ellipsoid" ), Qgis::geoNone() );
}
void QgsProject::setEllipsoid( const QString &ellipsoid )
@ -4956,7 +4956,7 @@ QgsCoordinateReferenceSystem QgsProject::defaultCrsForNewLayers() const
else
{
// global crs
const QString layerDefaultCrs = mSettings.value( QStringLiteral( "/Projections/layerDefaultCrs" ), geoEpsgCrsAuthId() ).toString();
const QString layerDefaultCrs = mSettings.value( QStringLiteral( "/Projections/layerDefaultCrs" ), QStringLiteral( "EPSG:4326" ) ).toString();
defaultCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( layerDefaultCrs );
}

View File

@ -578,7 +578,7 @@ class CORE_EXPORT QgsDataProvider : public QObject
double lastRenderingTimeMs = -1;
//! Default maximum allowable render time, in ms
double maxRenderingTimeMs = MAXIMUM_LAYER_PREVIEW_TIME_MS;
double maxRenderingTimeMs = Qgis::MAXIMUM_LAYER_PREVIEW_TIME_MS;
};
#endif

View File

@ -64,6 +64,14 @@ const double Qgis::DEFAULT_SNAP_TOLERANCE = 12.0;
const Qgis::MapToolUnit Qgis::DEFAULT_SNAP_UNITS = Qgis::MapToolUnit::Pixels;
const int Qgis::USER_CRS_START_ID = 100000;
const double Qgis::DEFAULT_POINT_SIZE = 2.0;
const double Qgis::DEFAULT_LINE_WIDTH = 0.26;
const double Qgis::DEFAULT_SEGMENT_EPSILON = 1e-8;
const int Qgis::PREVIEW_JOB_DELAY_MS = 250;
const int Qgis::MAXIMUM_LAYER_PREVIEW_TIME_MS = 250;
#ifdef Q_OS_WIN
const double Qgis::UI_SCALE_FACTOR = 1.5;
#else

View File

@ -5941,6 +5941,26 @@ class CORE_EXPORT Qgis
*/
static const Qgis::MapToolUnit DEFAULT_SNAP_UNITS;
/**
* Minimum ID number for a user-defined projection.
*/
static const int USER_CRS_START_ID;
//! The default size (in millimeters) for point marker symbols
static const double DEFAULT_POINT_SIZE;
//! The default width (in millimeters) for line symbols
static const double DEFAULT_LINE_WIDTH;
//! Default snapping tolerance for segments
static const double DEFAULT_SEGMENT_EPSILON;
//! Delay between the scheduling of 2 preview jobs
SIP_SKIP static const int PREVIEW_JOB_DELAY_MS;
//! Maximum rendering time for a layer of a preview job
SIP_SKIP static const int MAXIMUM_LAYER_PREVIEW_TIME_MS;
/**
* A string with default project scales.
*
@ -5982,6 +6002,47 @@ class CORE_EXPORT Qgis
* \since QGIS 3.20
*/
static QString geosVersion();
/**
* Constant that holds the string representation for "No ellipse/No CRS".
*
* \since QGIS 3.44
*/
static QString geoNone()
{
return QStringLiteral( "NONE" );
}
/**
* Geographic coordinate system auth:id string for a default geographic CRS (EPSG:4326).
*
* \since QGIS 3.44
*/
static QString geographicCrsAuthId()
{
return QStringLiteral( "EPSG:4326" );
}
/**
* WKT string that represents a geographic coord system
* \deprecated QGIS 3.44. Will be removed in QGIS 4.0.
*/
Q_DECL_DEPRECATED static QString geoWkt()
{
return QStringLiteral(
R"""(GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]] )"""
);
}
/**
* PROJ4 string that represents a geographic coord system.
* \deprecated QGIS 3.44. Will be removed in QGIS 4.0.
*/
Q_DECL_DEPRECATED static QString geoProj4()
{
return QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" );
}
};
QHASH_FOR_CLASS_ENUM( Qgis::CaptureTechnique )
@ -6638,7 +6699,13 @@ inline bool operator< ( const QVariant &v1, const QVariant &v2 )
template<> CORE_EXPORT bool qMapLessThanKey<QVariantList>( const QVariantList &key1, const QVariantList &key2 ) SIP_SKIP;
#endif
CORE_EXPORT QString qgsVsiPrefix( const QString &path );
/**
* Returns a the vsi prefix which corresponds to a file \a path, or an empty
* string if the path is not associated with a vsi prefix.
*
* \deprecated QGIS 3.44. Use QgsGdalUtils::vsiPrefixForPath() instead.
*/
Q_DECL_DEPRECATED CORE_EXPORT QString qgsVsiPrefix( const QString &path ) SIP_DEPRECATED;
/**
* Allocates size bytes and returns a pointer to the allocated memory.
@ -6655,12 +6722,6 @@ void CORE_EXPORT qgsFree( void *ptr ) SIP_SKIP;
#ifndef SIP_RUN
#ifdef _MSC_VER
#define CONSTLATIN1STRING inline const QLatin1String
#else
#define CONSTLATIN1STRING constexpr QLatin1String
#endif
///@cond PRIVATE
class ScopedIntIncrementor
{
@ -6693,72 +6754,28 @@ class ScopedIntIncrementor
};
///@endcond
/**
* Wkt string that represents a geographic coord sys
* \since QGIS GEOWkt
*/
CONSTLATIN1STRING geoWkt()
{
return QLatin1String(
R"""(GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]] )"""
);
}
//! PROJ4 string that represents a geographic coord sys
CONSTLATIN1STRING geoProj4()
{
return QLatin1String( "+proj=longlat +datum=WGS84 +no_defs" );
}
//! Geographic coord sys from EPSG authority
CONSTLATIN1STRING geoEpsgCrsAuthId()
{
return QLatin1String( "EPSG:4326" );
}
//! Constant that holds the string representation for "No ellips/No CRS"
CONSTLATIN1STRING geoNone()
{
return QLatin1String( "NONE" );
}
///@cond PRIVATE
//! Delay between the scheduling of 2 preview jobs
const int PREVIEW_JOB_DELAY_MS = 250;
//! Maximum rendering time for a layer of a preview job
const int MAXIMUM_LAYER_PREVIEW_TIME_MS = 250;
///@endcond
#endif
//! Magic number for a geographic coord sys in POSTGIS SRID
const long GEOSRID = 4326;
//! Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id
const long GEOCRS_ID = 3452;
//! Magic number for a geographic coord sys in EpsgCrsId ID format
const long GEO_EPSG_CRS_ID = 4326;
/**
* Numeric ID for the EPSG:4326 geographic coordinate system.
*
* \deprecated QGIS 3.44. Will be removed in QGIS 4.0.
*/
Q_DECL_DEPRECATED const long GEOSRID = 4326;
/**
* Magick number that determines whether a projection crsid is a system (srs.db)
* or user (~/.qgis.qgis.db) defined projection.
*/
const int USER_CRS_START_ID = 100000;
* Numeric ID for the EPSG:4326 geographic coordinate system in QGIS internal srs database.
*
* \deprecated QGIS 3.44. Will be removed in QGIS 4.0.
*/
Q_DECL_DEPRECATED const long GEOCRS_ID = 3452;
//
// Constants for point symbols
//
//! Magic number that determines the default point size for point symbols
const double DEFAULT_POINT_SIZE = 2.0;
const double DEFAULT_LINE_WIDTH = 0.26;
//! Default snapping tolerance for segments
const double DEFAULT_SEGMENT_EPSILON = 1e-8;
/**
* Numeric ID for the EPSG:4326 geographic coordinate system.
*
* \deprecated QGIS 3.44. Will be removed in QGIS 4.0.
*/
Q_DECL_DEPRECATED const long GEO_EPSG_CRS_ID = 4326;
typedef QMap<QString, QString> QgsStringMap SIP_SKIP;
@ -6879,22 +6896,3 @@ typedef unsigned long long qgssize;
#define BUILTIN_UNREACHABLE
#endif
#endif // SIP_RUN
#ifdef SIP_RUN
/**
* Wkt string that represents a geographic coord sys
* \since QGIS GEOWkt
*/
QString CORE_EXPORT geoWkt();
//! PROJ4 string that represents a geographic coord sys
QString CORE_EXPORT geoProj4();
//! Geographic coord sys from EPSG authority
QString CORE_EXPORT geoEpsgCrsAuthId();
//! Constant that holds the string representation for "No ellips/No CRS"
QString CORE_EXPORT geoNone();
#endif

View File

@ -49,7 +49,7 @@ QgsDistanceArea::QgsDistanceArea()
mInvFlattening = -1.0;
const QgsCoordinateTransformContext context; // this is ok - by default we have a source/dest of WGS84, so no reprojection takes place
setSourceCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), context ); // WGS 84
setEllipsoid( geoNone() );
setEllipsoid( Qgis::geoNone() );
}
QgsDistanceArea::~QgsDistanceArea() = default;
@ -77,7 +77,7 @@ QgsDistanceArea &QgsDistanceArea::operator=( const QgsDistanceArea &other )
bool QgsDistanceArea::willUseEllipsoid() const
{
return mEllipsoid != geoNone();
return mEllipsoid != Qgis::geoNone();
}
void QgsDistanceArea::setSourceCrs( const QgsCoordinateReferenceSystem &srcCRS, const QgsCoordinateTransformContext &context )
@ -89,9 +89,9 @@ void QgsDistanceArea::setSourceCrs( const QgsCoordinateReferenceSystem &srcCRS,
bool QgsDistanceArea::setEllipsoid( const QString &ellipsoid )
{
// Shortcut if ellipsoid is none.
if ( ellipsoid == geoNone() )
if ( ellipsoid == Qgis::geoNone() )
{
mEllipsoid = geoNone();
mEllipsoid = Qgis::geoNone();
mGeod.reset();
return true;
}
@ -462,7 +462,7 @@ double QgsDistanceArea::latitudeGeodesicCrossesAntimeridian( const QgsPointXY &p
double lat = p2y;
double lon = p2x;
if ( mEllipsoid == geoNone() )
if ( mEllipsoid == Qgis::geoNone() )
{
fractionAlongLine = ( 180 - p1x ) / ( p2x - p1x );
if ( p1.x() >= 180 )
@ -861,7 +861,7 @@ double QgsDistanceArea::bearing( const QgsPointXY &p1, const QgsPointXY &p2 ) co
void QgsDistanceArea::computeAreaInit() const
{
//don't try to perform calculations if no ellipsoid
if ( mEllipsoid == geoNone() )
if ( mEllipsoid == Qgis::geoNone() )
{
mGeod.reset();
return;

View File

@ -3015,7 +3015,7 @@ QgsRectangle QgsMapLayer::wgs84Extent( bool forceRecalculate ) const
}
else if ( ! mExtent2D.isNull() || ! mExtent3D.isNull() )
{
QgsCoordinateTransform transformer { crs(), QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() ), transformContext() };
QgsCoordinateTransform transformer { crs(), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), transformContext() };
transformer.setBallparkTransformsAreAppropriate( true );
try
{

View File

@ -219,7 +219,7 @@ class CORE_EXPORT QgsPointXY
}
//! Returns the minimum distance between this point and a segment
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint SIP_OUT, double epsilon = DEFAULT_SEGMENT_EPSILON ) const SIP_HOLDGIL;
double sqrDistToSegment( double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint SIP_OUT, double epsilon = Qgis::DEFAULT_SEGMENT_EPSILON ) const SIP_HOLDGIL;
//! Calculates azimuth between this point and other one (clockwise in degree, starting from north)
double azimuth( const QgsPointXY &other ) const SIP_HOLDGIL;

View File

@ -24,7 +24,7 @@
#define DEFAULT_SIMPLEFILL_STYLE Qt::SolidPattern
#define DEFAULT_SIMPLEFILL_BORDERCOLOR QColor( 35, 35, 35 )
#define DEFAULT_SIMPLEFILL_BORDERSTYLE Qt::SolidLine
#define DEFAULT_SIMPLEFILL_BORDERWIDTH DEFAULT_LINE_WIDTH
#define DEFAULT_SIMPLEFILL_BORDERWIDTH Qgis::DEFAULT_LINE_WIDTH
#define DEFAULT_SIMPLEFILL_JOINSTYLE Qt::BevelJoin
#define INF 1E20

View File

@ -177,11 +177,11 @@ class CORE_EXPORT QgsInterpolatedLineWidth
private:
bool mIsWidthVariable = false;
double mFixedWidth = DEFAULT_LINE_WIDTH;
double mFixedWidth = Qgis::DEFAULT_LINE_WIDTH;
double mMinimumValue = 0;
double mMaximumValue = 10;
double mMinimumWidth = DEFAULT_LINE_WIDTH;
double mMinimumWidth = Qgis::DEFAULT_LINE_WIDTH;
double mMaximumWidth = 3;
bool mIgnoreOutOfRange = false;
bool mUseAbsoluteValue = false;

View File

@ -31,7 +31,7 @@ class QgsColorRamp;
class QgsFillSymbol;
#define DEFAULT_SIMPLELINE_COLOR QColor(35,35,35)
#define DEFAULT_SIMPLELINE_WIDTH DEFAULT_LINE_WIDTH
#define DEFAULT_SIMPLELINE_WIDTH Qgis::DEFAULT_LINE_WIDTH
#define DEFAULT_SIMPLELINE_PENSTYLE Qt::SolidLine
#define DEFAULT_SIMPLELINE_JOINSTYLE Qt::BevelJoin
#define DEFAULT_SIMPLELINE_CAPSTYLE Qt::SquareCap

View File

@ -24,7 +24,7 @@
#define DEFAULT_SIMPLEMARKER_COLOR QColor(255,0,0)
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR QColor( 35, 35, 35 )
#define DEFAULT_SIMPLEMARKER_JOINSTYLE Qt::BevelJoin
#define DEFAULT_SIMPLEMARKER_SIZE DEFAULT_POINT_SIZE
#define DEFAULT_SIMPLEMARKER_SIZE Qgis::DEFAULT_POINT_SIZE
#define DEFAULT_SIMPLEMARKER_ANGLE 0
#include <QPen>
@ -485,7 +485,7 @@ class CORE_EXPORT QgsFilledMarkerSymbolLayer : public QgsSimpleMarkerSymbolLayer
//////////
#define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE
#define DEFAULT_SVGMARKER_SIZE 2*Qgis::DEFAULT_POINT_SIZE
#define DEFAULT_SVGMARKER_ANGLE 0
/**
@ -672,7 +672,7 @@ class CORE_EXPORT QgsSvgMarkerSymbolLayer : public QgsMarkerSymbolLayer
//////////
#define DEFAULT_RASTERMARKER_SIZE 2*DEFAULT_POINT_SIZE
#define DEFAULT_RASTERMARKER_SIZE 2*Qgis::DEFAULT_POINT_SIZE
#define DEFAULT_RASTERMARKER_ANGLE 0
/**

View File

@ -438,15 +438,15 @@ QList<QgsVectorTileBasicRendererStyle> QgsVectorTileBasicRenderer::simpleStyleWi
QColor polygonFillColor = QgsApplication::colorSchemeRegistry()->fetchRandomStyleColor();
QColor polygonStrokeColor = polygonFillColor;
polygonFillColor.setAlpha( 100 );
double polygonStrokeWidth = DEFAULT_LINE_WIDTH;
double polygonStrokeWidth = Qgis::DEFAULT_LINE_WIDTH;
QColor lineStrokeColor = QgsApplication::colorSchemeRegistry()->fetchRandomStyleColor();
double lineStrokeWidth = DEFAULT_LINE_WIDTH;
double lineStrokeWidth = Qgis::DEFAULT_LINE_WIDTH;
QColor pointFillColor = QgsApplication::colorSchemeRegistry()->fetchRandomStyleColor();
QColor pointStrokeColor = pointFillColor;
pointFillColor.setAlpha( 100 );
double pointSize = DEFAULT_POINT_SIZE;
double pointSize = Qgis::DEFAULT_POINT_SIZE;
return simpleStyle( polygonFillColor, polygonStrokeColor, polygonStrokeWidth,
lineStrokeColor, lineStrokeWidth,

View File

@ -932,7 +932,7 @@ QMap<QString, QString> QgsMapToolIdentify::featureDerivedAttributes( const QgsFe
}
QString str;
if ( ellipsoid != geoNone() )
if ( ellipsoid != Qgis::geoNone() )
{
str = formatDistance( dist );
derivedAttributes.insert( tr( "Length (Ellipsoidal — %1)" ).arg( ellipsoid ), str );
@ -996,7 +996,7 @@ QMap<QString, QString> QgsMapToolIdentify::featureDerivedAttributes( const QgsFe
}
QString str;
if ( ellipsoid != geoNone() )
if ( ellipsoid != Qgis::geoNone() )
{
str = formatArea( area );
derivedAttributes.insert( tr( "Area (Ellipsoidal — %1)" ).arg( ellipsoid ), str );
@ -1004,7 +1004,7 @@ QMap<QString, QString> QgsMapToolIdentify::featureDerivedAttributes( const QgsFe
str = formatArea( layerCrsGeometry.area() * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::distanceToAreaUnit( layer->crs().mapUnits() ), cartesianAreaUnits ), cartesianAreaUnits );
derivedAttributes.insert( tr( "Area (Cartesian)" ), str );
if ( ellipsoid != geoNone() )
if ( ellipsoid != Qgis::geoNone() )
{
double perimeter = 0;
try

View File

@ -41,7 +41,7 @@ StandardCoordinateReferenceSystemsModel::StandardCoordinateReferenceSystemsModel
#endif
const QgsSettings settings;
mDefaultCrs = QgsCoordinateReferenceSystem( settings.value( QStringLiteral( "/projections/defaultProjectCrs" ), geoEpsgCrsAuthId(), QgsSettings::App ).toString() );
mDefaultCrs = QgsCoordinateReferenceSystem( settings.value( QStringLiteral( "/projections/defaultProjectCrs" ), Qgis::geographicCrsAuthId(), QgsSettings::App ).toString() );
connect( QgsApplication::coordinateReferenceSystemRegistry(), &QgsCoordinateReferenceSystemRegistry::userCrsChanged, this, [=] {
mCurrentCrs.updateDefinition();

View File

@ -3568,7 +3568,7 @@ void QgsMapCanvas::startPreviewJob( int number )
const QList<QgsMapLayer *> layers = jobSettings.layers();
QList<QgsMapLayer *> previewLayers;
QgsDataProvider::PreviewContext context;
context.maxRenderingTimeMs = MAXIMUM_LAYER_PREVIEW_TIME_MS;
context.maxRenderingTimeMs = Qgis::MAXIMUM_LAYER_PREVIEW_TIME_MS;
for ( QgsMapLayer *layer : layers )
{
if ( layer->customProperty( QStringLiteral( "rendering/noPreviewJobs" ), false ).toBool() )
@ -3618,7 +3618,7 @@ void QgsMapCanvas::stopPreviewJobs()
void QgsMapCanvas::schedulePreviewJob( int number )
{
mPreviewTimer.setSingleShot( true );
mPreviewTimer.setInterval( PREVIEW_JOB_DELAY_MS );
mPreviewTimer.setInterval( Qgis::PREVIEW_JOB_DELAY_MS );
disconnect( mPreviewTimerConnection );
mPreviewTimerConnection = connect( &mPreviewTimer, &QTimer::timeout, this, [=]() {
startPreviewJob( number );

View File

@ -458,7 +458,7 @@ void QgsOWSSourceSelect::populateCrs()
defaultCRS = *it;
// prefer value of DEFAULT_GEO_EPSG_CRS_ID if available
if ( *it == geoEpsgCrsAuthId() )
if ( *it == Qgis::geographicCrsAuthId() )
defaultCRS = *it;
}

View File

@ -708,7 +708,7 @@ void QgsGrassNewMapset::setSelectedRegion()
// Convert to currently selected coordinate system
// Warning: seems that crashes if source == dest
if ( mProjectionSelector->crs().srsid() != GEOCRS_ID )
if ( mProjectionSelector->crs().srsid() != 3452 )
{
const QgsCoordinateReferenceSystem source( QStringLiteral( "EPSG:4326" ) );
if ( !source.isValid() )
@ -866,7 +866,7 @@ void QgsGrassNewMapset::drawRegion()
points << points[0]; // close polygon
// Warning: seems that crashes if source == dest
if ( mProjectionSelector->crs().srsid() != GEOCRS_ID )
if ( mProjectionSelector->crs().srsid() != 3452 )
{
QgsCoordinateReferenceSystem source = mProjectionSelector->crs();
@ -876,7 +876,7 @@ void QgsGrassNewMapset::drawRegion()
return;
}
QgsCoordinateReferenceSystem dest = QgsCoordinateReferenceSystem::fromSrsId( GEOCRS_ID );
QgsCoordinateReferenceSystem dest = QgsCoordinateReferenceSystem::fromSrsId( 3452 );
if ( !dest.isValid() )
{

View File

@ -57,7 +57,7 @@
QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode theWidgetMode )
: QgsAbstractDataSourceWidget( parent, fl, theWidgetMode )
, mDefaultCRS( geoEpsgCrsAuthId() )
, mDefaultCRS( Qgis::geographicCrsAuthId() )
{
setupUi( this );
QgsGui::enableAutoGeometryRestore( this );

View File

@ -73,7 +73,7 @@ namespace QgsWcs
//lonLatEnvelope
const QgsCoordinateReferenceSystem layerCrs = layer->crs();
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() );
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( Qgis::geographicCrsAuthId() );
const int wgs84precision = 6;
const QgsCoordinateTransform t( layerCrs, wgs84, project );
//transform

View File

@ -554,7 +554,7 @@ namespace QgsWfs
//create WGS84BoundingBox
const QgsRectangle layerExtent = layer->extent();
//transform the layers native CRS into WGS84
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() );
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( Qgis::geographicCrsAuthId() );
const int wgs84precision = 6;
QgsRectangle wgs84BoundingRect( 0, 0, 0, 0 );
if ( !layerExtent.isNull() )

View File

@ -840,7 +840,7 @@ namespace QgsWms
if ( !wmsExtent.isEmpty() )
{
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() );
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( Qgis::geographicCrsAuthId() );
// Get WMS WGS84 bounding rectangle
QgsRectangle wmsWgs84BoundingRect;

View File

@ -152,7 +152,7 @@ QMap<QString, QgsWmsLayerInfos> QgsWmsLayerInfos::buildWmsLayerInfos(
bool useLayerIds = QgsServerProjectUtils::wmsUseLayerIds( *project );
const QStringList restrictedLayers = QgsServerProjectUtils::wmsRestrictedLayers( *project );
const QgsRectangle wmsExtent = QgsServerProjectUtils::wmsExtent( *project );
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() );
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( Qgis::geographicCrsAuthId() );
for ( QgsMapLayer *ml : project->mapLayers() )
{

View File

@ -1529,7 +1529,7 @@ namespace QgsWms
context.setMapToPixel( QgsMapToPixel( 1 / ( mmPerMapUnit * context.scaleFactor() ) ) );
QgsDistanceArea distanceArea = QgsDistanceArea();
distanceArea.setSourceCrs( QgsCoordinateReferenceSystem( mWmsParameters.crs() ), mProject->transformContext() );
distanceArea.setEllipsoid( geoNone() );
distanceArea.setEllipsoid( Qgis::geoNone() );
context.setDistanceArea( distanceArea );
return context;
}

View File

@ -322,7 +322,7 @@ namespace QgsWmts
{
void appendLayerElements( QDomDocument &doc, QDomElement &contentsElement, QList<layerDef> wmtsLayers, QList<tileMatrixSetDef> tmsList, const QgsProject *project )
{
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() );
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( Qgis::geographicCrsAuthId() );
// Define InfoFormat helper
const std::function<void( QDomElement &, const QString & )> appendInfoFormat = [&doc]( QDomElement &elem, const QString &format ) {
QDomElement formatElem = doc.createElement( QStringLiteral( "InfoFormat" ) /*wmts:InfoFormat*/ );

View File

@ -35,7 +35,7 @@ namespace QgsWmts
{
QMap<QString, tileMatrixInfo> populateFixedTileMatrixInfoMap();
QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() );
QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( Qgis::geographicCrsAuthId() );
// Constant
const int tileSize = 256;
@ -289,7 +289,7 @@ namespace QgsWmts
tmi.unit = crs.mapUnits();
tmi.hasAxisInverted = crs.hasAxisInverted();
const QgsCoordinateTransform crsTransform( QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() ), crs, project );
const QgsCoordinateTransform crsTransform( QgsCoordinateReferenceSystem::fromOgcWmsCrs( Qgis::geographicCrsAuthId() ), crs, project );
try
{
// firstly transform CRS bounds expressed in WGS84 to CRS

View File

@ -126,6 +126,9 @@ class TestQgsCoordinateReferenceSystem : public QObject
QStringList myTOWGS84Strings;
QStringList myAuthIdStrings;
QString mTempFolder;
const QString mWgs84Wkt = R"""(GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]] )""";
QString testESRIWkt( int i, QgsCoordinateReferenceSystem &crs );
static bool sValidateCalled;
@ -172,7 +175,6 @@ void TestQgsCoordinateReferenceSystem::initTestCase()
QgsDebugMsgLevel( QStringLiteral( "Custom srs database: %1" ).arg( QgsApplication::qgisUserDatabaseFilePath() ), 1 );
qDebug() << "geoProj4() constant: " << geoProj4();
qDebug() << "GDAL version (build): " << GDAL_RELEASE_NAME;
qDebug() << "GDAL version (runtime): " << GDALVersionInfo( "RELEASE_NAME" );
const PJ_INFO info = proj_info();
@ -193,8 +195,7 @@ void TestQgsCoordinateReferenceSystem::cleanupTestCase()
void TestQgsCoordinateReferenceSystem::wktCtor()
{
const QString myWkt = geoWkt();
QgsCoordinateReferenceSystem myCrs( myWkt );
QgsCoordinateReferenceSystem myCrs( mWgs84Wkt );
debugPrint( myCrs );
QVERIFY( myCrs.isValid() );
@ -205,7 +206,7 @@ void TestQgsCoordinateReferenceSystem::wktCtor()
void TestQgsCoordinateReferenceSystem::idCtor()
{
Q_NOWARN_DEPRECATED_PUSH
const QgsCoordinateReferenceSystem myCrs( GEOSRID, QgsCoordinateReferenceSystem::EpsgCrsId );
const QgsCoordinateReferenceSystem myCrs( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
Q_NOWARN_DEPRECATED_POP
QVERIFY( myCrs.isValid() );
@ -478,19 +479,19 @@ void TestQgsCoordinateReferenceSystem::createFromId()
{
QgsCoordinateReferenceSystem myCrs;
Q_NOWARN_DEPRECATED_PUSH
myCrs.createFromId( GEO_EPSG_CRS_ID, QgsCoordinateReferenceSystem::EpsgCrsId );
myCrs.createFromId( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
Q_NOWARN_DEPRECATED_POP
debugPrint( myCrs );
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
QCOMPARE( myCrs.srsid(), 3452 );
QCOMPARE( myCrs.ellipsoidAcronym(), QStringLiteral( "EPSG:7030" ) );
}
void TestQgsCoordinateReferenceSystem::fromEpsgId()
{
QgsCoordinateReferenceSystem myCrs = QgsCoordinateReferenceSystem::fromEpsgId( GEO_EPSG_CRS_ID );
QgsCoordinateReferenceSystem myCrs = QgsCoordinateReferenceSystem::fromEpsgId( 4326 );
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
QCOMPARE( myCrs.srsid(), 3452 );
myCrs = QgsCoordinateReferenceSystem::fromEpsgId( -999 );
QVERIFY( !myCrs.isValid() );
@ -572,11 +573,11 @@ void TestQgsCoordinateReferenceSystem::createFromSrid()
{
QgsCoordinateReferenceSystem myCrs;
Q_NOWARN_DEPRECATED_PUSH
myCrs.createFromSrid( GEOSRID );
myCrs.createFromSrid( 4326 );
Q_NOWARN_DEPRECATED_POP
debugPrint( myCrs );
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
QCOMPARE( myCrs.srsid(), 3452 );
QCOMPARE( myCrs.ellipsoidAcronym(), QStringLiteral( "EPSG:7030" ) );
}
@ -615,10 +616,10 @@ void TestQgsCoordinateReferenceSystem::sridCache()
void TestQgsCoordinateReferenceSystem::createFromWkt()
{
QgsCoordinateReferenceSystem myCrs;
myCrs.createFromWkt( geoWkt() );
myCrs.createFromWkt( mWgs84Wkt );
debugPrint( myCrs );
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
QCOMPARE( myCrs.srsid(), 3452 );
QCOMPARE( myCrs.ellipsoidAcronym(), QStringLiteral( "EPSG:7030" ) );
}
@ -694,7 +695,7 @@ void TestQgsCoordinateReferenceSystem::createFromWktUnknown()
crs.saveAsUserCrs( QStringLiteral( "Test CRS" ) );
QgsDebugMsgLevel( crs.toWkt( Qgis::CrsWktVariant::Preferred ), 1 );
QCOMPARE( crs.toWkt( Qgis::CrsWktVariant::Preferred ), expectedWkt );
QCOMPARE( crs.srsid(), static_cast<long>( USER_CRS_START_ID + 1 ) );
QCOMPARE( crs.srsid(), static_cast<long>( Qgis::USER_CRS_START_ID + 1 ) );
QCOMPARE( crs.authid(), QStringLiteral( "USER:100001" ) );
QCOMPARE( crs.mapUnits(), Qgis::DistanceUnit::Meters );
QCOMPARE( crs.ellipsoidAcronym().left( 30 ), QStringLiteral( "PARAMETER:6378388:6356911.9461" ) );
@ -741,9 +742,9 @@ void TestQgsCoordinateReferenceSystem::createFromWktUnknown()
void TestQgsCoordinateReferenceSystem::fromWkt()
{
QgsCoordinateReferenceSystem myCrs = QgsCoordinateReferenceSystem::fromWkt( geoWkt() );
QgsCoordinateReferenceSystem myCrs = QgsCoordinateReferenceSystem::fromWkt( mWgs84Wkt );
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
QCOMPARE( myCrs.srsid(), 3452 );
myCrs = QgsCoordinateReferenceSystem::fromWkt( QStringLiteral( "not wkt" ) );
QVERIFY( !myCrs.isValid() );
@ -757,15 +758,15 @@ void TestQgsCoordinateReferenceSystem::wktCache()
{
// test that crs can be retrieved correctly from cache
QgsCoordinateReferenceSystem crs;
QVERIFY( crs.createFromWkt( geoWkt() ) );
QVERIFY( crs.createFromWkt( mWgs84Wkt ) );
QVERIFY( crs.isValid() );
QCOMPARE( crs.srsid(), GEOCRS_ID );
QVERIFY( QgsCoordinateReferenceSystem::wktCache().contains( geoWkt() ) );
QCOMPARE( crs.srsid(), 3452 );
QVERIFY( QgsCoordinateReferenceSystem::wktCache().contains( mWgs84Wkt ) );
// a second time, so crs is fetched from cache
QgsCoordinateReferenceSystem crs2;
QVERIFY( crs2.createFromWkt( geoWkt() ) );
QVERIFY( crs2.createFromWkt( mWgs84Wkt ) );
QVERIFY( crs2.isValid() );
QCOMPARE( crs2.srsid(), GEOCRS_ID );
QCOMPARE( crs2.srsid(), 3452 );
// invalid
QgsCoordinateReferenceSystem crs3;
@ -778,7 +779,7 @@ void TestQgsCoordinateReferenceSystem::wktCache()
QVERIFY( !crs4.isValid() );
QgsCoordinateReferenceSystem::invalidateCache();
QVERIFY( !QgsCoordinateReferenceSystem::wktCache().contains( geoWkt() ) );
QVERIFY( !QgsCoordinateReferenceSystem::wktCache().contains( mWgs84Wkt ) );
}
QString TestQgsCoordinateReferenceSystem::testESRIWkt( int i, QgsCoordinateReferenceSystem &myCrs )
@ -810,18 +811,18 @@ void TestQgsCoordinateReferenceSystem::createFromSrId()
{
QgsCoordinateReferenceSystem myCrs;
Q_NOWARN_DEPRECATED_PUSH
QVERIFY( myCrs.createFromSrid( GEOSRID ) );
QVERIFY( myCrs.createFromSrid( 4326 ) );
Q_NOWARN_DEPRECATED_POP
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
QCOMPARE( myCrs.srsid(), 3452 );
}
void TestQgsCoordinateReferenceSystem::fromSrsId()
{
QgsCoordinateReferenceSystem myCrs = QgsCoordinateReferenceSystem::fromSrsId( GEOCRS_ID );
QgsCoordinateReferenceSystem myCrs = QgsCoordinateReferenceSystem::fromSrsId( 3452 );
debugPrint( myCrs );
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
QCOMPARE( myCrs.srsid(), 3452 );
myCrs = QgsCoordinateReferenceSystem::fromSrsId( -9999 );
QVERIFY( !myCrs.isValid() );
}
@ -830,15 +831,15 @@ void TestQgsCoordinateReferenceSystem::srsIdCache()
{
// test that crs can be retrieved correctly from cache
QgsCoordinateReferenceSystem crs;
QVERIFY( crs.createFromSrsId( GEOCRS_ID ) );
QVERIFY( crs.createFromSrsId( 3452 ) );
QVERIFY( crs.isValid() );
QCOMPARE( crs.srsid(), GEOCRS_ID );
QVERIFY( QgsCoordinateReferenceSystem::srsIdCache().contains( GEOCRS_ID ) );
QCOMPARE( crs.srsid(), 3452 );
QVERIFY( QgsCoordinateReferenceSystem::srsIdCache().contains( 3452 ) );
// a second time, so crs is fetched from cache
QgsCoordinateReferenceSystem crs2;
QVERIFY( crs2.createFromSrsId( GEOCRS_ID ) );
QVERIFY( crs2.createFromSrsId( 3452 ) );
QVERIFY( crs2.isValid() );
QCOMPARE( crs2.srsid(), GEOCRS_ID );
QCOMPARE( crs2.srsid(), 3452 );
// invalid
QgsCoordinateReferenceSystem crs3;
@ -851,7 +852,7 @@ void TestQgsCoordinateReferenceSystem::srsIdCache()
QVERIFY( !crs4.isValid() );
QgsCoordinateReferenceSystem::invalidateCache();
QVERIFY( !QgsCoordinateReferenceSystem::srsIdCache().contains( GEOCRS_ID ) );
QVERIFY( !QgsCoordinateReferenceSystem::srsIdCache().contains( 3452 ) );
}
@ -861,19 +862,19 @@ void TestQgsCoordinateReferenceSystem::createFromProj()
QVERIFY( !myCrs.createFromProj( QString() ) );
QVERIFY( !myCrs.isValid() );
QVERIFY( myCrs.createFromProj( geoProj4() ) );
QVERIFY( myCrs.createFromProj( QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" ) ) );
debugPrint( myCrs );
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
QCOMPARE( myCrs.srsid(), 3452 );
QCOMPARE( myCrs.ellipsoidAcronym(), QStringLiteral( "EPSG:7030" ) );
}
void TestQgsCoordinateReferenceSystem::fromProj()
{
QgsCoordinateReferenceSystem myCrs = QgsCoordinateReferenceSystem::fromProj( geoProj4() );
QgsCoordinateReferenceSystem myCrs = QgsCoordinateReferenceSystem::fromProj( QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" ) );
debugPrint( myCrs );
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
QCOMPARE( myCrs.srsid(), 3452 );
myCrs = QgsCoordinateReferenceSystem::fromProj( QString() );
QVERIFY( !myCrs.isValid() );
}
@ -882,15 +883,15 @@ void TestQgsCoordinateReferenceSystem::proj4Cache()
{
// test that crs can be retrieved correctly from cache
QgsCoordinateReferenceSystem crs;
QVERIFY( crs.createFromProj( geoProj4() ) );
QVERIFY( crs.createFromProj( QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" ) ) );
QVERIFY( crs.isValid() );
QCOMPARE( crs.srsid(), GEOCRS_ID );
QVERIFY( QgsCoordinateReferenceSystem::projCache().contains( geoProj4() ) );
QCOMPARE( crs.srsid(), 3452 );
QVERIFY( QgsCoordinateReferenceSystem::projCache().contains( QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" ) ) );
// a second time, so crs is fetched from cache
QgsCoordinateReferenceSystem crs2;
QVERIFY( crs2.createFromProj( geoProj4() ) );
QVERIFY( crs2.createFromProj( QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" ) ) );
QVERIFY( crs2.isValid() );
QCOMPARE( crs2.srsid(), GEOCRS_ID );
QCOMPARE( crs2.srsid(), 3452 );
// invalid
QgsCoordinateReferenceSystem crs3;
@ -903,7 +904,7 @@ void TestQgsCoordinateReferenceSystem::proj4Cache()
QVERIFY( !crs4.isValid() );
QgsCoordinateReferenceSystem::invalidateCache();
QVERIFY( !QgsCoordinateReferenceSystem::projCache().contains( geoProj4() ) );
QVERIFY( !QgsCoordinateReferenceSystem::projCache().contains( QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" ) ) );
}
void TestQgsCoordinateReferenceSystem::fromString()
@ -1563,9 +1564,9 @@ void TestQgsCoordinateReferenceSystem::postgisSrid()
{
QgsCoordinateReferenceSystem myCrs;
Q_NOWARN_DEPRECATED_PUSH
myCrs.createFromSrid( GEOSRID );
myCrs.createFromSrid( 4326 );
Q_NOWARN_DEPRECATED_POP
QVERIFY( myCrs.postgisSrid() == GEOSRID );
QVERIFY( myCrs.postgisSrid() == 4326 );
debugPrint( myCrs );
}
void TestQgsCoordinateReferenceSystem::ellipsoidAcronym()
@ -1592,7 +1593,7 @@ void TestQgsCoordinateReferenceSystem::toProj()
const QgsCoordinateReferenceSystem myCrs( QStringLiteral( "EPSG:4326" ) );
//first proj string produced by gdal 1.8-1.9
//second by gdal 1.7
QCOMPARE( myCrs.toProj(), geoProj4() );
QCOMPARE( myCrs.toProj(), QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" ) );
}
void TestQgsCoordinateReferenceSystem::isGeographic()
{
@ -1860,7 +1861,7 @@ void TestQgsCoordinateReferenceSystem::saveAsUserCrs()
QCOMPARE( userCrs.srsid(), 0L ); // not saved to database yet
const long newId = userCrs.saveAsUserCrs( QStringLiteral( "babies first projection" ) );
QCOMPARE( newId, static_cast<long>( USER_CRS_START_ID ) );
QCOMPARE( newId, static_cast<long>( Qgis::USER_CRS_START_ID ) );
QCOMPARE( userCrs.srsid(), newId );
QCOMPARE( userCrs.authid(), QStringLiteral( "USER:100000" ) );
QCOMPARE( userCrs.description(), QStringLiteral( "babies first projection" ) );

View File

@ -357,7 +357,7 @@ void TestQgsCoordinateReferenceSystemRegistry::testRecent()
QCOMPARE( pushSpy.size(), 1 );
QCOMPARE( pushSpy.at( 0 ).at( 0 ).value<QgsCoordinateReferenceSystem>().authid(), QStringLiteral( "EPSG:3111" ) );
QgsApplication::coordinateReferenceSystemRegistry()->pushRecent( QgsCoordinateReferenceSystem::fromProj( geoProj4() ) );
QgsApplication::coordinateReferenceSystemRegistry()->pushRecent( QgsCoordinateReferenceSystem::fromProj( QStringLiteral( "+proj=longlat +datum=WGS84 +no_defs" ) ) );
recent = QgsApplication::coordinateReferenceSystemRegistry()->recentCrs();
QCOMPARE( recent.size(), 2 );
QCOMPARE( recent.at( 0 ).authid(), QStringLiteral( "EPSG:4326" ) );

View File

@ -70,7 +70,7 @@ void TestQgsDistanceArea::basic()
QgsDistanceArea daA;
double resultA, resultB, resultC;
daA.setEllipsoid( geoNone() );
daA.setEllipsoid( Qgis::geoNone() );
resultA = daA.measureLine( p1, p2 );
QCOMPARE( resultA, 5.0 );
@ -105,9 +105,9 @@ void TestQgsDistanceArea::basic()
void TestQgsDistanceArea::noEllipsoid()
{
QgsDistanceArea da;
da.setEllipsoid( geoNone() );
da.setEllipsoid( Qgis::geoNone() );
QVERIFY( !da.willUseEllipsoid() );
QCOMPARE( da.ellipsoid(), geoNone() );
QCOMPARE( da.ellipsoid(), Qgis::geoNone() );
}
void TestQgsDistanceArea::cache()
@ -152,13 +152,13 @@ void TestQgsDistanceArea::cache()
QgsDistanceArea da5;
QVERIFY( !da5.setEllipsoid( QStringLiteral( "MyFirstEllipsoid" ) ) );
QVERIFY( !da5.willUseEllipsoid() );
QCOMPARE( da5.ellipsoid(), geoNone() );
QCOMPARE( da5.ellipsoid(), Qgis::geoNone() );
// invalid again, should be cached
QgsDistanceArea da6;
QVERIFY( !da6.setEllipsoid( QStringLiteral( "MyFirstEllipsoid" ) ) );
QVERIFY( !da6.willUseEllipsoid() );
QCOMPARE( da6.ellipsoid(), geoNone() );
QCOMPARE( da6.ellipsoid(), Qgis::geoNone() );
}
void TestQgsDistanceArea::test_distances()

View File

@ -125,7 +125,7 @@ void TestQgsMapRendererJob::initTestCase()
mEncoding = QStringLiteral( "UTF-8" );
QgsField myField1( QStringLiteral( "Value" ), QMetaType::Type::Int, QStringLiteral( "int" ), 10, 0, QStringLiteral( "Value on lon" ) );
mFields.append( myField1 );
mCRS = QgsCoordinateReferenceSystem( geoWkt() );
mCRS = QgsCoordinateReferenceSystem( R"""(GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]] )""" );
//
// Create the test dataset if it doesn't exist
//

View File

@ -140,7 +140,7 @@ void TestQgsVectorFileWriter::initTestCase()
mEncoding = QStringLiteral( "UTF-8" );
const QgsField myField1( QStringLiteral( "Field1" ), QMetaType::Type::QString, QStringLiteral( "String" ), 10, 0, QStringLiteral( "Field 1 comment" ) );
mFields.append( myField1 );
mCRS = QgsCoordinateReferenceSystem( geoWkt() );
mCRS = QgsCoordinateReferenceSystem( R"""(GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]] )""" );
mPoint1 = QgsPointXY( 10.0, 10.0 );
mPoint2 = QgsPointXY( 15.0, 10.0 );
mPoint3 = QgsPointXY( 15.0, 12.0 );
@ -425,7 +425,7 @@ void TestQgsVectorFileWriter::regression1141()
QgsFields fields;
fields.append( myField );
QgsCoordinateReferenceSystem crs;
crs = QgsCoordinateReferenceSystem( geoWkt() );
crs = QgsCoordinateReferenceSystem( R"""(GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["unknown"],AREA["World"],BBOX[-90,-180,90,180]],ID["EPSG",4326]] )""" );
const QString tmpDir = QDir::tempPath() + '/';
const QString fileName = tmpDir + "ąęćń.shp";

View File

@ -110,13 +110,13 @@ void TestQgsVectorTileLayer::initTestCase()
QColor polygonFillColor = Qt::blue;
const QColor polygonStrokeColor = polygonFillColor;
polygonFillColor.setAlpha( 100 );
const double polygonStrokeWidth = DEFAULT_LINE_WIDTH * 2;
const double polygonStrokeWidth = Qgis::DEFAULT_LINE_WIDTH * 2;
const QColor lineStrokeColor = Qt::blue;
const double lineStrokeWidth = DEFAULT_LINE_WIDTH * 2;
const double lineStrokeWidth = Qgis::DEFAULT_LINE_WIDTH * 2;
QColor pointFillColor = Qt::red;
const QColor pointStrokeColor = pointFillColor;
pointFillColor.setAlpha( 100 );
const double pointSize = DEFAULT_POINT_SIZE;
const double pointSize = Qgis::DEFAULT_POINT_SIZE;
QgsVectorTileBasicRenderer *rend = new QgsVectorTileBasicRenderer;
rend->setStyles( QgsVectorTileBasicRenderer::simpleStyle(
@ -201,7 +201,7 @@ void TestQgsVectorTileLayer::test_labeling()
// use a different renderer to make the labels stand out more
QgsVectorTileBasicRenderer *rend = new QgsVectorTileBasicRenderer;
rend->setStyles( QgsVectorTileBasicRenderer::simpleStyle(
Qt::transparent, Qt::white, DEFAULT_LINE_WIDTH * 2,
Qt::transparent, Qt::white, Qgis::DEFAULT_LINE_WIDTH * 2,
Qt::transparent, 0,
Qt::transparent, Qt::transparent, 0
) );
@ -552,7 +552,7 @@ void TestQgsVectorTileLayer::test_polygonWithLineStyle()
mMapSettings->setLayers( QList<QgsMapLayer *>() << layer.get() );
const QColor lineStrokeColor = Qt::blue;
const double lineStrokeWidth = DEFAULT_LINE_WIDTH * 2;
const double lineStrokeWidth = Qgis::DEFAULT_LINE_WIDTH * 2;
QgsSimpleLineSymbolLayer *lineSymbolLayer = new QgsSimpleLineSymbolLayer;
lineSymbolLayer->setColor( lineStrokeColor );
@ -630,7 +630,7 @@ void TestQgsVectorTileLayer::test_styleMinZoomBeyondTileMaxZoom()
mMapSettings->setLayers( QList<QgsMapLayer *>() << layer.get() );
const QColor lineStrokeColor = Qt::blue;
const double lineStrokeWidth = DEFAULT_LINE_WIDTH * 2;
const double lineStrokeWidth = Qgis::DEFAULT_LINE_WIDTH * 2;
QgsSimpleLineSymbolLayer *lineSymbolLayer = new QgsSimpleLineSymbolLayer;
lineSymbolLayer->setColor( lineStrokeColor );
@ -670,7 +670,7 @@ void TestQgsVectorTileLayer::test_filterRuleAllLayers()
mMapSettings->setLayers( QList<QgsMapLayer *>() << layer.get() );
const QColor lineStrokeColor = Qt::blue;
const double lineStrokeWidth = DEFAULT_LINE_WIDTH * 4;
const double lineStrokeWidth = Qgis::DEFAULT_LINE_WIDTH * 4;
QgsSimpleLineSymbolLayer *lineSymbolLayer = new QgsSimpleLineSymbolLayer;
lineSymbolLayer->setColor( lineStrokeColor );