Skip to content

Commit 317d918

Browse files
authored
Merge pull request #64 from zgpky/fix/polyline-material
Fix: flatten polyline materials and restrict Polyline.material types
2 parents d34662e + a7795c4 commit 317d918

File tree

3 files changed

+30
-98
lines changed

3 files changed

+30
-98
lines changed

src/czml3/properties.py

Lines changed: 14 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,10 @@ class Material(BaseCZMLObject):
7575
default=None
7676
)
7777
"""A material that fills the surface with a checkerboard pattern. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/CheckerboardMaterial>`__ for it's definition."""
78-
polylineOutline: (
79-
None | PolylineMaterial | PolylineOutline | TimeIntervalCollection
80-
) = Field(default=None) # NOTE: Not in documentation
81-
"""See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineOutline>`__ for it's definition."""
8278

8379

84-
class PolylineOutline(BaseCZMLObject):
85-
"""A definition of how a surface is colored or shaded.
80+
class PolylineOutlineMaterial(BaseCZMLObject):
81+
"""A material that fills the surface of a line with an outlined color.
8682
8783
See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineOutlineMaterial>`__ for it's definition.
8884
"""
@@ -95,20 +91,8 @@ class PolylineOutline(BaseCZMLObject):
9591
"""The width of the outline."""
9692

9793

98-
class PolylineOutlineMaterial(BaseCZMLObject):
99-
"""A definition of the material wrapper for a polyline outline.
100-
101-
See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineOutlineMaterial>`__ for it's definition.
102-
"""
103-
104-
polylineOutline: None | PolylineOutline | TimeIntervalCollection = Field(
105-
default=None
106-
)
107-
"""See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineOutline>`__ for it's definition."""
108-
109-
110-
class PolylineGlow(BaseCZMLObject):
111-
"""A definition of how a glowing polyline appears.
94+
class PolylineGlowMaterial(BaseCZMLObject):
95+
"""A material that fills the surface of a line with a glowing color.
11296
11397
See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineGlowMaterial>`__ for it's definition.
11498
"""
@@ -121,38 +105,18 @@ class PolylineGlow(BaseCZMLObject):
121105
"""The strength of the tapering effect. 1.0 and higher means no tapering."""
122106

123107

124-
class PolylineGlowMaterial(BaseCZMLObject):
125-
"""A material that fills the surface of a line with a glowing color.
126-
127-
See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineGlowMaterial>`__ for it's definition.
128-
"""
129-
130-
polylineGlow: None | PolylineGlow | TimeIntervalCollection = Field(default=None)
131-
"""See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineGlow>`__ for it's definition."""
132-
133-
134-
class PolylineArrow(BaseCZMLObject):
135-
"""A definition of how a polyline arrow appears.
136-
137-
See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineArrowMaterial>`__ for it's definition.
138-
"""
139-
140-
color: None | Color | str | TimeIntervalCollection = Field(default=None)
141-
"""The color of the surface. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Color>`__ for it's definition."""
142-
143-
144108
class PolylineArrowMaterial(BaseCZMLObject):
145109
"""A material that fills the surface of a line with an arrow.
146110
147111
See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineArrowMaterial>`__ for it's definition.
148112
"""
149113

150-
polylineArrow: None | PolylineArrow | TimeIntervalCollection = Field(default=None)
151-
"""See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineArrow>`__ for it's definition."""
114+
color: None | Color | str | TimeIntervalCollection = Field(default=None)
115+
"""The color of the surface. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Color>`__ for it's definition."""
152116

153117

154-
class PolylineDash(BaseCZMLObject):
155-
"""A definition of how a polyline should be dashed with two colors.
118+
class PolylineDashMaterial(BaseCZMLObject):
119+
"""A material that provides a how a polyline should be dashed.
156120
157121
See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineDashMaterial>`__ for it's definition.
158122
"""
@@ -167,16 +131,6 @@ class PolylineDash(BaseCZMLObject):
167131
"""A 16-bit bitfield representing which portions along a single dashLength are the dash (1) and which are the gap (0). The default value, 255 (0000000011111111), indicates 50% gap followed by 50% dash."""
168132

169133

170-
class PolylineDashMaterial(BaseCZMLObject):
171-
"""A material that provides a how a polyline should be dashed.
172-
173-
See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineDashMaterial>`__ for it's definition.
174-
"""
175-
176-
polylineDash: None | PolylineDash | TimeIntervalCollection = Field(default=None)
177-
"""See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineDash>`__ for it's definition."""
178-
179-
180134
class PolylineMaterial(BaseCZMLObject):
181135
"""A definition of how a surface is colored or shaded.
182136
@@ -809,31 +763,17 @@ class Polyline(BaseCZMLObject):
809763
"""The width of the polyline."""
810764
granularity: None | float | TimeIntervalCollection = Field(default=None)
811765
"""The sampling distance, in radians."""
812-
material: (
813-
None
814-
| PolylineMaterial
815-
| PolylineDashMaterial
816-
| PolylineArrowMaterial
817-
| PolylineGlowMaterial
818-
| PolylineOutlineMaterial
819-
| str
820-
| TimeIntervalCollection
821-
) = Field(default=None)
766+
material: None | PolylineMaterial | str | TimeIntervalCollection = Field(
767+
default=None
768+
)
822769
"""The material to use to draw the polyline. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Field>`__ for it's definition."""
823770
followSurface: None | bool | TimeIntervalCollection = Field(default=None)
824771
"""Whether or not the positions are connected as great arcs (the default) or as straight lines. This property has been superseded by `arcType`, which should be used instead."""
825772
shadows: None | ShadowMode | TimeIntervalCollection = Field(default=None)
826773
"""Whether or not the polyline casts or receives shadows. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/ShadowMode>`__ for it's definition."""
827-
depthFailMaterial: (
828-
None
829-
| PolylineMaterial
830-
| PolylineDashMaterial
831-
| PolylineArrowMaterial
832-
| PolylineGlowMaterial
833-
| PolylineOutlineMaterial
834-
| str
835-
| TimeIntervalCollection
836-
) = Field(default=None)
774+
depthFailMaterial: None | PolylineMaterial | str | TimeIntervalCollection = Field(
775+
default=None
776+
)
837777
"""The material to use to draw the polyline when it is below the terrain. See `here <https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Field>`__ for it's definition."""
838778
distanceDisplayCondition: (
839779
None | DistanceDisplayCondition | TimeIntervalCollection

tests/test_packet.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@
2424
Point,
2525
Polygon,
2626
Polyline,
27-
PolylineArrow,
2827
PolylineArrowMaterial,
29-
PolylineDash,
3028
PolylineDashMaterial,
31-
PolylineGlow,
3229
PolylineGlowMaterial,
3330
PolylineMaterial,
34-
PolylineOutline,
3531
PolylineOutlineMaterial,
3632
Position,
3733
PositionList,
@@ -406,8 +402,8 @@ def test_packet_polyline_outline():
406402
positions=PositionList(
407403
cartographicDegrees=[-75, 43, 500000, -125, 43, 500000]
408404
),
409-
material=PolylineOutlineMaterial(
410-
polylineOutline=PolylineOutline(
405+
material=PolylineMaterial(
406+
polylineOutline=PolylineOutlineMaterial(
411407
color=Color(rgba=[255, 0, 0, 255]),
412408
outlineColor=Color(rgba=[255, 0, 0, 255]),
413409
outlineWidth=2,
@@ -456,8 +452,8 @@ def test_packet_polyline_glow():
456452
positions=PositionList(
457453
cartographicDegrees=[-75, 43, 500000, -125, 43, 500000]
458454
),
459-
material=PolylineGlowMaterial(
460-
polylineGlow=PolylineGlow(
455+
material=PolylineMaterial(
456+
polylineGlow=PolylineGlowMaterial(
461457
color=Color(rgba=[255, 0, 0, 255]),
462458
glowPower=0.2,
463459
taperPower=0.5,
@@ -503,8 +499,8 @@ def test_packet_polyline_arrow():
503499
positions=PositionList(
504500
cartographicDegrees=[-75, 43, 500000, -125, 43, 500000]
505501
),
506-
material=PolylineArrowMaterial(
507-
polylineArrow=PolylineArrow(color=Color(rgba=[255, 0, 0, 255]))
502+
material=PolylineMaterial(
503+
polylineArrow=PolylineArrowMaterial(color=Color(rgba=[255, 0, 0, 255]))
508504
),
509505
),
510506
)
@@ -546,8 +542,8 @@ def test_packet_polyline_dashed():
546542
positions=PositionList(
547543
cartographicDegrees=[-75, 43, 500000, -125, 43, 500000]
548544
),
549-
material=PolylineDashMaterial(
550-
polylineDash=PolylineDash(color=Color(rgba=[255, 0, 0, 255]))
545+
material=PolylineMaterial(
546+
polylineDash=PolylineDashMaterial(color=Color(rgba=[255, 0, 0, 255]))
551547
),
552548
),
553549
)

tests/test_properties.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,10 @@
3737
Point,
3838
Polygon,
3939
Polyline,
40-
PolylineArrow,
4140
PolylineArrowMaterial,
42-
PolylineDash,
4341
PolylineDashMaterial,
44-
PolylineGlow,
4542
PolylineGlowMaterial,
4643
PolylineMaterial,
47-
PolylineOutline,
4844
PolylineOutlineMaterial,
4945
Position,
5046
PositionList,
@@ -266,8 +262,8 @@ def test_arrowmaterial_color():
266262
}
267263
}
268264
}"""
269-
pamat = PolylineArrowMaterial(
270-
polylineArrow=PolylineArrow(color=Color(rgba=[200, 100, 30, 255])),
265+
pamat = PolylineMaterial(
266+
polylineArrow=PolylineArrowMaterial(color=Color(rgba=[200, 100, 30, 255])),
271267
)
272268

273269
assert str(pamat) == expected_result
@@ -296,8 +292,8 @@ def test_dashmaterial_colors():
296292
"dashPattern": 255
297293
}
298294
}"""
299-
dashmat = PolylineDashMaterial(
300-
polylineDash=PolylineDash(
295+
dashmat = PolylineMaterial(
296+
polylineDash=PolylineDashMaterial(
301297
color=Color(rgba=[200, 100, 30, 255]),
302298
gapColor=Color(rgba=[100, 200, 0, 255]),
303299
dashLength=16,
@@ -323,8 +319,8 @@ def test_glowmaterial_color():
323319
"taperPower": 0.3
324320
}
325321
}"""
326-
glowmat = PolylineGlowMaterial(
327-
polylineGlow=PolylineGlow(
322+
glowmat = PolylineMaterial(
323+
polylineGlow=PolylineGlowMaterial(
328324
color=Color(rgba=[200, 100, 30, 255]), glowPower=0.7, taperPower=0.3
329325
)
330326
)
@@ -353,8 +349,8 @@ def test_outline_material_colors():
353349
"outlineWidth": 3.0
354350
}
355351
}"""
356-
omat = PolylineOutlineMaterial(
357-
polylineOutline=PolylineOutline(
352+
omat = PolylineMaterial(
353+
polylineOutline=PolylineOutlineMaterial(
358354
color=Color(rgba=[200, 100, 30, 255]),
359355
outlineColor=Color(rgba=[100, 200, 0, 255]),
360356
outlineWidth=3,

0 commit comments

Comments
 (0)