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
Expression Editor: Replace Map Function Does Not Match Two-Digit Numeric Key to Value Properly #42940
Comments
that's because 11 is also 1 1. You would need to do this in two steps, or increment your index by 10 to have them all in double digit, and you would still have issue wit longer int. i'm not sure how much of this is a bug. |
It seems really unintuitive, especially if the key is being quoted, as a user would expect that to be a literal match to '11', not 1 1. |
@Saijin-Naib the |
Not actually a bug, but me mis-understanding how this function works, and possibly a tricky default implementation. Being closed by this awesome PR: #42941 Thanks! |
Describe the bug
In a replace(map()) function, the replacing/mapping does not function properly when the key is numeric and more than one digit.
For instance, if the key were to be 1 and the value Paved - Asphalt, it will work properly, but if the key were to be 11 and the value Curb - Stone, it will simply put Paved - AsphaltPaved - Asphalt.
How to Reproduce
replace("CAMPRS_SHOULDER_ID",map('0','NULL','1','Paved - Asphalt','2','Gravel','3','Earth','4','Vegetation','5','None','6','Curb - Asphalt','7','Curb - Concrete','8','Curb - Granite','9','Paved - Concrete','10','Gutter - Concrete','11','Curb - Stone','12','Gutter - Paved'))
QGIS and OS versions
QGIS version
3.18.2-Zürich
QGIS code revision
515138c
Compiled against Qt
5.15.2
Running against Qt
5.15.2
Compiled against GDAL/OGR
3.2.2
Running against GDAL/OGR
3.2.2
Compiled against GEOS
3.9.1-CAPI-1.14.2
Running against GEOS
3.9.1-CAPI-1.14.2
Compiled against SQLite
3.35.2
Running against SQLite
3.35.2
Compiled against PDAL
2.2.0
Running against PDAL
2.2.0 (git-version: 24dd45)
PostgreSQL Client Version
13.0
SpatiaLite Version
5.0.1
QWT Version
6.1.3
QScintilla2 Version
2.11.5
Compiled against PROJ
8.0.0
Running against PROJ
Rel. 8.0.0, March 1st, 2021
OS Version
Windows 10 Version 2009
Active python plugins
CalculateGeometry;
cartography_tools;
ClipMultipleLayers;
MemoryLayerSaver;
project_colors_dock;
slyr;
toggle_labels_widget;
zoom_level;
db_manager;
MetaSearch;
processing
Additional context
Example screenshot:
The text was updated successfully, but these errors were encountered: