-
-
Notifications
You must be signed in to change notification settings - Fork 308
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
lib/vector/Vlib: always write out topo files in update mode #3459
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works without Vect_build_partial()
or Vect_build()
as long as the map is Vect_close()
. Still, G_fatal_error()
needs to add an error handler to call Vect_close()
. Is it possible just to crash without closing the map?
When a vector is opened with |
Thanks for the explanation. This PR then sounds like a bug fix to me. I think it is fair to say that expected behavior of "open-for-update, do-nothing, close" sequence is that it would not invalidate the data. |
With 8ef73e8 there is a better solution where a map opened in update mode survives with level 2, any changes would be discarded, i.e. if |
Works well! Thanks! Once topology is built after any changes, |
I am not convinced with the current proposed solution because in case of a crash this can lead to a modified coor file (modified geometries) and old topo, sidx, cidx files no longer matching the new coor file which can cause strange errors. Therefore I prefer my first solution were even with no changes, the topo, sidx, cidx files are created anew. In case of a crash, there will be no topo, sidx, cidx files and |
Did a quick test.
In no case, changes were discarded. With Or breaking v.info with the 2nd solution might also be better instead of silently (hard to notice) downgrading level 1 with the 1st, causing issues later? At least, the error message mentions
Having said that, there are only three vector modules that use $ cd vector
$ find -type f -name "*.c" -exec grep -H "Vect_open_update2\?(" {} \; | cut -d/ -f2 | sort -u
v.clean
v.edit
v.patch So I'm not sure... |
This may not be obvious since we have mostly tests of individual tools, but these examples can be rewritten as tests in Python without a need to create a separate binary like we have for 3D raster library. We have examples of using ctypes to test the C library functions for both grass.gunittest tests using ctypes (also without grass.pygrass) and pytest-based tests. |
Probably we could take a different route – modify functions that write coor file to set "dirty" bit (e.g. |
@marisn This does not solve the problem of a crash. I prefer solution 1 where the support files are deleted when opening and always written out anew when closing. Writing out these files is fast and does not require rebuilding topology. With solution 2, there is the danger of ending up with non matching/wrong support files which can lead to difficult to debug problems. |
@metzm Based on my test, I think solution 1 should be preferred because with either solution, we need an error handler to properly close the map and it'll be the developer's mistake if that doesn't happen and solution 1 will be less harmful in that case. |
936bf39
to
7404b0c
Compare
I saw that same error between edits without topology building. I was wondering if it's always required to rebuild topology or if there are any cases where we don't need it when editing features. Will it be slow to rebuild it if there are a lot of features? |
If topology is already built and you just want that the cidx is marked up to date, it should be enough to call |
In pygrass, here https://github.com/OSGeo/grass/blob/main/python/grass/pygrass/vector/abstract.py#L454-L470 |
Please create a PR for the documentation as neither Vect_build or Vect_close mention this important bit. |
|
With the fix in pygrass, all checks have now passed. Ready to merge? |
* Vlib: always write out topo files in update mode * delete support files only when closing * fix pygrass Vect_close --------- Co-authored-by: Huidae Cho <grass4u@gmail.com>
When a vector with topology is opened in update mode, but nothing is changed, topology info (topo, cidx, sidx) is not written out. This PR fixes this.
I am not sure if this is a bug or an enhancement.