OpenMapTiles: support building heights (#516)

This commit is contained in:
Gustl22
2018-03-22 10:53:18 +01:00
committed by Emux
parent 0137d9ff1f
commit 846074ddc1
2 changed files with 40 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
/*
* Copyright 2012 Hannes Janetzek
* Copyright 2016 Andrey Novikov
* Copyright 2017 Gustl22
* Copyright 2017-2018 Gustl22
* Copyright 2018 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -60,14 +60,40 @@ public class MapElement extends GeometryBuffer {
this.setLayer(element.layer);
}
/**
* @return height in meters, if present
*/
public Float getHeight() {
String v = tags.getValue(Tag.KEY_HEIGHT);
if (v == null)
v = tags.getValue("render_height"); // OpenMapTiles
if (v != null)
return Float.parseFloat(v);
return null;
}
/**
* @return minimum height in meters, if present
*/
public Float getMinHeight() {
String v = tags.getValue(Tag.KEY_MIN_HEIGHT);
if (v == null)
v = tags.getValue("render_min_height"); // OpenMapTiles
if (v != null)
return Float.parseFloat(v);
return null;
}
public boolean isBuilding() {
return tags.containsKey(Tag.KEY_BUILDING)
|| "building".equals(tags.getValue("kind")); // Mapzen
|| "building".equals(tags.getValue("kind")) // Mapzen
|| "building".equals(tags.getValue("layer")); // OpenMapTiles
}
public boolean isBuildingPart() {
return tags.containsKey(Tag.KEY_BUILDING_PART)
|| "building_part".equals(tags.getValue("kind")); // Mapzen
|| "building_part".equals(tags.getValue("kind")) // Mapzen
|| "building:part".equals(tags.getValue("layer")); // OpenMapTiles
}
public void setLabelPosition(float x, float y) {

View File

@@ -2,7 +2,7 @@
* Copyright 2013 Hannes Janetzek
* Copyright 2016-2018 devemux86
* Copyright 2016 Robin Boldt
* Copyright 2017 Gustl22
* Copyright 2017-2018 Gustl22
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -129,21 +129,23 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook {
int height = 0; // cm
int minHeight = 0; // cm
String v = element.tags.getValue(Tag.KEY_HEIGHT);
if (v != null)
height = (int) (Float.parseFloat(v) * 100);
Float f = element.getHeight();
if (f != null)
height = (int) (f * 100);
else {
// #TagFromTheme: generalize level/height tags
if ((v = element.tags.getValue(Tag.KEY_BUILDING_LEVELS)) != null)
String v = element.tags.getValue(Tag.KEY_BUILDING_LEVELS);
if (v != null)
height = (int) (Float.parseFloat(v) * BUILDING_LEVEL_HEIGHT);
}
v = element.tags.getValue(Tag.KEY_MIN_HEIGHT);
if (v != null)
minHeight = (int) (Float.parseFloat(v) * 100);
f = element.getMinHeight();
if (f != null)
minHeight = (int) (f * 100);
else {
// #TagFromTheme: level/height tags
if ((v = element.tags.getValue(Tag.KEY_BUILDING_MIN_LEVEL)) != null)
String v = element.tags.getValue(Tag.KEY_BUILDING_MIN_LEVEL);
if (v != null)
minHeight = (int) (Float.parseFloat(v) * BUILDING_LEVEL_HEIGHT);
}