Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processing] Try directly interpreting string as CRS first #57508

Merged
merged 1 commit into from
May 23, 2024

Conversation

nyalldawson
Copy link
Collaborator

...before falling back to alternatives like treating it as a map layer

Fixes #57494

...before falling back to alternatives like treating it as a map
layer

Fixes qgis#57494
@github-actions github-actions bot added this to the 3.38.0 milestone May 22, 2024
Copy link

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit 90c93ce)

Copy link
Contributor

@troopa81 troopa81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind adding tests?

@nyalldawson
Copy link
Collaborator Author

@troopa81

Do you mind adding tests?

I tried, but it's not possible (without unreasonable effort) -- there's already tests covering the functionality here, it's just the order of evaluation which has changed.

@nyalldawson nyalldawson merged commit 53e5b34 into qgis:master May 23, 2024
34 of 35 checks passed
@nyalldawson nyalldawson deleted the fix_57494 branch May 23, 2024 08:19
@agiudiceandrea
Copy link
Contributor

@nyalldawson it seems to me the issue still occurs for some algorithm even using QGIS 3.37.0-Master b2a8801d76 : native:creategrid, native:createconstantrasterlayer, native:randompointsinextent, qgis:regularpoints, native:createrandomuniformrasterlayer, ...

@nyalldawson
Copy link
Collaborator Author

@agiudiceandrea

What command are you using to get them?

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented May 24, 2024

@nyalldawson on an OSGeo4W Shell:

C:\OSGeo4W_V2_8>qgis_process-qgis-dev --version
QGIS 3.37.0-Master 'Master' (b2a8801d76)
QGIS code revision b2a8801d76
Qt version 5.15.13
Python version 3.12.3
Compiled against GDAL/OGR 3.10.0dev-39cad318b2
Running against GDAL/OGR 3.10.0dev-12dab86ca2
PROJ version 9.4.0
EPSG Registry database version v11.004 (2024-02-24)
GEOS version 3.12.1-CAPI-1.18.1
SQLite version 3.45.1
OS Windows 10 Version 1903
This copy of QGIS writes debugging output.

C:\OSGeo4W_V2_8>qgis_process-qgis-dev help native:creategrid
Create grid (native:creategrid)

----------------
Description
----------------
This algorithm creates a vector layer with a grid covering a given extent. Elements in the grid can be points, lines or polygons. The size and/or placement of each element in the grid is defined using a horizontal and vertical spacing. The CRS of the output layer must be defined. The grid extent and the spacing values must be expressed in the coordinates and units of this CRS. The top-left point (minX, maxY) is used as the reference point. That means that, at that point, an element is guaranteed to be placed. Unless the width and height of the selected extent is a multiple of the selected spacing, that is not true for the other points that define that extent.

----------------
Arguments
----------------

...

CRS: Grid CRS
ERROR: Status 2: File ProjectCrs could not be found
ERROR: Status 2: File ProjectCrs could not be found
        Default value:  ProjectCrs
        Argument type:  crs
        Acceptable values:
                - CRS as an auth ID (e.g. 'EPSG:3111')
                - CRS as a PROJ4 string (e.g. 'PROJ4:à')
                - CRS as a WKT string (e.g. 'WKT:à')
                - Path to a layer. The CRS of the layer is used.

...

The issue is due to the fact that such algorithms have the string "ProjectCrs" as default value for the CRS parameter, but such string is not a valid QgsCoordinateReferenceSystem, thus the check in

QString QgsProcessingParameterCrs::valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok ) const
{
if ( value.type() == QVariant::String )
{
const QgsCoordinateReferenceSystem crs( value.toString() );
if ( crs.isValid() )
return value.toString();
}
still fails.

See

// maybe special string
if ( context.project() && crsText.compare( QLatin1String( "ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
return context.project()->crs();

@nyalldawson
Copy link
Collaborator Author

@agiudiceandrea fixed in #57576

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

qgis_process with algorithms using a CRS: error and a faulty message
3 participants