Fix route data object'
This commit is contained in:
parent
2f8a514d4f
commit
bd1de01665
2 changed files with 52 additions and 6 deletions
|
@ -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++
|
||||||
|
@ -360,7 +366,7 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
|
|
||||||
|
|
||||||
protected void readRouteIndex(RouteRegion region) throws IOException {
|
protected void readRouteIndex(RouteRegion region) throws IOException {
|
||||||
int routeEncodingRule =1;
|
int routeEncodingRule = 1;
|
||||||
while(true){
|
while(true){
|
||||||
int t = codedIS.readTag();
|
int t = codedIS.readTag();
|
||||||
int tag = WireFormat.getTagFieldNumber(t);
|
int tag = WireFormat.getTagFieldNumber(t);
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue