Merge pull request #10564 from osmandapp/T7525

Add condition for BuildingInterpolation.ALPHABETIC
This commit is contained in:
vshcherb 2021-01-15 20:16:04 +01:00 committed by GitHub
commit 67c122ce03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,25 +106,42 @@ public class Building extends MapObject {
public float interpolation(String hno) { public float interpolation(String hno) {
if(getInterpolationType() != null || getInterpolationInterval() > 0 if (getInterpolationType() != null || getInterpolationInterval() > 0
//|| checkNameAsInterpolation() // disable due to situation in NL #4284 // || checkNameAsInterpolation() // disable due to situation in NL #4284
) { ) {
int num = Algorithms.extractFirstIntegerNumber(hno); int num = Algorithms.extractFirstIntegerNumber(hno);
String fname = super.getName(); String fname = super.getName();
int numB = Algorithms.extractFirstIntegerNumber(fname); int numB = Algorithms.extractFirstIntegerNumber(fname);
int numT = numB; int numT = numB;
String sname = getName2();
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);
if (fch == sch) {
return -1;
}
float res = ((float) hint - fch) / (((float) sch - fch));
if (res > 1 || res < -1) {
return -1;
}
return res;
}
if (num >= numB) { if (num >= numB) {
String sname = getName2(); if (fname.contains("-") && sname == null) {
if(fname.contains("-") && sname == null){
int l = fname.indexOf('-'); int l = fname.indexOf('-');
sname = fname.substring(l + 1, fname.length()); sname = fname.substring(l + 1, fname.length());
} }
if (sname != null) { if (sname != null) {
numT = Algorithms.extractFirstIntegerNumber(sname); numT = Algorithms.extractFirstIntegerNumber(sname);
if(numT < num) { if (numT < num) {
return -1; return -1;
} }
} }
if (getInterpolationType() == BuildingInterpolation.EVEN && num % 2 == 1) { if (getInterpolationType() == BuildingInterpolation.EVEN && num % 2 == 1) {
return -1; return -1;
} }
@ -137,8 +154,8 @@ public class Building extends MapObject {
} else { } else {
return -1; return -1;
} }
if(numT > numB){ if (numT > numB) {
return ((float)num - numB) / (((float)numT - numB)); return ((float) num - numB) / (((float) numT - numB));
} }
return 0; return 0;
} }