v.to.rast: avoid zero categories metadata when using use=cat#7019
Open
Abhi-d-gr8 wants to merge 3 commits intoOSGeo:mainfrom
Open
v.to.rast: avoid zero categories metadata when using use=cat#7019Abhi-d-gr8 wants to merge 3 commits intoOSGeo:mainfrom
Abhi-d-gr8 wants to merge 3 commits intoOSGeo:mainfrom
Conversation
6fdc5bc to
c688eb9
Compare
Member
|
Given the starting point is a performance regression and unclear behavior, a reproducible benchmark and more reasoning is needed here. The test should be more specific to show that the desired behavior is indeed there. |
wenzeslaus
requested changes
Feb 6, 2026
Comment on lines
+64
to
+73
| module = SimpleModule("r.info", map=self.output, flags="gr") | ||
| self.runModule(module) | ||
| info = module.outputs.stdout | ||
|
|
||
| # r.info -gr uses shell format and prints ncats= (not "categories=") | ||
| ncats = None | ||
| for line in info.splitlines(): | ||
| if line.startswith("ncats="): | ||
| ncats = int(float(line.split("=", 1)[1])) | ||
| break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2739
While working with
v.to.rast, I noticed that rasterizing withuse=catresults inr.inforeportingNumber of Categories: 0, even though the raster clearly contains category values. This is confusing for users and looks like a regression.The issue seems to come from an earlier change where writing individual category rules was disabled for performance reasons. In the
use=catcase without labels, this means no category metadata ends up being written at all.This PR restores meaningful category metadata by using
Rast_set_cats_fmt()to store a category format instead of enumerating all categories. This keeps the fast path intact and avoids the performance cost of writing per-category rules, while ensuringr.infono longer reports zero categories.I also added a small regression test to make sure
use=catproduces non-zero category metadata going forward.