Skip to content
This repository has been archived by the owner on Aug 18, 2022. It is now read-only.

Commit

Permalink
uuid is now properly parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontaigu committed Jun 8, 2018
1 parent 1f22d0e commit a3ac218
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pylas/headers/rawheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import enum
import logging
import uuid

from .. import compression
from .. import errors
Expand Down Expand Up @@ -50,10 +51,7 @@ class RawHeader1_1(ctypes.LittleEndianStructure):
("file_signature", ctypes.c_char * 4),
("file_source_id", ctypes.c_uint16),
("global_encoding", GlobalEncoding),
("guid_data_1", ctypes.c_uint32),
("guid_data_2", ctypes.c_uint16),
("guid_data_3", ctypes.c_uint16),
("guid_data_4", ctypes.c_uint8 * 8),
("uuid_bytes", ctypes.c_ubyte * 16),
("version_major", ctypes.c_uint8),
("version_minor", ctypes.c_uint8),
("system_identifier", ctypes.c_char * 32),
Expand Down Expand Up @@ -161,6 +159,14 @@ def point_size(self):
def point_size(self, value):
self.point_data_record_length = value

@property
def uuid(self):
return uuid.UUID(bytes_le=bytes(self.uuid_bytes))

@uuid.setter
def uuid(self, new_uuid):
self.uuid_bytes = (ctypes.c_ubyte * 16)(*new_uuid.bytes_le)

@property
def are_points_compressed(self):
return compression.is_point_format_compressed(self._point_data_format_id)
Expand Down
11 changes: 11 additions & 0 deletions pylastests/test_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_nb_points_return_1_4():

def test_header_copy():
import copy

las = pylas.read(test_common.simple_las)
header_copy = copy.copy(las.header)

Expand All @@ -56,3 +57,13 @@ def test_header_copy():
header_copy.point_format_id = 0
assert header_copy.point_format_id != las.header.point_format_id
assert header_copy.version == las.header.version


def test_set_uuid():
import uuid

las = pylas.read(test_common.simple_las)
u = uuid.uuid4()
las.header.uuid = u
las = test_common.write_then_read_again(las)
assert las.header.uuid == u

0 comments on commit a3ac218

Please sign in to comment.