Skip to content

Commit

Permalink
clean-up: CPU-intensive prepare() moved out of synchronized block
Browse files Browse the repository at this point in the history
  • Loading branch information
phanecak-maptiler committed Dec 12, 2023
1 parent c8c4b24 commit 57c2547
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/org/openmaptiles/layers/Transportation.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 57c2547

Please sign in to comment.