gwlucastrig / Tinfour

Delaunay and Constrained Delaunay Triangulations in Java, providing high-performance utilities for modeling surfaces with support for Lidar LAS files, Digital Elevation Models (DEM), finite element analysis, path planning, natural neighbor interpolation, and other applications of Triangulated Irregular Networks (TIN)
Apache License 2.0
158 stars 34 forks source link

Error in shapefile writing for SVM operations #96

Open gwlucastrig opened 1 year ago

gwlucastrig commented 1 year ago

Recent attempts to import the contour-files output from the SVM module into QGIS failed due to geometry problems in the shapefiles produced by SVM. Problems were traced back to two sets of errors. First, some of the contours produced by the ContourBuilder had self-intersecting lines. Second, the API for writing shapefiles has some coding errors. This issue proposes to fix both these problems.

gwlucastrig commented 1 year ago

The main problem turned out to be the shapefile index file (the .shx file). Tinfour's ShapfileWriter updated the record-indexing section of that file, but it did not update the coordinate bounds section in the index file header. QGIS treated this as meaning that the geometry for the shapefile was not available. However, the ShapefileWriter did correctly update the same section of the main file (the .shp file). So I simply consolidated the code for performing flush operations on the two files into a single method that was used consistently for both.

I have pushed up changes for the shapefile-related classes.

I am still investigating some geometry validation errors being reported about the contour files. The cause is not yet known.