Skip to content

Commit

Permalink
Merge pull request #18 from Stoops-ML/v2.2.1
Browse files Browse the repository at this point in the history
V2.2.1
  • Loading branch information
Stoops-ML authored Dec 20, 2024
2 parents 9b3b3b1 + a85b7b4 commit a709797
Show file tree
Hide file tree
Showing 9 changed files with 498 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v2.2.1

* Expand preamble checking in Document()
* Box() requires dimensions
* Rectangle() requires coordinates
* Reinstate LICENSE file (required for conda)

# v2.2.0

* Add readthedocs support
Expand Down
27 changes: 27 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
BSD-3-Clause license
Copyright (c) 2015-2022, conda-forge contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
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.0"
__version__ = "2.2.1"

__all__ = ["Document", "Packet", "CZML_VERSION"]
34 changes: 32 additions & 2 deletions src/czml3/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,40 @@ class Document(BaseCZMLObject):
@field_validator("packets")
@classmethod
def validate_packets(cls, packets):
if packets[0].version is None:
if packets[0].version is None or packets[0].name is None:
raise ValueError(
"The first packet must be a preamble and include `version`"
"The first packet must be a preamble and include 'version' and 'name' properties."
)
if packets[0].id != "document":
raise ValueError("The first packet must have an ID of 'document'.")
for p in (
"delete",
"parent",
"availability",
"properties",
"position",
"orientation",
"viewFrom",
"billboard",
"box",
"corridor",
"cylinder",
"ellipse",
"ellipsoid",
"label",
"model",
"path",
"point",
"polygon",
"polyline",
"rectangle",
"tileset",
"wall",
):
if getattr(packets[0], p) is not None:
raise ValueError(
f"The first packet must not include the '{p}' property"
)
return packets

@model_serializer
Expand Down
6 changes: 2 additions & 4 deletions src/czml3/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ class Box(BaseCZMLObject):

show: None | bool | TimeIntervalCollection = Field(default=None)
"""Whether or not the box is shown."""
dimensions: None | BoxDimensions | TimeIntervalCollection = Field(default=None)
dimensions: BoxDimensions | TimeIntervalCollection = Field()
"""The dimensions of the box. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/BoxDimensions>`__ for it's definition."""
heightReference: None | HeightReference | TimeIntervalCollection = Field(
default=None
Expand Down Expand Up @@ -1164,9 +1164,7 @@ class Rectangle(BaseCZMLObject, Interpolatable, Deletable):

show: None | bool | TimeIntervalCollection = Field(default=None)
"""Whether or not the rectangle is shown."""
coordinates: None | RectangleCoordinates | TimeIntervalCollection = Field(
default=None
)
coordinates: None | RectangleCoordinates | TimeIntervalCollection = Field()
"""The coordinates of the rectangle. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/RectangleCoordinates>`__ for it's definition."""
fill: None | bool | TimeIntervalCollection = Field(default=None)
"""Whether or not the rectangle is filled."""
Expand Down
4 changes: 3 additions & 1 deletion src/czml3/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@

class CZMLWidget(BaseModel):
document: Document = Field(
default=Document(packets=[Packet(id="document", version=CZML_VERSION)])
default=Document(
packets=[Packet(id="document", name="name", version=CZML_VERSION)]
)
)
cesium_version: str = Field(default="1.88")
ion_token: str = Field(default="")
Expand Down
15 changes: 9 additions & 6 deletions tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def test_document_has_expected_packets():
preamble = Packet(version=CZML_VERSION)
preamble = Packet(version=CZML_VERSION, name="document", id="document")
packet0 = Packet(id="id_00")
packet1 = Packet(id="id_01")

Expand All @@ -12,10 +12,11 @@ def test_document_has_expected_packets():


def test_doc_repr():
packet = Packet(id="id_00", version=CZML_VERSION)
packet = Packet(id="document", name="name", version=CZML_VERSION)
expected_result = """[
{
"id": "id_00",
"id": "document",
"name": "name",
"version": "CZML_VERSION"
}
]""".replace("CZML_VERSION", CZML_VERSION)
Expand All @@ -26,9 +27,11 @@ def test_doc_repr():


def test_doc_dumps():
packet = Packet(id="id_00", version=CZML_VERSION)
expected_result = """[{"id":"id_00","version":"CZML_VERSION"}]""".replace(
"CZML_VERSION", CZML_VERSION
packet = Packet(id="document", version=CZML_VERSION, name="name")
expected_result = (
"""[{"id":"document","name":"name","version":"CZML_VERSION"}]""".replace(
"CZML_VERSION", CZML_VERSION
)
)

document = Document(packets=[packet])
Expand Down
Loading

0 comments on commit a709797

Please sign in to comment.