PolyLabel default disabled #402

This commit is contained in:
Emux
2017-09-15 21:13:31 +03:00
parent 0fbce21140
commit 4f78fed094
5 changed files with 33 additions and 6 deletions

View File

@@ -10,6 +10,7 @@
- Core utilities [#396](https://github.com/mapsforge/vtm/issues/396)
- Map scaling improvements [#401](https://github.com/mapsforge/vtm/issues/401)
- Mapsforge fix artifacts zoom > 17 [#231](https://github.com/mapsforge/vtm/issues/231)
- PolyLabel default disabled [#402](https://github.com/mapsforge/vtm/issues/402)
- vtm-theme-comparator module [#387](https://github.com/mapsforge/vtm/issues/387)
- Internal render themes various improvements [#41](https://github.com/mapsforge/vtm/issues/41)
- Many other minor improvements and bug fixes

View File

@@ -59,6 +59,8 @@ public class MapsforgeMapActivity extends MapActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//LabelLayer.POLY_LABEL = true;
startActivityForResult(new Intent(this, MapFilePicker.class),
SELECT_MAP_FILE);
}

View File

@@ -40,6 +40,10 @@ public class MapsforgeTest extends GdxMap {
private static File mapFile;
private MapsforgeTest() {
//LabelLayer.POLY_LABEL = true;
}
@Override
public void createLayers() {
MapFileTileSource tileSource = new MapFileTileSource();

View File

@@ -34,9 +34,11 @@ public class LabelLayer extends Layer implements Map.UpdateListener, TileManager
static final Logger log = LoggerFactory.getLogger(LabelLayer.class);
public final static String LABEL_DATA = LabelLayer.class.getName();
static final String LABEL_DATA = LabelLayer.class.getName();
private final static long MAX_RELABEL_DELAY = 100;
private static final long MAX_RELABEL_DELAY = 100;
public static boolean POLY_LABEL;
private final LabelPlacement mLabelPlacer;
private final Worker mWorker;

View File

@@ -1,6 +1,6 @@
/*
* Copyright 2013 Hannes Janetzek
* Copyright 2016 devemux86
* Copyright 2016-2017 devemux86
* Copyright 2016 Andrey Novikov
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -90,10 +90,28 @@ public class LabelTileLoaderHook implements TileLoaderThemeHook {
return false;
}
if (label == null)
label = PolyLabel.get(element);
float x = 0;
float y = 0;
if (label == null) {
if (LabelLayer.POLY_LABEL) {
label = PolyLabel.get(element);
x = label.x;
y = label.y;
} else {
int n = element.index[0];
for (int i = 0; i < n; ) {
x += element.points[i++];
y += element.points[i++];
}
x /= (n / 2);
y /= (n / 2);
}
} else {
x = label.x;
y = label.y;
}
ld.labels.push(TextItem.pool.get().set(label.x, label.y, value, text));
ld.labels.push(TextItem.pool.get().set(x, y, value, text));
} else if (element.type == POINT) {
String value = element.tags.getValue(text.textKey);
if (value == null || value.length() == 0)