arsf / lag

LiDAR Analysis GUI
GNU General Public License v2.0
22 stars 5 forks source link

ASCII Files Don't Load #31

Closed ada-foss closed 11 years ago

ada-foss commented 12 years ago

ASCII files don't load. Either they didn't ever load, or some recent change has broken that functionality.

I think they never worked, because it looks like LoadWorker has, for a very long time, worked on the following code:

    int points_to_load = reader->header.number_of_point_records
          / (point_offset + 1);

    while (!stopped && points_loaded < points_to_load
          && reader->read_point())

For ASCII files, reader->header.number_of_point_records always has been 0, because ASCII files contain no convenient headers from which to extract that information from. And so, the while clause will always evaluate as false on the first iteration, meaning no points will ever have been able to load while those two lines have been in place. (Unless, of course, the behaviour of laslib has changed. Unconfirmable though, as laslib has no source code management at all.)

ada-foss commented 11 years ago

Worked around for now. When no boundary is available in the header (or when LAG detects that LASlib may be lying about the header), LAG makes a pass of the whole file to determine its own min+max values of each dimension. This is costly in loading times, but reasonably lightweight in terms of programming and maintenance.

The other change is that when LAG detects LASlib might be untruthful about the number of points in a LAS file, then LAG just pulses the progress bar, to show that/whether progress is being made, how fast it is being made, and that LAG does not know when the file will be finished.

It would be very possible to ammend the header with any of LAGs own values as it goes along, if it needs to, as-well-as counting the number of points in the file when finding the bounding box.