Fix issue with diff generation
This commit is contained in:
parent
bd1de01665
commit
7211a51b64
2 changed files with 116 additions and 4 deletions
|
@ -16,12 +16,14 @@ import java.util.List;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||||
|
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
|
||||||
import net.osmand.binary.OsmandOdb.IdTable;
|
import net.osmand.binary.OsmandOdb.IdTable;
|
||||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock;
|
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock;
|
||||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox;
|
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBox;
|
||||||
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule;
|
import net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule;
|
||||||
import net.osmand.binary.OsmandOdb.RestrictionData;
|
import net.osmand.binary.OsmandOdb.RestrictionData;
|
||||||
import net.osmand.binary.OsmandOdb.RouteData;
|
import net.osmand.binary.OsmandOdb.RouteData;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
import net.osmand.util.OpeningHoursParser;
|
import net.osmand.util.OpeningHoursParser;
|
||||||
|
|
||||||
|
@ -213,6 +215,7 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
int refTypeRule = -1;
|
int refTypeRule = -1;
|
||||||
int destinationTypeRule = -1;
|
int destinationTypeRule = -1;
|
||||||
int destinationRefTypeRule = -1;
|
int destinationRefTypeRule = -1;
|
||||||
|
private RouteRegion referenceRouteRegion;
|
||||||
|
|
||||||
public String getPartName() {
|
public String getPartName() {
|
||||||
return "Routing";
|
return "Routing";
|
||||||
|
@ -223,6 +226,17 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
return OsmandOdb.OsmAndStructure.ROUTINGINDEX_FIELD_NUMBER;
|
return OsmandOdb.OsmAndStructure.ROUTINGINDEX_FIELD_NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int searchRouteEncodingRule(String tag, String value) {
|
||||||
|
// TODO cache;
|
||||||
|
for(int k = 0; k < routeEncodingRules.size(); k++) {
|
||||||
|
RouteTypeRule rt = routeEncodingRules.get(k);
|
||||||
|
if(Algorithms.objectEquals(rt.getTag(), tag) && Algorithms.objectEquals(rt.getValue(), value)) {
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public RouteTypeRule quickGetEncodingRule(int id) {
|
public RouteTypeRule quickGetEncodingRule(int id) {
|
||||||
return routeEncodingRules.get(id);
|
return routeEncodingRules.get(id);
|
||||||
}
|
}
|
||||||
|
@ -293,10 +307,86 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RouteDataObject adopt(RouteDataObject obj) {
|
public RouteDataObject adopt(RouteDataObject o) {
|
||||||
// TODO Auto-generated method stub
|
if(o.region == this || o.region == referenceRouteRegion) {
|
||||||
return null;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(routeEncodingRules.isEmpty()) {
|
||||||
|
routeEncodingRules.addAll(o.region.routeEncodingRules);
|
||||||
|
referenceRouteRegion= o.region;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
RouteDataObject rdo = new RouteDataObject(this);
|
||||||
|
rdo.pointsX = o.pointsX;
|
||||||
|
rdo.pointsY = o.pointsY;
|
||||||
|
rdo.id = o.id;
|
||||||
|
rdo.restrictions = o.restrictions;
|
||||||
|
|
||||||
|
if (o.types != null) {
|
||||||
|
rdo.types = new int[o.types.length];
|
||||||
|
for (int i = 0; i < o.types.length; i++) {
|
||||||
|
RouteTypeRule tp = o.region.routeEncodingRules.get(o.types[i]);
|
||||||
|
int ruleId = searchRouteEncodingRule(tp.getTag(), tp.getValue());
|
||||||
|
if(ruleId != -1) {
|
||||||
|
rdo.types[i] = ruleId;
|
||||||
|
} else {
|
||||||
|
ruleId = routeEncodingRules.size() ;
|
||||||
|
initRouteEncodingRule(ruleId, tp.getTag(), tp.getValue());
|
||||||
|
rdo.types[i] = ruleId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (o.pointTypes != null) {
|
||||||
|
rdo.pointTypes = new int[o.pointTypes.length][];
|
||||||
|
for (int i = 0; i < o.pointTypes.length; i++) {
|
||||||
|
if (o.pointTypes[i] != null) {
|
||||||
|
rdo.pointTypes[i] = new int[o.pointTypes[i].length];
|
||||||
|
for (int j = 0; j < o.pointTypes[i].length; j++) {
|
||||||
|
RouteTypeRule tp = o.region.routeEncodingRules.get(o.pointTypes[i][j]);
|
||||||
|
int ruleId = searchRouteEncodingRule(tp.getTag(), tp.getValue());
|
||||||
|
if(ruleId != -1) {
|
||||||
|
rdo.pointTypes[i][j] = ruleId;
|
||||||
|
} else {
|
||||||
|
ruleId = routeEncodingRules.size() ;
|
||||||
|
initRouteEncodingRule(ruleId, tp.getTag(), tp.getValue());
|
||||||
|
rdo.pointTypes[i][j] = ruleId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO
|
||||||
|
// rdo.nameIds rdo.names;
|
||||||
|
// rdo.pointNameTypes rdo.pointNames
|
||||||
|
// BinaryMapDataObject bm =
|
||||||
|
// new BinaryMapDataObject(o.id, o.coordinates, o.polygonInnerCoordinates, o.objectType, o.area,
|
||||||
|
// types.toArray(), additionalTypes.isEmpty() ? null : additionalTypes.toArray());
|
||||||
|
// if (o.namesOrder != null) {
|
||||||
|
// bm.objectNames = new TIntObjectHashMap<>();
|
||||||
|
// bm.namesOrder = new TIntArrayList();
|
||||||
|
// for (int i = 0; i < o.namesOrder.size(); i++) {
|
||||||
|
// int nameType = o.namesOrder.get(i);
|
||||||
|
// String name = o.objectNames.get(nameType);
|
||||||
|
// TagValuePair tp = o.mapIndex.decodeType(nameType);
|
||||||
|
// Integer r = getRule(tp);
|
||||||
|
// if(r != null) {
|
||||||
|
// bm.namesOrder.add(r);
|
||||||
|
// bm.objectNames.put(r, name);
|
||||||
|
// } else {
|
||||||
|
// int nid = decodingRules.size() + 1;
|
||||||
|
// initMapEncodingRule(tp.additionalAttribute, nid, tp.tag, tp.value);
|
||||||
|
// additionalTypes.add(nid);
|
||||||
|
// bm.objectNames.put(nid, name);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return bm;
|
||||||
|
return rdo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used in C++
|
// Used in C++
|
||||||
|
|
|
@ -112,7 +112,29 @@ public class RouteDataObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (equals) {
|
||||||
|
if (this.pointTypes == null || thatObj.pointTypes == null) {
|
||||||
|
equals = this.pointTypes == thatObj.pointTypes;
|
||||||
|
} else if (pointTypes.length != thatObj.pointTypes.length) {
|
||||||
|
equals = false;
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < this.pointTypes.length && equals; i++) {
|
||||||
|
if (this.pointTypes[i] == null || thatObj.pointTypes[i] == null) {
|
||||||
|
equals = this.pointTypes[i] == thatObj.pointTypes[i];
|
||||||
|
} else if (pointTypes[i].length != thatObj.pointTypes[i].length) {
|
||||||
|
equals = false;
|
||||||
|
} else {
|
||||||
|
for (int j = 0; j < this.pointTypes[i].length && equals; j++) {
|
||||||
|
String thisTag = region.routeEncodingRules.get(pointTypes[i][j]).getTag();
|
||||||
|
String thisValue = region.routeEncodingRules.get(pointTypes[i][j]).getValue();
|
||||||
|
String thatTag = thatObj.region.routeEncodingRules.get(thatObj.pointTypes[i][j]).getTag();
|
||||||
|
String thatValue = thatObj.region.routeEncodingRules.get(thatObj.pointTypes[i][j]).getValue();
|
||||||
|
equals = (Algorithms.objectEquals(thisTag, thatTag) && Algorithms.objectEquals(thisValue, thatValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (equals) {
|
if (equals) {
|
||||||
if (this.pointNameTypes == null || thatObj.pointNameTypes == null) {
|
if (this.pointNameTypes == null || thatObj.pointNameTypes == null) {
|
||||||
equals = this.pointNameTypes == thatObj.pointNameTypes;
|
equals = this.pointNameTypes == thatObj.pointNameTypes;
|
||||||
|
|
Loading…
Reference in a new issue