Polygon labels: use centroid position if available #734

This commit is contained in:
Emux 2019-10-04 18:24:14 +03:00
parent 3915e3343d
commit 88a9a9ee7f
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2018 devemux86 * Copyright 2016-2019 devemux86
* Copyright 2016 Andrey Novikov * Copyright 2016 Andrey Novikov
* Copyright 2019 marq24 * Copyright 2019 marq24
* *
@ -75,6 +75,8 @@ public class LabelTileLoaderHook implements TileLoaderThemeHook {
} }
} else if (element.type == POLY) { } else if (element.type == POLY) {
PointF label = element.labelPosition; PointF label = element.labelPosition;
if (label == null)
label = element.centroidPosition;
// skip unnecessary calculations if label is outside of visible area // skip unnecessary calculations if label is outside of visible area
if (label != null && (label.x < 0 || label.x > Tile.SIZE || label.y < 0 || label.y > Tile.SIZE)) if (label != null && (label.x < 0 || label.x > Tile.SIZE || label.y < 0 || label.y > Tile.SIZE))
return false; return false;