Source code for py3dtiles.tile

# -*- coding: utf-8 -*-

import numpy as np
from enum import Enum
from abc import ABC, abstractmethod


[docs] class TileContent(ABC): def __init__(self): self.header = None self.body = None
[docs] def to_array(self): self.sync() header_arr = self.header.to_array() body_arr = self.body.to_array() return np.concatenate((header_arr, body_arr))
[docs] def to_hex_str(self): arr = self.to_array() return " ".join("{:02X}".format(x) for x in arr)
[docs] def save_as(self, filename): tile_arr = self.to_array() with open(filename, 'bw') as f: f.write(bytes(tile_arr))
[docs] def sync(self): """ Allow to synchronize headers with contents. """ self.header.sync(self.body)
[docs] class TileType(Enum): UNKNWON = 0 POINTCLOUD = 1 BATCHED3DMODEL = 2
[docs] class TileHeader(ABC):
[docs] @abstractmethod def from_array(self, array): pass
[docs] @abstractmethod def to_array(self): pass
[docs] @abstractmethod def sync(self, body): pass
[docs] class TileBody(object):
[docs] @abstractmethod def to_array(self): pass