Skip to content

Commit

Permalink
Chore: rename tile.py file and its classes to better match 3dtiles spec
Browse files Browse the repository at this point in the history
* tile.py becomes tile_content.py
* TileHeader class becomes TileContentHeader
* TileBody class becomes TileContentBody
* TileType enumeration becomes TileContentType
  • Loading branch information
LorenzoMarnat authored and autra committed May 17, 2022
1 parent 9aef189 commit 00dcdf3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Generic Tile
The py3dtiles module provides some classes to fit into the
specification:

- *TileContent* with a header *TileHeader* and a body *TileBody*
- *TileHeader* represents the metadata of the tile (magic value, version, ...)
- *TileBody* contains varying semantic and geometric data depending on the the tile's type
- *TileContent* with a header *TileContentHeader* and a body *TileContentBody*
- *TileContentHeader* represents the metadata of the tile (magic value, version, ...)
- *TileContentBody* contains varying semantic and geometric data depending on the the tile's type

Moreover, a utility class *TileContentReader* is available to read a tile
file as well as a simple command line tool to retrieve basic information
Expand Down Expand Up @@ -43,12 +43,12 @@ In the current implementation, the *Pnts* class only contains a *FeatureTable*
>>>
>>> # tile_content is an instance of the TileContent class
>>> tile_content
<py3dtiles.tile.TileContent>
<py3dtiles.tile_content.TileContent>
>>>
>>> # extract information about the tile_content header
>>> th = tile_content.header
>>> th
<py3dtiles.tile.TileHeader>
<py3dtiles.tile_content.TileContentHeader>
>>> th.magic_value
'pnts'
>>> th.tile_byte_length
Expand Down Expand Up @@ -127,7 +127,7 @@ https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/TileFormats/Batche
>>>
>>> # tile_content is an instance of the TileContent class
>>> tile_content
<py3dtiles.tile.TileContent>
<py3dtiles.tile_content.TileContent>
>>>
>>> # extract information about the tile header
>>> th = tile.header
Expand Down
2 changes: 1 addition & 1 deletion py3dtiles/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from .utils import TileContentReader, convert_to_ecef
from .tile import TileContent
from .tile_content import TileContent
from .feature_table import Feature
from .gltf import GlTF
from .pnts import Pnts
Expand Down
20 changes: 10 additions & 10 deletions py3dtiles/b3dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import struct
import numpy as np

from .tile import TileContent, TileHeader, TileBody, TileType
from .tile_content import TileContent, TileContentHeader, TileContentBody, TileContentType
from .gltf import GlTF
from .batch_table import BatchTable

Expand Down Expand Up @@ -70,11 +70,11 @@ def from_array(array):
return t


class B3dmHeader(TileHeader):
class B3dmHeader(TileContentHeader):
BYTELENGTH = 28

def __init__(self):
self.type = TileType.BATCHED3DMODEL
self.type = TileContentType.BATCHED3DMODEL
self.magic_value = b"b3dm"
self.version = 1
self.tile_byte_length = 0
Expand Down Expand Up @@ -130,7 +130,7 @@ def from_array(array):
Returns
-------
h : TileHeader
h : TileContentHeader
"""

h = B3dmHeader()
Expand All @@ -146,12 +146,12 @@ def from_array(array):
h.bt_json_byte_length = struct.unpack("i", array[20:24])[0]
h.bt_bin_byte_length = struct.unpack("i", array[24:28])[0]

h.type = TileType.BATCHED3DMODEL
h.type = TileContentType.BATCHED3DMODEL

return h


class B3dmBody(TileBody):
class B3dmBody(TileContentBody):
def __init__(self):
self.batch_table = BatchTable()
# self.feature_table = FeatureTable()
Expand All @@ -169,13 +169,13 @@ def from_glTF(glTF):
"""
Parameters
----------
th : TileHeader
th : TileContentHeader
glTF : GlTF
Returns
-------
b : TileBody
b : TileContentBody
"""

# build tile body
Expand All @@ -189,13 +189,13 @@ def from_array(th, array):
"""
Parameters
----------
th : TileHeader
th : TileContentHeader
array : numpy.array
Returns
-------
b : TileBody
b : TileContentBody
"""

# build feature table
Expand Down
2 changes: 1 addition & 1 deletion py3dtiles/feature_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def from_array(th, array):
"""
Parameters
----------
th : TileHeader
th : TileContentHeader
array : numpy.array
Expand Down
16 changes: 8 additions & 8 deletions py3dtiles/pnts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import struct
import numpy as np

from .tile import TileContent, TileHeader, TileBody, TileType
from .tile_content import TileContent, TileContentHeader, TileContentBody, TileContentType
from .feature_table import FeatureTable


Expand Down Expand Up @@ -68,11 +68,11 @@ def from_array(array):
return t


class PntsHeader(TileHeader):
class PntsHeader(TileContentHeader):
BYTELENGTH = 28

def __init__(self):
self.type = TileType.POINTCLOUD
self.type = TileContentType.POINTCLOUD
self.magic_value = b"pnts"
self.version = 1
self.tile_byte_length = 0
Expand Down Expand Up @@ -117,7 +117,7 @@ def from_array(array):
Returns
-------
h : TileHeader
h : TileContentHeader
"""

h = PntsHeader()
Expand All @@ -133,12 +133,12 @@ def from_array(array):
h.bt_json_byte_length = struct.unpack("i", array[20:24])[0]
h.bt_bin_byte_length = struct.unpack("i", array[24:28])[0]

h.type = TileType.POINTCLOUD
h.type = TileContentType.POINTCLOUD

return h


class PntsBody(TileBody):
class PntsBody(TileContentBody):
def __init__(self):
self.feature_table = FeatureTable()
# TODO : self.batch_table = BatchTable()
Expand All @@ -151,13 +151,13 @@ def from_array(th, array):
"""
Parameters
----------
th : TileHeader
th : TileContentHeader
array : numpy.array
Returns
-------
b : TileBody
b : TileContentBody
"""

# build feature table
Expand Down
2 changes: 1 addition & 1 deletion py3dtiles/points/task/pnts_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def points_to_pnts(name, points, out_folder, include_rgb):
body = py3dtiles.pnts.PntsBody()
body.feature_table = ft

tile = py3dtiles.tile.TileContent()
tile = py3dtiles.tile_content.TileContent()
tile.body = body
tile.header = py3dtiles.pnts.PntsHeader()
tile.header.sync(body)
Expand Down
6 changes: 3 additions & 3 deletions py3dtiles/tile.py → py3dtiles/tile_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ def sync(self):
self.header.sync(self.body)


class TileType(Enum):
class TileContentType(Enum):

UNKNWON = 0
POINTCLOUD = 1
BATCHED3DMODEL = 2


class TileHeader(ABC):
class TileContentHeader(ABC):
@abstractmethod
def from_array(self, array):
pass
Expand All @@ -55,7 +55,7 @@ def sync(self, body):
pass


class TileBody(object):
class TileContentBody(object):
@abstractmethod
def to_array(self):
pass

0 comments on commit 00dcdf3

Please sign in to comment.