Skip to content

Commit

Permalink
Catch mismatch between header.point_records_count on point_map.
Browse files Browse the repository at this point in the history
  • Loading branch information
grantbrown committed Jul 29, 2012
1 parent 8bc6ca4 commit f964d30
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions laspy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,18 @@ def point_map(self):
if not self.manager.header.version in ("1.3", "1.4"):
self._pmap = np.frombuffer(self._mmap, self.pointfmt,
offset = self.manager.header.data_offset)
if self.manager.header.point_records_count != len(self._pmap):
if self.manager.mode == "r":
raise LaspyException("""Invalid Point Records Count Information Encountered in Header.
Please correct. Header.point_records_count = %i, and %i records actually detected."""%(self.manager.header.point_records_count, len(self._pmap)))
else:
print("WARNING: laspy found invalid data in header.point_records_count. Header.point_records_count = %i, and %i records actually detected. Attempting to correct mismatch.")
self.manager.header.point_records_count = len(self._pmap)
else:
self._pmap = np.frombuffer(self._mmap, self.pointfmt,
offset = self.manager.header.data_offset,
count = self.manager.header.point_records_count)


def close(self, flush = True):
'''Close the data provider and flush changes if _mmap and _pmap exist.'''
Expand Down

0 comments on commit f964d30

Please sign in to comment.