From 9af16fce716f28e8c43b4a8f8f9e8f63344f8df6 Mon Sep 17 00:00:00 2001 From: Darren Eberly Date: Mon, 1 Jun 2020 21:26:29 -0400 Subject: [PATCH] feature: implemented polyline casting --- pytiled_parser/tiled_object.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pytiled_parser/tiled_object.py b/pytiled_parser/tiled_object.py index 3865aed..7109350 100644 --- a/pytiled_parser/tiled_object.py +++ b/pytiled_parser/tiled_object.py @@ -302,7 +302,21 @@ def _cast_polygon(raw_tiled_object: RawTiledObject) -> Polygon: def _cast_polyline(raw_tiled_object: RawTiledObject) -> Polyline: - raise NotImplementedError + """ Cast the raw_tiled_object to a Polyline object. + + Args: + raw_tiled_object: Raw Tiled Object to be casted to a Polyline + + Returns: + Polyline: The Polyline object created from the raw_tiled_object + """ + polyline = [] + for point in raw_tiled_object["polyline"]: + polyline.append(OrderedPair(point["x"], point["y"])) + + return Polyline( + points=polyline, **_get_common_attributes(raw_tiled_object).__dict__ + ) def _cast_text(raw_tiled_object: RawTiledObject) -> Text: