From 57c2547704733541d643c3b61c06280705e8066d Mon Sep 17 00:00:00 2001 From: Peter Hanecak Date: Tue, 12 Dec 2023 11:06:22 +0100 Subject: [PATCH] clean-up: CPU-intensive prepare() moved out of synchronized block --- .../java/org/openmaptiles/layers/Transportation.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/openmaptiles/layers/Transportation.java b/src/main/java/org/openmaptiles/layers/Transportation.java index 78bc27ae..6cb8bd2d 100644 --- a/src/main/java/org/openmaptiles/layers/Transportation.java +++ b/src/main/java/org/openmaptiles/layers/Transportation.java @@ -262,18 +262,22 @@ public void processNaturalEarth(String table, SourceFeature feature, // once, but just to be safe synchronize updates to that field if (feature.hasTag("iso_a2", "GB")) { try { - Geometry boundary = feature.polygon().buffer(GeoUtils.metersToPixelAtEquator(0, 10_000) / 256d); + var prepared = PreparedGeometryFactory.prepare( + feature.polygon().buffer(GeoUtils.metersToPixelAtEquator(0, 10_000) / 256d) + ); synchronized (this) { - greatBritain = PreparedGeometryFactory.prepare(boundary); + greatBritain = prepared; } } catch (GeometryException e) { LOGGER.error("Failed to get Great Britain Polygon: " + e); } } else if (feature.hasTag("iso_a2", "IE")) { try { - Geometry boundary = feature.polygon().buffer(GeoUtils.metersToPixelAtEquator(0, 10_000) / 256d); + var prepared = PreparedGeometryFactory.prepare( + feature.polygon().buffer(GeoUtils.metersToPixelAtEquator(0, 10_000) / 256d) + ); synchronized (this) { - ireland = PreparedGeometryFactory.prepare(boundary); + ireland = prepared; } } catch (GeometryException e) { LOGGER.error("Failed to get Ireland Polygon: " + e);