Source code for py3dtiles.tile_content

from abc import ABC, abstractmethod
from enum import Enum
from pathlib import Path

import numpy as np


[docs] class TileContent: 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(f"{x:02X}" for x in arr)
[docs] def save_as(self, path: Path): tile_arr = self.to_array() with path.open('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 TileContentType(Enum): UNKNOWN = 0 POINT_CLOUD = 1 BATCHED_3D_MODEL = 2
[docs] class TileContentHeader(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 TileContentBody(ABC):
[docs] @abstractmethod def to_array(self): pass