Fix route data object'

This commit is contained in:
Victor Shcherb 2017-08-30 18:06:55 +02:00
parent 2f8a514d4f
commit bd1de01665
2 changed files with 52 additions and 6 deletions

View file

@ -205,9 +205,9 @@ public class BinaryMapRouteReaderAdapter {
public static class RouteRegion extends BinaryIndexPart { public static class RouteRegion extends BinaryIndexPart {
public int regionsRead; public int regionsRead;
public List<RouteTypeRule> routeEncodingRules = new ArrayList<BinaryMapRouteReaderAdapter.RouteTypeRule>();
List<RouteSubregion> subregions = new ArrayList<RouteSubregion>(); List<RouteSubregion> subregions = new ArrayList<RouteSubregion>();
List<RouteSubregion> basesubregions = new ArrayList<RouteSubregion>(); List<RouteSubregion> basesubregions = new ArrayList<RouteSubregion>();
List<RouteTypeRule> routeEncodingRules = new ArrayList<BinaryMapRouteReaderAdapter.RouteTypeRule>();
int nameTypeRule = -1; int nameTypeRule = -1;
int refTypeRule = -1; int refTypeRule = -1;
@ -227,7 +227,7 @@ public class BinaryMapRouteReaderAdapter {
return routeEncodingRules.get(id); return routeEncodingRules.get(id);
} }
private void initRouteEncodingRule(int id, String tags, String val) { public void initRouteEncodingRule(int id, String tags, String val) {
while (routeEncodingRules.size() <= id) { while (routeEncodingRules.size() <= id) {
routeEncodingRules.add(null); routeEncodingRules.add(null);
} }
@ -291,6 +291,12 @@ public class BinaryMapRouteReaderAdapter {
} }
return false; return false;
} }
public RouteDataObject adopt(RouteDataObject obj) {
// TODO Auto-generated method stub
return null;
}
} }
// Used in C++ // Used in C++

View file

@ -66,17 +66,17 @@ public class RouteDataObject {
public boolean compareRoute(RouteDataObject thatObj) { public boolean compareRoute(RouteDataObject thatObj) {
if (this.id == thatObj.id if (this.id == thatObj.id
&& Arrays.equals(this.pointNames, thatObj.pointNames)
&& Arrays.equals(this.pointsX, thatObj.pointsX) && Arrays.equals(this.pointsX, thatObj.pointsX)
&& Arrays.equals(this.pointsY, thatObj.pointsY) && Arrays.equals(this.pointsY, thatObj.pointsY)) {
&& Arrays.equals(this.restrictions, thatObj.restrictions)) {
if (this.region == null) { if (this.region == null) {
throw new IllegalStateException("Illegal routing object: " + id); throw new IllegalStateException("Illegal routing object: " + id);
} }
if (thatObj.region == null) { if (thatObj.region == null) {
throw new IllegalStateException("Illegal routing object: " + thatObj.id); throw new IllegalStateException("Illegal routing object: " + thatObj.id);
} }
boolean equals = true; boolean equals = true;
equals = equals && Arrays.equals(this.restrictions, thatObj.restrictions);
if (equals) { if (equals) {
if (this.names != null && thatObj.names != null) { if (this.names != null && thatObj.names != null) {
equals = Arrays.equals(this.names.values(), thatObj.names.values()); equals = Arrays.equals(this.names.values(), thatObj.names.values());
@ -97,6 +97,46 @@ public class RouteDataObject {
} }
} }
} }
if (equals) {
if (this.nameIds == null || thatObj.nameIds == null) {
equals = this.nameIds == thatObj.nameIds;
} else if (nameIds.length != thatObj.nameIds.length) {
equals = false;
} else {
for (int i = 0; i < this.nameIds.length && equals; i++) {
String thisTag = region.routeEncodingRules.get(nameIds[i]).getTag();
String thisValue = names.get(nameIds[i]);
String thatTag = thatObj.region.routeEncodingRules.get(thatObj.nameIds[i]).getTag();
String thatValue = thatObj.names.get(thatObj.nameIds[i]);
equals = (Algorithms.objectEquals(thisTag, thatTag) && Algorithms.objectEquals(thisValue, thatValue));
}
}
}
if (equals) {
if (this.pointNameTypes == null || thatObj.pointNameTypes == null) {
equals = this.pointNameTypes == thatObj.pointNameTypes;
} else if (pointNameTypes.length != thatObj.pointNameTypes.length) {
equals = false;
} else {
for (int i = 0; i < this.pointNameTypes.length && equals; i++) {
if (this.pointNameTypes[i] == null || thatObj.pointNameTypes[i] == null) {
equals = this.pointNameTypes[i] == thatObj.pointNameTypes[i];
} else if (pointNameTypes[i].length != thatObj.pointNameTypes[i].length) {
equals = false;
} else {
for (int j = 0; j < this.pointNameTypes[i].length && equals; j++) {
String thisTag = region.routeEncodingRules.get(pointNameTypes[i][j]).getTag();
String thisValue = pointNames[i][j];
String thatTag = thatObj.region.routeEncodingRules.get(thatObj.pointNameTypes[i][j]).getTag();
String thatValue = thatObj.pointNames[i][j];
equals = (Algorithms.objectEquals(thisTag, thatTag) && Algorithms.objectEquals(thisValue, thatValue));
}
}
}
}
}
} }
return false; return false;
} }