From 398ba72709ce24a3a1f572e266cc03f4f3f88777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Mon, 17 May 2021 16:18:20 +0300 Subject: [PATCH] visible labels for far plane --- .../tile/vector/labeling/LabelPlacement.java | 16 +++++++++++++--- vtm/src/org/oscim/utils/Parameters.java | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java index 2097253e5..356983795 100644 --- a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java +++ b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java @@ -31,6 +31,7 @@ import org.oscim.renderer.bucket.TextItem; import org.oscim.theme.styles.TextStyle; import org.oscim.utils.FastMath; +import org.oscim.utils.Parameters; import org.oscim.utils.geom.OBB2D; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,6 +52,7 @@ public static final LabelTileData getLabels(MapTile tile) { private static final float MIN_CAPTION_DIST = 5; private static final float MIN_WAY_DIST = 3; + private static final float DISTANCES_LABELS_COEFFICIENT = 3; /** * thread local pool of for unused label items @@ -352,9 +354,17 @@ boolean updateLabels(LabelTask work) { } /* estimation for visible area to be labeled */ - int mw = (mMap.getWidth() + Tile.SIZE) / 2; - int mh = (mMap.getHeight() + Tile.SIZE) / 2; - mSquareRadius = mw * mw + mh * mh; + if (Parameters.DISTANCES_LABELS_DRAWING) { + float mw = mMap.getWidth(); + float mh = mMap.getHeight(); + float k = DISTANCES_LABELS_COEFFICIENT * mMap.getMapPosition().tilt / Viewport.MAX_TILT; + if (k < 0.5) k = 0.5F; + mSquareRadius = (mw * mw + mh * mh) * k; + } else { + int mw = (mMap.getWidth() + Tile.SIZE) / 2; + int mh = (mMap.getHeight() + Tile.SIZE) / 2; + mSquareRadius = mw * mw + mh * mh; + } /* scale of tiles zoom-level relative to current position */ double scale = pos.scale / (1 << zoom); diff --git a/vtm/src/org/oscim/utils/Parameters.java b/vtm/src/org/oscim/utils/Parameters.java index 2d72252bb..2594c03ba 100644 --- a/vtm/src/org/oscim/utils/Parameters.java +++ b/vtm/src/org/oscim/utils/Parameters.java @@ -90,6 +90,11 @@ public enum SymbolScaling {ALL, POI} */ public static boolean THREADED_INIT = false; + /** + * Drawing labels of far plane + */ + public static boolean DISTANCES_LABELS_DRAWING = false; + private Parameters() { throw new IllegalStateException(); }