From 2752878e9e7c2bcf588a4cf717841fb1c88fee74 Mon Sep 17 00:00:00 2001
From: Gustl22 <user.rebo@gmx.de>
Date: Fri, 15 Jun 2018 11:43:05 +0200
Subject: [PATCH] S3DBLayer: fix roof angle estimation

---
 vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java b/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java
index 38ee3a3d..f0dd6408 100644
--- a/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java
+++ b/vtm/src/org/oscim/layers/tile/buildings/S3DBLayer.java
@@ -94,8 +94,9 @@ public class S3DBLayer extends BuildingLayer {
                 }
             }
             if (bb != null) {
-                float maxSize = (int) Math.max(bb.getHeight(), bb.getWidth()) * TILE_SCALE;
-                roofHeight = (int) ((Float.parseFloat(v) / 45.f) * (maxSize * 15)); // Angle is simplified, 15 is some constant, may depend on lat
+                float minSize = (int) Math.min(bb.getHeight(), bb.getWidth()) * groundScale; // depends on lat
+                // Angle is simplified, 40 is an estimated constant
+                roofHeight = (int) ((Float.parseFloat(v) / 45.f) * (minSize * 40));
             }
         } else if ((v = element.tags.getValue(Tag.KEY_ROOF_SHAPE)) != null && !v.equals(Tag.VALUE_FLAT)) {
             roofHeight = (2 * BUILDING_LEVEL_HEIGHT);