[Bug] `v.out.ogr` export points w/ missing category twice
Describe the bug
When a point has a category of -2147483647, it is skipped in v.out.ogr if the -c flag is not provided. Otherwise, it will be exported twice.
To reproduce
Generate 3 points. The second one has a category of -2147483647 while others are 2.
printf "P 1 1
0 0
1 1
P 1 1
1 0
1 -2147483647
P 1 1
2 0
1 3
" | v.in.ascii -n input=- output=pts format=standard --overwrite
v.info map=pts
v.category input=pts option=print
v.out.ogr input=pts output="pts.gpkg" format=GPKG --overwrite -c
This will export 4 points. If -c is not provided, only 2 points will be exported.
Expected behavior
Export points with missing cat only once.
System description
-
Operating System: Ubuntu 24.04
-
GRASS version: 8.4.1
-
details about further software components version=8.4.1 date=2025 revision=exported build_date=2025-07-21 build_platform=x86_64-pc-linux-gnu build_off_t_size=8 libgis_revision=8.4.1 libgis_date=2025-07-21T15:11:31+00:00 proj=9.4.1 gdal=3.11.3 geos=3.12.2 sqlite=3.45.1
This is actually a bug in v.in.ascii because negative category values are not allowed. This is not documented in https://grass.osgeo.org/grass84/manuals/vectorintro.html but there is a admittedly hdden hint in the GRASS 8 Programmer's Manual at "Categories and Layers": Categories start with 1 (category '0' is allowed for OGR layers). Categories do not have to be continuous.
Could you elaborate on how you actually got that negative value? Seems related to your other issue https://github.com/OSGeo/grass-addons/issues/1517 but perhaps more details are needed.
Yes, I got this negative value from the output of r.stream.snap function. I'll see if I can provide a minimal reproduction of that issue.
The number looks like it could be integer overflow issue.
I provided a minimal example in https://github.com/OSGeo/grass-addons/issues/1517. It seems they somehow forgot to assign a category to some output points, which caused this unexpected behavior in v.out.ogr.