gdal icon indicating copy to clipboard operation
gdal copied to clipboard

VFK: Fix solving circle parcel geometry (fixes #8993)

Open seidlmic opened this issue 2 years ago • 5 comments

What does this PR do?

It seems that current code generates in some situation wrong shaped parcels. Probably due to unexpected point order which is not in VFK format guaranteed.

Because it is not obvious how to fix current algorithm it was replaces with new one based on solving 3 equations by computing determinant of system. The percentage of circle shaped parcel is very low so computing time is not so important.

The advantage of the solution with determinant is, it does not need to care about points order or their configuration. Only the value of determinant should be tested. If it is too small (the area off 3 point triangle) means invalid configuration. If determinant is too large no reasonable size of circle in case of VFK data.

These situation should be handle in method GetCircleCenterFrom3Points() but it is not clear to me how to do it directly in method.

The fix should be confirm by @landam as the author of original code.

To test the code run:

/usr/local/gdal/test/bin/ogr2ogr --config OGR_VFK_DB_OVERWRITE YES --config OGR_VFK_DB_NAME 616397.db --config OGR_VFK_DB_READ_ALL_BLOCKS N0 -f SHP 616397_PAR.SHP 2020-09-01_sgi/616397.vfk PAR

 /usr/local/gdal/test/bin/ogr2ogr --config OGR_VFK_DB_OVERWRITE NO --config OGR_VFK_DB_NAME 616397.db --config OGR_VFK_DB_READ_ALL_BLOCKS N0  616397_PAR.SHP 2020-09-01_spi/616397.vfk PAR

What are related issues/pull requests?

Tasklist

Environment

616397_sgi.zip 616397_spi.zip

The circle parcel ID is 1390618203

seidlmic avatar Dec 23 '23 10:12 seidlmic

Code formatting issues: If you are seeing this message in CI, reproduce locally with: `pre-commit run --all-files`. To run `pre-commit` as part of git workflow, use `pre-commit install`.

Cf https://gdal.org/development/dev_practices.html#commit-hooks how to install and configure pre-commit

rouault avatar Dec 23 '23 10:12 rouault

Coverage Status

coverage: 68.748% (-0.004%) from 68.752% when pulling 8bcb36c2a05afc8f3d33858a881379c65e882a8a on seidlmic:master into 527b897e632fc83457c9cf0c6a8221a48519c23c on OSGeo:master.

coveralls avatar Dec 23 '23 11:12 coveralls

some linting issues remaining: https://github.com/OSGeo/gdal/actions/runs/7308961912/job/19916097431?pr=8995

cf my comment https://github.com/OSGeo/gdal/pull/8995#issuecomment-1868266258 how to solve them automatically

rouault avatar Jan 17 '24 18:01 rouault

I have installed pre-commit and hopefully fix clang formatting issue

seidlmic avatar Jan 23 '24 10:01 seidlmic

Things look good to me. Hopefully @landam can give it some review too

rouault avatar Jan 23 '24 18:01 rouault

OK, I'm merging this... There are likely potential optimizations like the one I suggested in https://github.com/OSGeo/gdal/pull/8995#pullrequestreview-1866404386 , but this should be good enough as it for now.

rouault avatar Mar 25 '24 22:03 rouault