From 925e42546dbdbc1b3cadf1b3e755f71bcb1c9ee8 Mon Sep 17 00:00:00 2001 From: Kseniia Date: Tue, 12 Jan 2021 17:52:03 +0200 Subject: [PATCH 1/6] add condition for BuildingInterpolation.ALPHABETIC --- .../main/java/net/osmand/data/Building.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 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 7668d16a30..9d11828dbf 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Building.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Building.java @@ -106,25 +106,32 @@ public class Building extends MapObject { public float interpolation(String hno) { - if(getInterpolationType() != null || getInterpolationInterval() > 0 - //|| checkNameAsInterpolation() // disable due to situation in NL #4284 - ) { + if (getInterpolationType() != null || getInterpolationInterval() > 0 + // || checkNameAsInterpolation() // disable due to situation in NL #4284 + ) { int num = Algorithms.extractFirstIntegerNumber(hno); String fname = super.getName(); int numB = Algorithms.extractFirstIntegerNumber(fname); - int numT = numB; + int numT = numB; if (num >= numB) { String sname = getName2(); - if(fname.contains("-") && sname == null){ + if (getInterpolationType() == BuildingInterpolation.ALPHABETIC) { + char ch = hno.charAt(hno.length() - 1); + char chF = fname.charAt(fname.length() - 1); + if (chF < ch) { + return -1; + } + } + if (fname.contains("-") && sname == null) { int l = fname.indexOf('-'); sname = fname.substring(l + 1, fname.length()); } if (sname != null) { numT = Algorithms.extractFirstIntegerNumber(sname); - if(numT < num) { + if (numT < num) { return -1; } - } + } if (getInterpolationType() == BuildingInterpolation.EVEN && num % 2 == 1) { return -1; } @@ -137,8 +144,8 @@ public class Building extends MapObject { } else { return -1; } - if(numT > numB){ - return ((float)num - numB) / (((float)numT - numB)); + if (numT > numB) { + return ((float) num - numB) / (((float) numT - numB)); } return 0; } From b57b7ef268e1d9450a765f1ad461baa62b7e2492 Mon Sep 17 00:00:00 2001 From: Kseniia Date: Wed, 13 Jan 2021 09:40:20 +0200 Subject: [PATCH 2/6] fix interpolation for alphabetic --- .../main/java/net/osmand/data/Building.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 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 9d11828dbf..379b399fe9 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Building.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Building.java @@ -113,15 +113,20 @@ public class Building extends MapObject { String fname = super.getName(); int numB = Algorithms.extractFirstIntegerNumber(fname); int numT = numB; - if (num >= numB) { - String sname = getName2(); - if (getInterpolationType() == BuildingInterpolation.ALPHABETIC) { - char ch = hno.charAt(hno.length() - 1); - char chF = fname.charAt(fname.length() - 1); - if (chF < ch) { - return -1; - } + String sname = getName2(); + + if (getInterpolationType() == BuildingInterpolation.ALPHABETIC && num == numB) { + char ch = hno.charAt(hno.length() - 1); + char chF = fname.charAt(fname.length() - 1); + char chS = sname.charAt(sname.length() - 1); + if (chS < chF && chF < ch) { + return -1; } + if (chS > chF && ch < chF) { + return -1; + } + } + if (num >= numB) { if (fname.contains("-") && sname == null) { int l = fname.indexOf('-'); sname = fname.substring(l + 1, fname.length()); From d25981a18de2b9403184db4f72ed8497d6861652 Mon Sep 17 00:00:00 2001 From: Kseniia Date: Fri, 15 Jan 2021 19:35:20 +0200 Subject: [PATCH 3/6] fix interpolation for alphabetic --- .../src/main/java/net/osmand/data/Building.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 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 379b399fe9..67870ec383 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Building.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Building.java @@ -116,14 +116,17 @@ public class Building extends MapObject { String sname = getName2(); if (getInterpolationType() == BuildingInterpolation.ALPHABETIC && num == numB) { - char ch = hno.charAt(hno.length() - 1); - char chF = fname.charAt(fname.length() - 1); - char chS = sname.charAt(sname.length() - 1); - if (chS < chF && chF < ch) { - return -1; + 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)); } - if (chS > chF && ch < chF) { - return -1; + if (sCh < fCh) { + return ((float) f - h) / (((float) f - s)); } } if (num >= numB) { From c98ae20599bd3dbb12c34ca5ac67f732434662a7 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Fri, 15 Jan 2021 18:47:02 +0100 Subject: [PATCH 4/6] 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) { From 1d16ff216ae67458999b54f0d8843187af681801 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Fri, 15 Jan 2021 18:49:17 +0100 Subject: [PATCH 5/6] Update Building.java --- OsmAnd-java/src/main/java/net/osmand/data/Building.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 de3d8d5148..ec96ee35d6 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Building.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Building.java @@ -114,8 +114,11 @@ public class Building extends MapObject { int numB = Algorithms.extractFirstIntegerNumber(fname); int numT = numB; String sname = getName2(); - - if (getInterpolationType() == BuildingInterpolation.ALPHABETIC && num == numB) { + if (getInterpolationType() == BuildingInterpolation.ALPHABETIC) { + if (num != numB) { + // currently not supported + return -1; + } int hint = (int) hno.charAt(hno.length() - 1); int fch = (int) fname.charAt(fname.length() - 1); int sch = sname.charAt(sname.length() - 1); From d29c271471919c0d7d4c113601c970ac915ecf70 Mon Sep 17 00:00:00 2001 From: Kseniia Date: Fri, 15 Jan 2021 21:13:18 +0200 Subject: [PATCH 6/6] fix interpolation for alphabetic --- OsmAnd-java/src/main/java/net/osmand/data/Building.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 ec96ee35d6..a1247c4b15 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Building.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Building.java @@ -128,7 +128,8 @@ public class Building extends MapObject { float res = ((float) hint - fch) / (((float) sch - fch)); if (res > 1 || res < -1) { return -1; - } + } + return res; } if (num >= numB) { if (fname.contains("-") && sname == null) {