Skip to content
Browse files

Allow setting point_records_count

  • Loading branch information...
1 parent f964d30 commit fd5e9c29798bdaceb12be2ee02c7fd5908b9d99a @grantbrown committed Jul 29, 2012
Showing with 6 additions and 8 deletions.
  1. +3 −1 laspy/base.py
  2. +2 −3 laspy/header.py
  3. +1 −4 laspytest/test_laspy.py
View
4 laspy/base.py
@@ -61,7 +61,9 @@ def point_map(self):
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.")
+ 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))
self.manager.header.point_records_count = len(self._pmap)
else:
self._pmap = np.frombuffer(self._mmap, self.pointfmt,
View
5 laspy/header.py
@@ -952,9 +952,8 @@ def get_pointrecordscount(self):
return self.reader.get_pointrecordscount()
def set_pointrecordscount(self, value):
- if not self.file_mode in ("w", "w+"):
- raise LaspyHeaderException("File must be open in write or append mode " +
- "to change the number of point records.")
+ if not self.file_mode in ("w", "w+","rw"):
+ raise LaspyHeaderException("File must be open in a write mode to modify point_records_count.")
self.writer.set_header_property("point_records_count", value)
'''Sets the number of point records expected in the file.
View
5 laspytest/test_laspy.py
@@ -439,10 +439,7 @@ def test_date(self):
self.FileObject.header.date = d2
d3 = self.FileObject.header.get_date()
self.assertEqual(d2, d3)
- def test_pointrecordscount(self):
- """Testing pointrecordscount"""
- with self.assertRaises(Exception):
- self.FileObject.header.point_records_count = 100
+
def test_point_recs_by_return(self):
"""Testing point records by return"""
r1 = [x + 1 for x in self.FileObject.header.point_return_count]

0 comments on commit fd5e9c2

Please sign in to comment.
Something went wrong with that request. Please try again.