From 08cf7ca4b137f036f4cbc4109cffb55683b003ec Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Tue, 29 Sep 2020 01:01:10 -0700 Subject: [PATCH] avoid calling to_polygons on Polygons (for speed) --- masque/file/klamath.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/masque/file/klamath.py b/masque/file/klamath.py index 97fe7e0..c70f704 100644 --- a/masque/file/klamath.py +++ b/masque/file/klamath.py @@ -454,6 +454,14 @@ def _shapes_to_elements(shapes: List[Shape], extension=extension, properties=properties) elements.append(path) + elif isinstance(shape, Polygon): + polygon = shape + xy_open = numpy.round(polygon.vertices + polygon.offset).astype(int) + xy_closed = numpy.vstack((xy_open, xy_open[0, :])) + boundary = klamath.elements.Boundary(layer=(layer, data_type), + xy=xy_closed, + properties=properties) + elements.append(boundary) else: for polygon in shape.to_polygons(): xy_open = numpy.round(polygon.vertices + polygon.offset).astype(int)