From c950d0fa60399f07e8dfa4ea84c642712d4c3d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Wed, 6 Nov 2019 11:06:51 +0100 Subject: [PATCH] =?UTF-8?q?Remove=20KNOWN=5FPROPERTIES=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/czml3/base.py | 3 +- src/czml3/core.py | 30 ----- src/czml3/properties.py | 243 +--------------------------------------- 3 files changed, 7 insertions(+), 269 deletions(-) diff --git a/src/czml3/base.py b/src/czml3/base.py index 5783013..22dc3dd 100644 --- a/src/czml3/base.py +++ b/src/czml3/base.py @@ -28,7 +28,6 @@ def default(self, o): @attr.s(repr=False, frozen=True) class BaseCZMLObject: - KNOWN_PROPERTIES = [] # type: List[str] def __repr__(self): return self.dumps(indent=4) @@ -48,7 +47,7 @@ def to_json(self): if getattr(self, "delete", False): properties_list = NON_DELETE_PROPERTIES else: - properties_list = self.KNOWN_PROPERTIES + properties_list = list(attr.asdict(self).keys()) obj_dict = {} for property_name in properties_list: diff --git a/src/czml3/core.py b/src/czml3/core.py index 5e0bfa5..8da3167 100644 --- a/src/czml3/core.py +++ b/src/czml3/core.py @@ -12,8 +12,6 @@ class Preamble(BaseCZMLObject): """The preamble packet.""" - KNOWN_PROPERTIES = ["id", "version", "name", "clock"] - version = attr.ib(default=CZML_VERSION) name = attr.ib(default=None) clock = attr.ib(default=None) @@ -31,34 +29,6 @@ class Packet(BaseCZMLObject): for further information. """ - # https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Packet - KNOWN_PROPERTIES = [ - "id", - "delete", - "name", - "parent", - "description", - "availability", - "properties", - "position", - "orientation", - "viewFrom", - "billboard", - "box", - "corridor", - "cylinder", - "ellipse", - "ellipsoid", - "label", - "model", - "path", - "point", - "polygon", - "polyline", - "rectangle", - "wall", - ] - id = attr.ib(factory=lambda: str(uuid4())) delete = attr.ib(default=None) name = attr.ib(default=None) diff --git a/src/czml3/properties.py b/src/czml3/properties.py index d1763f9..9ce5a95 100644 --- a/src/czml3/properties.py +++ b/src/czml3/properties.py @@ -19,8 +19,6 @@ class Material(BaseCZMLObject): """A definition of how a surface is colored or shaded.""" - KNOWN_PROPERTIES = ["solidColor", "image", "grid", "stripe", "checkerboard"] - solidColor = attr.ib( default=None, converter=lambda c: SolidColorMaterial(color=c) if isinstance(c, Color) else c, @@ -35,18 +33,6 @@ class Material(BaseCZMLObject): class PolylineMaterial(BaseCZMLObject): """"A definition of how a surface is colored or shaded.""" - KNOWN_PROPERTIES = [ - "solidColor", - "polylineOutline", - "polylineArrow", - "polylineDash", - "polylineGlow", - "image", - "grid", - "stripe", - "checkerboard", - ] - solidColor = attr.ib( default=None, converter=lambda c: SolidColorMaterial(color=c) if isinstance(c, Color) else c, @@ -61,8 +47,6 @@ class PolylineMaterial(BaseCZMLObject): class SolidColorMaterial(BaseCZMLObject): """A material that fills the surface with a solid color.""" - KNOWN_PROPERTIES = ["color"] - color = attr.ib(default=None) @@ -70,14 +54,6 @@ class SolidColorMaterial(BaseCZMLObject): class GridMaterial(BaseCZMLObject): """A material that fills the surface with a two-dimensional grid.""" - KNOWN_PROPERTIES = [ - "color", - "cellAlpha", - "lineCount", - "lineThickness", - "lineOffset", - ] - color = attr.ib(default=None) cellAlpha = attr.ib(default=0.1) lineCount = attr.ib(default=[8, 8]) @@ -89,8 +65,6 @@ class GridMaterial(BaseCZMLObject): class StripeMaterial(BaseCZMLObject): """A material that fills the surface with alternating colors.""" - KNOWN_PROPERTIES = ["orientation", "evenColor", "oddColor", "offset", "repeat"] - orientation = attr.ib( default="HORIZONTAL" ) # TODO: https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/StripeOrientationValue @@ -104,8 +78,6 @@ class StripeMaterial(BaseCZMLObject): class CheckerboardMaterial(BaseCZMLObject): """A material that fills the surface with alternating colors.""" - KNOWN_PROPERTIES = ["orientation", "evenColor", "oddColor", "offset", "repeat"] - evenColor = attr.ib(default=None) oddColor = attr.ib(default=None) repeat = attr.ib(default=None) @@ -115,8 +87,6 @@ class CheckerboardMaterial(BaseCZMLObject): class ImageMaterial(BaseCZMLObject): """A material that fills the surface with an image.""" - KNOWN_PROPERTIES = ["image", "repeat", "color", "transparent"] - image = attr.ib(default=None) repeat = attr.ib(default=[1, 1]) color = attr.ib(default=None) @@ -127,8 +97,6 @@ class ImageMaterial(BaseCZMLObject): class Color(BaseCZMLObject, Interpolatable, Deletable): """A color. The color can optionally vary over time.""" - KNOWN_PROPERTIES = ["delete", "rgba", "rgbaf", "reference"] - delete = attr.ib(default=None) rgba = attr.ib( default=None, @@ -145,17 +113,6 @@ class Color(BaseCZMLObject, Interpolatable, Deletable): class Position(BaseCZMLObject, Interpolatable, Deletable): """Defines a position. The position can optionally vary over time.""" - KNOWN_PROPERTIES = [ - "delete", - "epoch", - "interpolationAlgorithm", - "interpolationDegree", - "referenceFrame", - "cartesian", - "cartographicRadians", - "cartographicDegrees", - ] - delete = attr.ib(default=None) epoch = attr.ib(default=None) interpolationAlgorithm = attr.ib(default=None) @@ -201,29 +158,6 @@ class Billboard(BaseCZMLObject, HasAlignment): A billboard is sometimes called a marker. """ - KNOWN_PROPERTIES = [ - "show", - "image", - "scale", - "pixelOffset", - "eyeOffset", - "horizontalOrigin", - "verticalOrigin", - "heightReference", - "color", - "rotation", - "alignedAxis", - "sizeInMeters", - "width", - "height", - "scaleByDistance", - "translucencyByDistance", - "pixelOffsetScaleByDistance", - "imageSubRegion", - "distanceDisplayCondition", - "disableDepthTestDistance", - ] - image = attr.ib(converter=lambda i: Uri(uri=i) if isinstance(i, str) else i) show = attr.ib(default=None) scale = attr.ib(default=None) @@ -235,8 +169,6 @@ class Billboard(BaseCZMLObject, HasAlignment): class EllipsoidRadii(BaseCZMLObject, Deletable, Interpolatable): """The radii of an ellipsoid.""" - KNOWN_PROPERTIES = ["cartesian", "reference"] - cartesian = attr.ib(default=None) reference = attr.ib(default=None) @@ -245,31 +177,6 @@ class EllipsoidRadii(BaseCZMLObject, Deletable, Interpolatable): class Polygon(BaseCZMLObject): """A polygon, which is a closed figure on the surface of the Earth.""" - KNOWN_PROPERTIES = [ - "show", - "positions", - "holes", - "arcType", - "height", - "heightReference", - "extrudedHeight", - "extrudedHeightReference", - "stRotation", - "granularity", - "fill", - "material", - "outline", - "outlineColor", - "outlineWidth", - "perPositionHeight", - "closeTop", - "closeBottom", - "shadows", - "distanceDisplayCondition", - "classificationType", - "zIndex", - ] - positions = attr.ib() show = attr.ib(default=None) arcType = attr.ib(default=None) @@ -285,22 +192,6 @@ class Polygon(BaseCZMLObject): class Polyline(BaseCZMLObject): """A polyline, which is a line in the scene composed of multiple segments.""" - KNOWN_PROPERTIES = [ - "show", - "positions", - "arcType", - "width", - "granularity", - "material", - "followSurface", - "shadows", - "depthFailMaterial", - "distanceDisplayCondition", - "clampToGround", - "classificationType", - "zIndex", - ] - positions = attr.ib() show = attr.ib(default=None) arcType = attr.ib(default=None) @@ -320,8 +211,6 @@ class Polyline(BaseCZMLObject): class ArcType(BaseCZMLObject, Deletable): """The type of an arc.""" - KNOWN_PROPERTIES = ["arcType", "reference"] - arcType = attr.ib(default=None) reference = attr.ib(default=None) @@ -330,8 +219,6 @@ class ArcType(BaseCZMLObject, Deletable): class ShadowMode(BaseCZMLObject, Deletable): """Whether or not an object casts or receives shadows from each light source when shadows are enabled.""" - KNOWN_PROPERTIES = ["shadowMode", "reference"] - shadowMode = attr.ib(default=None) referenec = attr.ib(default=None) @@ -340,8 +227,6 @@ class ShadowMode(BaseCZMLObject, Deletable): class ClassificationType(BaseCZMLObject, Deletable): """Whether a classification affects terrain, 3D Tiles, or both.""" - KNOWN_PROPERTIES = ["classificationType", "reference"] - classificationType = attr.ib(default=None) reference = attr.ib(default=None) @@ -350,8 +235,6 @@ class ClassificationType(BaseCZMLObject, Deletable): class DistanceDisplayCondition(BaseCZMLObject, Interpolatable, Deletable): """Indicates the visibility of an object based on the distance to the camera.""" - KNOWN_PROPERTIES = ["distanceDisplayCondition", "reference"] - distanceDisplayCondition = attr.ib(default=None) reference = attr.ib(default=None) @@ -360,14 +243,6 @@ class DistanceDisplayCondition(BaseCZMLObject, Interpolatable, Deletable): class PositionList(BaseCZMLObject, Deletable): """A list of positions.""" - KNOWN_PROPERTIES = [ - "referenceFrame", - "cartersian", - "cartographicRadians", - "cartographicDegrees", - "references", - ] - referenceFrame = attr.ib(default=None) cartesian = attr.ib(default=None) cartographicRadians = attr.ib(default=None) @@ -379,22 +254,6 @@ class PositionList(BaseCZMLObject, Deletable): class Ellipsoid(BaseCZMLObject): """A closed quadric surface that is a three-dimensional analogue of an ellipse.""" - KNOWN_PROPERTIES = [ - "radii", - "show", - "heightReference", - "fill", - "material", - "outline", - "outlineColor", - "outlineWidth", - "stackPartitions", - "slicePartitions", - "subdivisions", - "shadows", - "distanceDisplayCondition", - ] - radii = attr.ib() show = attr.ib(default=None) heightReference = attr.ib(default=None) @@ -412,19 +271,6 @@ class Ellipsoid(BaseCZMLObject): class Box(BaseCZMLObject): """A box, which is a closed rectangular cuboid.""" - KNOWN_PROPERTIES = [ - "show", - "dimensions", - "heightReference", - "fill", - "material", - "outline", - "outlineColor", - "outlineWidth", - "shadows", - "distanceDisplayCondition", - ] - show = attr.ib(default=None) dimensions = attr.ib(default=None) heightReference = attr.ib(default=None) @@ -441,17 +287,19 @@ class Box(BaseCZMLObject): class BoxDimensions(BaseCZMLObject, Interpolatable): """The width, depth, and height of a box.""" - KNOWN_PROPERTIES = ["cartesian", "reference"] - cartesian = attr.ib(default=None) reference = attr.ib(default=None) @attr.s(repr=False, frozen=True, kw_only=True) class EyeOffset(BaseCZMLObject, Deletable): - """An offset in eye coordinates which can optionally vary over time. Eye coordinates are a left-handed coordinate system where the X-axis points toward the viewer's right, the Y-axis poitns up, and the Z-axis points into the screen.""" + """An offset in eye coordinates which can optionally vary over time. + + Eye coordinates are a left-handed coordinate system + where the X-axis points toward the viewer's right, + the Y-axis poitns up, and the Z-axis points into the screen. - KNOWN_PROPERTIES = ["cartesian", "reference"] + """ cartesian = attr.ib(default=None) reference = attr.ib(default=None) @@ -461,8 +309,6 @@ class EyeOffset(BaseCZMLObject, Deletable): class HeightReference(BaseCZMLObject, Deletable): """The height reference of an object, which indicates if the object's position is relative to terrain or not.""" - KNOWN_PROPERTIES = ["heightReference", "reference"] - heightReference = attr.ib(default=None) reference = attr.ib(default=None) @@ -476,8 +322,6 @@ class Clock(BaseCZMLObject): """ - KNOWN_PROPERTIES = ["currentTime", "multiplier", "range", "step"] - currentTime = attr.ib(default=None) multiplier = attr.ib(default=1.0) range = attr.ib(default=ClockRanges.LOOP_STOP) @@ -497,16 +341,6 @@ class Path(BaseCZMLObject): """ - KNOWN_PROPERTIES = [ - "show", - "leadTime", - "trailTime", - "width", - "resolution", - "material", - "distanceDisplayCondition", - ] - show = attr.ib(default=None) leadTime = attr.ib(default=None) trailTime = attr.ib(default=None) @@ -520,19 +354,6 @@ class Path(BaseCZMLObject): class Point(BaseCZMLObject): """A point, or viewport-aligned circle.""" - KNOWN_PROPERTIES = [ - "show", - "pixelSize", - "heightReference", - "color", - "outlineColor", - "outlineWidth", - "scaleByDistance", - "translucencyByDistance", - "distanceDisplayCondition", - "disableDepthTestDistance", - ] - show = attr.ib(default=None) pixelSize = attr.ib(default=None) heightReference = attr.ib(default=None) @@ -555,8 +376,6 @@ class NearFarScalar(BaseCZMLObject, Interpolatable, Deletable): less than the near distance or greater than the far distance, respectively. """ - KNOWN_PROPERTIES = ["nearFarScalar", "reference"] - nearFarScalar = attr.ib(default=None) reference = attr.ib(default=None) @@ -566,30 +385,6 @@ class NearFarScalar(BaseCZMLObject, Interpolatable, Deletable): class Label(BaseCZMLObject, HasAlignment): """A string of text.""" - KNOWN_PROPERTIES = [ - "show", - "text", - "font", - "style", - "scale", - "showBackground", - "backgroundColor", - "backgroundPadding", - "pixelOffset", - "eyeOffset", - "horizontalOrigin", - "verticalOrigin", - "heightReference", - "fillColor", - "outlineColor", - "outlineWidth", - "translucencyByDistance", - "pixelOffsetScaleByDistance", - "scaleByDistance", - "distanceDisplayCondition", - "disableDepthTestDistance", - ] - show = attr.ib(default=True) text = attr.ib(default=None) font = attr.ib( @@ -615,12 +410,6 @@ class Orientation(BaseCZMLObject): """ - KNOWN_PROPERTIES = [ - "unitQuaternion", - "reference", - "velocityReference", - ] - unitQuaternion = attr.ib( default=None, converter=lambda q: UnitQuaternionValue(values=q) @@ -635,26 +424,6 @@ class Orientation(BaseCZMLObject): class Model(BaseCZMLObject): """A 3D model.""" - KNOWN_PROPERTIES = [ - "show", - "gltf", - "scale", - "minimumPixelSize", - "maximumScale", - "incrementallyLoadTextures", - "runAnimations", - "shadows", - "heightReference", - "silhouetteColor", - "silhouetteSize", - "color", - "colorBlendMode", - "colorBlendAmount", - "distanceDisplayCondition", - "nodeTransformations", - "articulations", - ] - show = attr.ib(default=None) gltf = attr.ib(converter=lambda u: Uri(uri=u) if not isinstance(u, Uri) else u) scale = attr.ib(default=None)