OpenMapTiles: support building heights (#516)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 Hannes Janetzek
|
* Copyright 2012 Hannes Janetzek
|
||||||
* Copyright 2016 Andrey Novikov
|
* Copyright 2016 Andrey Novikov
|
||||||
* Copyright 2017 Gustl22
|
* Copyright 2017-2018 Gustl22
|
||||||
* Copyright 2018 devemux86
|
* Copyright 2018 devemux86
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* 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);
|
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() {
|
public boolean isBuilding() {
|
||||||
return tags.containsKey(Tag.KEY_BUILDING)
|
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() {
|
public boolean isBuildingPart() {
|
||||||
return tags.containsKey(Tag.KEY_BUILDING_PART)
|
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) {
|
public void setLabelPosition(float x, float y) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016-2018 devemux86
|
* Copyright 2016-2018 devemux86
|
||||||
* Copyright 2016 Robin Boldt
|
* Copyright 2016 Robin Boldt
|
||||||
* Copyright 2017 Gustl22
|
* Copyright 2017-2018 Gustl22
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* 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 height = 0; // cm
|
||||||
int minHeight = 0; // cm
|
int minHeight = 0; // cm
|
||||||
|
|
||||||
String v = element.tags.getValue(Tag.KEY_HEIGHT);
|
Float f = element.getHeight();
|
||||||
if (v != null)
|
if (f != null)
|
||||||
height = (int) (Float.parseFloat(v) * 100);
|
height = (int) (f * 100);
|
||||||
else {
|
else {
|
||||||
// #TagFromTheme: generalize level/height tags
|
// #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);
|
height = (int) (Float.parseFloat(v) * BUILDING_LEVEL_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
v = element.tags.getValue(Tag.KEY_MIN_HEIGHT);
|
f = element.getMinHeight();
|
||||||
if (v != null)
|
if (f != null)
|
||||||
minHeight = (int) (Float.parseFloat(v) * 100);
|
minHeight = (int) (f * 100);
|
||||||
else {
|
else {
|
||||||
// #TagFromTheme: level/height tags
|
// #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);
|
minHeight = (int) (Float.parseFloat(v) * BUILDING_LEVEL_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user