py3dtiles.tileset package
This module contains supporting classes and functions to manipulate 3DTiles data structure.
Use this module if you plan on directly reading, manipulating and writing tilesets, tiles and tile contents.
- class py3dtiles.tileset.BoundingVolume[source]
Bases:
RootProperty
[_BoundingVolumeJsonDictT
],Generic
[_BoundingVolumeJsonDictT
]Abstract class used as interface for box, region and sphere
- abstract add(other: BoundingVolume[Any]) None [source]
- class py3dtiles.tileset.BoundingVolumeBox[source]
Bases:
BoundingVolume
[BoundingVolumeBoxDictType
]A box bounding volume as defined in the 3DTiles specifications i.e. an array of 12 numbers that define an oriented bounding box:
The first three elements define the x, y, and z values for the center of the box.
The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length.
The next three elements (with indices 6, 7, and 8) define the y axis direction and half-length.
The last three elements (indices 9, 10, and 11) define the z axis direction and half-length.
Note that, by default, a box bounding volume doesn’t need to be aligned with the coordinate axis. Still in general, computing the box bounding volume of two box bounding volumes won’t necessarily yield a box that is aligned with the coordinate axis (although this computation might require some fitting algorithm e.g. the principal component analysis method. Yet in sake of simplification (and numerical efficiency), when asked to “add” (i.e. to find the enclosing box of) two (or more) box bounding volumes this class resolves to compute the “canonical” fitting/enclosing box i.e. a box that is parallel to the coordinate axis.
- add(other: BoundingVolume[Any]) None [source]
Compute the ‘canonical’ bounding volume fitting this bounding volume together with the added bounding volume. Again (refer above to the class definition) the computed fitting bounding volume is generically not the smallest one (due to its alignment with the coordinate axis).
- Parameters:
other – another box bounding volume to be added with this one
- classmethod from_dict(bounding_volume_box_dict: BoundingVolumeBoxDictType) Self [source]
Construct a BoundingVolumeBox from a dict following the structure of a 3dtiles bounding volume
- classmethod from_list(box_list: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) BoundingVolumeBox [source]
Construct a bounding box enclosing all the points.
Internally call set_from_points.
- Returns:
a new instance of BoundingVolumeBox
- classmethod from_points(points: list[ndarray[Any, dtype[float64]]]) BoundingVolumeBox [source]
Construct a bounding box enclosing all the points.
Internally call set_from_points.
- Returns:
a new instance of BoundingVolumeBox
- static get_box_array_from_mins_maxs(mins_maxs: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]] [source]
- Parameters:
mins_maxs – the list [x_min, y_min, z_min, x_max, y_max, z_max] that is the boundaries of the box along each coordinate axis
- Returns:
the smallest box (as an array, as opposed to a BoundingVolumeBox instance) that encloses the given list of (3D) points and that is parallel to the coordinate axis.
- static get_box_array_from_point(points: list[ndarray[Any, dtype[float64]]]) ndarray[Any, dtype[float64]] [source]
- Parameters:
points – a list of 3D points
- Returns:
the smallest box (as an array, as opposed to a BoundingVolumeBox instance) that encloses the given list of (3D) points and that is parallel to the coordinate axis.
- get_canonical_as_array() ndarray[Any, dtype[float64]] [source]
- Returns:
the smallest enclosing box (as an array) that is parallel to the coordinate axis
- get_corners() list[ndarray[Any, dtype[float64]]] [source]
- Returns:
the corners (3D points) of the box as a list
- set_from_list(box_list: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) None [source]
Set the box from a list of coordinates closely matching the 3Dtiles spec.
- Parameters:
box_list – An array of 12 numbers that define an oriented bounding box. The first three elements define the x, y, and z values for the center of the box. The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length. The next three elements (indices 6, 7, and 8) define the y axis direction and half-length. The last three elements (indices 9, 10, and 11) define the z axis direction and half-length.
- set_from_mins_maxs(mins_maxs: ndarray[Any, dtype[float64]]) None [source]
Set the box from a min and a max.
- Parameters:
mins_maxs – the array [x_min, y_min, z_min, x_max, y_max, z_max] that is the boundaries of the box along each coordinate axis
- set_from_points(points: list[ndarray[Any, dtype[float64]]]) None [source]
Make the current box only include a list of points. Note: the box limits are replaced, not extended.
- Parameters:
points – An array of points
- to_dict() BoundingVolumeBoxDictType [source]
- class py3dtiles.tileset.RootProperty[source]
Bases:
ABC
,Generic
[_JsonDictT
]One the 3DTiles notions defined as an abstract data model through a schema of the 3DTiles specifications (either core of extensions).
- class py3dtiles.tileset.Tile(geometric_error: float = 500, bounding_volume: BoundingVolume[Any] | None = None, transform: ndarray[Any, dtype[float64]] = array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), refine_mode: Literal['ADD', 'REPLACE'] = 'ADD', content_uri: Path | None = None)[source]
Bases:
RootProperty
[TileDictType
]- delete_on_disk(root_uri: Path, delete_sub_tileset: bool = False) None [source]
Deletes all files linked to the tile and its children. The uri of the folder where tileset is, should be defined.
- Parameters:
root_uri – The folder where tileset is.
delete_sub_tileset – If True, all tilesets present as tile content will be removed as well as their content. If False, the linked tilesets in tiles won’t be removed.
- classmethod from_dict(tile_dict: TileDictType) Tile [source]
- get_all_children() list[Tile] [source]
- Returns:
the recursive (across the children tree) list of the children tiles
- get_or_fetch_content(root_uri: Path | None) TileContent | TileSet [source]
If a tile_content content has been set, returns this content. If the tile content is None and a tile_content uri has been set, the tile will load the file and return its content.
- Parameters:
root_uri – the base uri which tile.content_uri is relative to. Usually the directory containing the tileset containing this tile.
- to_dict() TileDictType [source]
- transform_coord(coord: ndarray[Any, dtype[T]]) ndarray[Any, dtype[T]] [source]
Transform one coordinate according to this tile transformation property.
NOTE: this only applies the current tile transformation, not the transformation of ancestors
- class py3dtiles.tileset.TileSet(geometric_error: float = 500)[source]
Bases:
RootProperty
[TilesetDictType
]This class represents the tileset in a 3DTiles dataset.
- delete_on_disk(tileset_path: Path, delete_sub_tileset: bool = False) None [source]
Deletes all files linked to the tileset. The uri of the tileset should be defined.
- Parameters:
tileset_path – The path of the tileset
delete_sub_tileset – If True, all tilesets present as tile content will be removed as well as their content. If False, the linked tilesets in tiles won’t be removed.
- classmethod from_dict(tileset_dict: TilesetDictType) Self [source]
- to_dict() TilesetDictType [source]
Convert to json string possibly mentioning used schemas
- write_as_json(tileset_path: Path) None [source]
Write the tileset as a JSON file. :param tileset_path: the path where the tileset will be written
- write_to_directory(tileset_path: Path, overwrite: bool = False) None [source]
Write (or overwrite), to the directory whose name is provided, the TileSet that is: - the tileset as a json file and - all the tiles content of the Tiles used by the Tileset. :param tileset_path: the target directory name :param overwrite: delete the tileset (and the content) if already exists
Subpackages
- py3dtiles.tileset.content package
B3dm
B3dmBody
B3dmHeader
GltfAttribute
GltfPrimitive
Pnts
PntsBody
PntsHeader
TileContent
TileContentBody
TileContentHeader
gltf_component_from_primitive()
read_binary_tile_content()
- Submodules
- py3dtiles.tileset.content.b3dm module
- py3dtiles.tileset.content.b3dm_feature_table module
- py3dtiles.tileset.content.batch_table module
- py3dtiles.tileset.content.constants module
- py3dtiles.tileset.content.feature_table module
- py3dtiles.tileset.content.gltf_utils module
- py3dtiles.tileset.content.pnts module
- py3dtiles.tileset.content.pnts_feature_table module
- py3dtiles.tileset.content.tile_content module
- py3dtiles.tileset.content.tile_content_reader module
- py3dtiles.tileset.extension package
Submodules
- py3dtiles.tileset.bounding_volume module
- py3dtiles.tileset.bounding_volume_box module
BoundingVolumeBox
BoundingVolumeBox.add()
BoundingVolumeBox.from_dict()
BoundingVolumeBox.from_list()
BoundingVolumeBox.from_points()
BoundingVolumeBox.get_box_array_from_mins_maxs()
BoundingVolumeBox.get_box_array_from_point()
BoundingVolumeBox.get_canonical_as_array()
BoundingVolumeBox.get_center()
BoundingVolumeBox.get_corners()
BoundingVolumeBox.is_valid()
BoundingVolumeBox.set_from_list()
BoundingVolumeBox.set_from_mins_maxs()
BoundingVolumeBox.set_from_points()
BoundingVolumeBox.sync_with_children()
BoundingVolumeBox.to_dict()
BoundingVolumeBox.transform()
BoundingVolumeBox.translate()
- py3dtiles.tileset.root_property module
- py3dtiles.tileset.tile module
Tile
Tile.add_child()
Tile.delete_on_disk()
Tile.from_dict()
Tile.get_all_children()
Tile.get_or_fetch_content()
Tile.get_refine_mode()
Tile.has_content()
Tile.has_content_loaded()
Tile.set_refine_mode()
Tile.sync_bounding_volume_with_children()
Tile.to_dict()
Tile.transform_coord()
Tile.transform_coords()
Tile.write_content()
- py3dtiles.tileset.tileset module
- py3dtiles.tileset.utils module