From c98ae20599bd3dbb12c34ca5ac67f732434662a7 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Fri, 15 Jan 2021 18:47:02 +0100 Subject: [PATCH] Update Building.java --- .../main/java/net/osmand/data/Building.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/data/Building.java b/OsmAnd-java/src/main/java/net/osmand/data/Building.java index 67870ec383..de3d8d5148 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Building.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Building.java @@ -116,17 +116,15 @@ public class Building extends MapObject { String sname = getName2(); if (getInterpolationType() == BuildingInterpolation.ALPHABETIC && num == numB) { - char hCh = hno.charAt(hno.length() - 1); - char fCh = fname.charAt(fname.length() - 1); - char sCh = sname.charAt(sname.length() - 1); - int h = Character.getNumericValue(hCh); - int f = Character.getNumericValue(fCh); - int s = Character.getNumericValue(sCh); - if (sCh > fCh) { - return ((float) h - f) / (((float) s - f)); + int hint = (int) hno.charAt(hno.length() - 1); + int fch = (int) fname.charAt(fname.length() - 1); + int sch = sname.charAt(sname.length() - 1); + if (fch == sch) { + return -1; } - if (sCh < fCh) { - return ((float) f - h) / (((float) f - s)); + float res = ((float) hint - fch) / (((float) sch - fch)); + if (res > 1 || res < -1) { + return -1; } } if (num >= numB) {