Skip to content

Commit

Permalink
Merge pull request #63 from jtodevs/master
Browse files Browse the repository at this point in the history
Added properties
  • Loading branch information
astrojuanlu authored Apr 12, 2020
2 parents 6823df7 + 53a8e6d commit 328608f
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/czml3/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,22 @@ class Packet(BaseCZMLObject):
properties = attr.ib(default=None)
position = attr.ib(default=None)
orientation = attr.ib(default=None)
viewFrom = attr.ib(default=None)
billboard = attr.ib(default=None)
box = attr.ib(default=None)
corridor = attr.ib(default=None)
cylinder = attr.ib(default=None)
ellipse = attr.ib(default=None)
ellipsoid = attr.ib(default=None)
label = attr.ib(default=None)
model = attr.ib(default=None)
path = attr.ib(default=None)
point = attr.ib(default=None)
polygon = attr.ib(default=None)
polyline = attr.ib(default=None)
rectangle = attr.ib(default=None)
tileset = attr.ib(default=None)
wall = attr.ib(default=None)


@attr.s(repr=False, frozen=True)
Expand Down
103 changes: 103 additions & 0 deletions src/czml3/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class Position(BaseCZMLObject, Interpolatable, Deletable):
cartesian = attr.ib(default=None)
cartographicRadians = attr.ib(default=None)
cartographicDegrees = attr.ib(default=None)
cartesianVelocity = attr.ib(default=None)
reference = attr.ib(default=None)

def __attrs_post_init__(self,):
if all(
Expand All @@ -146,6 +148,8 @@ def __attrs_post_init__(self,):
self.cartesian,
self.cartographicDegrees,
self.cartographicRadians,
self.cartesianVelocity,
self.reference,
)
):
raise ValueError(
Expand Down Expand Up @@ -175,6 +179,77 @@ class EllipsoidRadii(BaseCZMLObject, Interpolatable, Deletable):
reference = attr.ib(default=None)


@attr.s(repr=False, frozen=True, kw_only=True)
class Corridor(BaseCZMLObject):
"""A corridor , which is a shape defined by a centerline and width that conforms to the
curvature of the body shape. It can can optionally be extruded into a volume."""

positions = attr.ib()
show = attr.ib(default=None)
width = attr.ib()
height = attr.ib(default=None)
heightReference = attr.ib(default=None)
extrudedHeight = attr.ib(default=None)
extrudedHeightReference = attr.ib(default=None)
cornerType = attr.ib(default=None)
granularity = attr.ib(default=None)
fill = attr.ib(default=None)
material = attr.ib(default=None)
outline = attr.ib(default=None)
outlineColor = attr.ib(default=None)
outlineWidth = attr.ib(default=None)
shadows = attr.ib(default=None)
distanceDisplayCondition = attr.ib(default=None)
classificationType = attr.ib(default=None)
zIndex = attr.ib(default=None)


@attr.s(repr=False, frozen=True, kw_only=True)
class Cylinder(BaseCZMLObject):
"""A cylinder, which is a special cone defined by length, top and bottom radius."""

length = attr.ib()
show = attr.ib(default=None)
topRadius = attr.ib()
bottomRadius = attr.ib()
heightReference = attr.ib(default=None)
fill = attr.ib(default=None)
material = attr.ib(default=None)
outline = attr.ib(default=None)
outlineColor = attr.ib(default=None)
outlineWidth = attr.ib(default=None)
numberOfVerticalLines = attr.ib(default=None)
slices = attr.ib(default=None)
shadows = attr.ib(default=None)
distanceDisplayCondition = attr.ib(default=None)


@attr.s(repr=False, frozen=True, kw_only=True)
class Ellipse(BaseCZMLObject):
"""An ellipse, which is a close curve, on or above Earth's surface."""

semiMajorAxis = attr.ib()
semiMinorAxis = attr.ib()
show = attr.ib(default=None)
height = attr.ib(default=None)
heightReference = attr.ib(default=None)
extrudedHeight = attr.ib(default=None)
extrudedHeightReference = attr.ib(default=None)
rotation = attr.ib(default=None)
stRotation = attr.ib(default=None)
granularity = attr.ib(default=None)
fill = attr.ib(default=None)
material = attr.ib(default=None)
outline = attr.ib(default=None)
outlineColor = attr.ib(default=None)
outlineWidth = attr.ib(default=None)
numberOfVerticalLines = attr.ib(default=None)
shadows = attr.ib(default=None)
distanceDisplayCondition = attr.ib(default=None)
classificationType = attr.ib(default=None)
zIndex = attr.ib(default=None)


@attr.s(repr=False, frozen=True, kw_only=True)
class Polygon(BaseCZMLObject):
"""A polygon, which is a closed figure on the surface of the Earth."""
Expand Down Expand Up @@ -396,6 +471,34 @@ class Point(BaseCZMLObject):
disableDepthTestDistance = attr.ib(default=None)


@attr.s(repr=False, frozen=True, kw_only=True)
class TileSet(BaseCZMLObject):
"""A 3D Tiles tileset."""

show = attr.ib(default=None)
uri = attr.ib()
maximumScreenSpaceError = attr.ib(default=None)


@attr.s(repr=False, frozen=True, kw_only=True)
class Wall(BaseCZMLObject):
"""A two-dimensional wall defined as a line strip and optional maximum and minimum heights.
It conforms to the curvature of the globe and can be placed along the surface or at altitude."""

show = attr.ib(default=None)
positions = attr.ib()
minimumHeights = attr.ib(default=None)
maximumHeights = attr.ib(default=None)
granularity = attr.ib(default=None)
fill = attr.ib(default=None)
material = attr.ib(default=None)
outline = attr.ib(default=None)
outlineColor = attr.ib(default=None)
outlineWidth = attr.ib(default=None)
shadows = attr.ib(default=None)
distanceDisplayCondition = attr.ib(default=None)


@attr.s(repr=False, frozen=True, kw_only=True)
class NearFarScalar(BaseCZMLObject, Interpolatable, Deletable):
""" A numeric value which will be linearly interpolated between two values based on an object's distance from the
Expand Down
30 changes: 30 additions & 0 deletions tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
ClassificationType,
Color,
DistanceDisplayCondition,
Ellipsoid,
EllipsoidRadii,
EyeOffset,
GridMaterial,
ImageMaterial,
Expand Down Expand Up @@ -364,6 +366,15 @@ def test_position_cartographic_degrees():
assert repr(pos) == expected_result


def test_position_reference():
expected_result = """{
"reference": "satellite"
}"""
pos = Position(reference="satellite")

assert repr(pos) == expected_result


def test_single_interval_value():
expected_result = """{
"interval": "2019-01-01T00:00:00Z/2019-01-02T00:00:00Z",
Expand Down Expand Up @@ -436,3 +447,22 @@ def test_bad_uri_raises_error():
Uri(uri="a")

assert "uri must be a URL or a data URI" in excinfo.exconly()


def test_ellisoid():
expected_result = """{
"radii": {
"cartesian": [
20.0,
30.0,
40.0
]
},
"fill": false,
"outline": true
}"""

ell = Ellipsoid(
radii=EllipsoidRadii(cartesian=[20.0, 30.0, 40.0]), fill=False, outline=True
)
assert repr(ell) == expected_result

0 comments on commit 328608f

Please sign in to comment.