Skip to content
2 changes: 1 addition & 1 deletion src/czml3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .core import CZML_VERSION, Document, Packet

__version__ = "2.2.2"
__version__ = "2.2.3"

__all__ = ["Document", "Packet", "CZML_VERSION"]
43 changes: 22 additions & 21 deletions src/czml3/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from urllib.parse import urlparse

from pydantic import (
BaseModel,
Field,
field_validator,
model_serializer,
Expand Down Expand Up @@ -54,24 +53,10 @@
)


class HasAlignment(BaseModel):
"""A property that can be horizontally or vertically aligned."""

horizontalOrigin: None | HorizontalOrigins | TimeIntervalCollection = Field(
default=None
)
""" See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/HorizontalOrigin>`__ for it's definition."""
verticalOrigin: None | VerticalOrigins | TimeIntervalCollection = Field(
default=None
)
""" See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/VerticalOrigin>`__ for it's definition."""


class Material(BaseCZMLObject):
"""A definition of how a surface is colored or shaded.

See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Material>`__ for it's definition.
"""
See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Material>`__ for it's definition."""

solidColor: None | SolidColorMaterial | str | TimeIntervalCollection = Field(
default=None
Expand Down Expand Up @@ -458,7 +443,7 @@ def validate_reference(cls, r):
return r


class Billboard(BaseCZMLObject, HasAlignment):
class Billboard(BaseCZMLObject):
"""A billboard, or viewport-aligned image. The billboard is positioned in the scene by the position property. A billboard is sometimes called a marker.

See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Billboard>`__ for it's definition."""
Expand All @@ -477,6 +462,14 @@ class Billboard(BaseCZMLObject, HasAlignment):
"""The eye offset of the billboard, which is the offset in eye coordinates at which to place the billboard relative to the position property. Eye coordinates are a left-handed coordinate system where the X-axis points toward the viewer's right, the Y-axis points up, and the Z-axis points into the screen. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/EyeOffset>`__ for it's definition."""
color: None | Color | str | TimeIntervalCollection = Field(default=None)
"""The color of the billboard. This color value is multiplied with the values of the billboard's image to produce the final color. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Color>`__ for it's definition."""
horizontalOrigin: None | HorizontalOrigins | TimeIntervalCollection = Field(
default=None
)
""" See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/HorizontalOrigin>`__ for it's definition."""
verticalOrigin: None | VerticalOrigins | TimeIntervalCollection = Field(
default=None
)
""" See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/VerticalOrigin>`__ for it's definition."""

@field_validator("eyeOffset")
@classmethod
Expand Down Expand Up @@ -955,7 +948,7 @@ def validate_cartographicDegrees(cls, r):
return r


class PositionList(BaseCZMLObject, Interpolatable, Deletable):
class PositionList(BaseCZMLObject, Deletable):
"""A list of positions.

See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PositionList>`__ for it's definition."""
Expand Down Expand Up @@ -1128,7 +1121,7 @@ class Box(BaseCZMLObject):
"""The display condition specifying the distance from the camera at which this box will be displayed. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/DistanceDisplayCondition>`__ for it's definition."""


class BoxDimensions(BaseCZMLObject, Interpolatable):
class BoxDimensions(BaseCZMLObject, Interpolatable, Deletable):
"""The width, depth, and height of a box.

See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/BoxDimensions>`__ for it's definition."""
Expand Down Expand Up @@ -1157,7 +1150,7 @@ def validate_reference(cls, r):
return r


class Rectangle(BaseCZMLObject, Interpolatable, Deletable):
class Rectangle(BaseCZMLObject):
"""A cartographic rectangle, which conforms to the curvature of the globe and can be placed on the surface or at altitude and can optionally be extruded into a volume.

See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Rectangle>`__ for it's definition."""
Expand Down Expand Up @@ -1457,7 +1450,7 @@ def validate_nearFarScalar(cls, r):
return r


class Label(BaseCZMLObject, HasAlignment):
class Label(BaseCZMLObject):
"""A string of text.

See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Label>`__ for it's definition."""
Expand Down Expand Up @@ -1488,6 +1481,14 @@ class Label(BaseCZMLObject, HasAlignment):
"""The offset, in viewport pixels, of the label origin from the position. A pixel offset is the number of pixels up and to the right to place the label, relative to the `position`. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PixelOffset>`__ for it's definition."""
eyeOffset: None | EyeOffset | TimeIntervalCollection = Field(default=None)
"""The eye offset of the label, which is the offset in eye coordinates at which to place the label relative to the position property. Eye coordinates are a left-handed coordinate system where the X-axis points toward the viewer's right, the Y-axis points up, and the Z-axis points into the screen. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/EyeOffset>`__ for it's definition."""
horizontalOrigin: None | HorizontalOrigins | TimeIntervalCollection = Field(
default=None
)
""" See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/HorizontalOrigin>`__ for it's definition."""
verticalOrigin: None | VerticalOrigins | TimeIntervalCollection = Field(
default=None
)
""" See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/VerticalOrigin>`__ for it's definition."""


class Orientation(BaseCZMLObject, Interpolatable, Deletable):
Expand Down
12 changes: 5 additions & 7 deletions src/czml3/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,23 @@ def check_reference(r):
)


def format_datetime_like(dt_object):
def format_datetime_like(dt_object: None | str | dt.datetime) -> str | None:
if dt_object is None:
result = dt_object
return dt_object

elif isinstance(dt_object, str):
try:
parse_iso_date(dt_object)
except Exception:
raise
else:
result = dt_object
return dt_object

elif isinstance(dt_object, dt.datetime):
result = dt_object.strftime(ISO8601_FORMAT_Z)
return dt_object.strftime(ISO8601_FORMAT_Z)

else:
result = dt_object.strftime(ISO8601_FORMAT_Z)

return result
raise TypeError(f"Invalid datetime format: {dt_object}")


class FontValue(BaseCZMLObject):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ def test_outline_material_colors():

def test_positionlist_epoch():
expected_result = """{
"epoch": "2019-06-11T12:26:58.000000Z",
"cartographicDegrees": [
200.0,
100.0,
30.0
]
],
"epoch": "2019-06-11T12:26:58.000000Z"
}"""
p = PositionList(
epoch=dt.datetime(2019, 6, 11, 12, 26, 58, tzinfo=dt.timezone.utc),
Expand Down
12 changes: 12 additions & 0 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,18 @@ def test_check_reference():

def test_format_datetime_like():
assert format_datetime_like(None) is None
assert (
format_datetime_like("2019-01-01T12:00:00.000000Z")
== "2019-01-01T12:00:00.000000Z"
)
assert (
format_datetime_like(dt.datetime(2019, 1, 1, 12))
== "2019-01-01T12:00:00.000000Z"
)
with pytest.raises(ValueError):
format_datetime_like("test")
with pytest.raises(TypeError):
format_datetime_like(1) # type: ignore[arg-type]


def test_reference_list():
Expand Down
Loading