Source code for py3dtiles.tileset.tile_content

from __future__ import annotations

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

import numpy as np
import numpy.typing as npt


[docs] class TileContent: def __init__(self): self.header = None self.body = None
[docs] def to_array(self) -> npt.NDArray[np.uint8]: 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): def __init__(self): self.tile_byte_length = 0 self.ft_json_byte_length = 0 self.ft_bin_byte_length = 0 self.bt_json_byte_length = 0 self.bt_bin_byte_length = 0 self.bt_length = 0 # number of models in the batch
[docs] @staticmethod @abstractmethod def from_array(array: npt.NDArray) -> TileContentHeader: ...
[docs] @abstractmethod def to_array(self) -> npt.NDArray: ...
[docs] @abstractmethod def sync(self, body) -> None: ...
[docs] class TileContentBody(ABC):
[docs] @abstractmethod def to_array(self) -> npt.NDArray: ...