clean up
This commit is contained in:
parent
2ee126419f
commit
534f03d558
1 changed files with 8 additions and 15 deletions
|
@ -77,7 +77,6 @@ public class RoutingContext {
|
||||||
|
|
||||||
// 2. Routing memory cache (big objects)
|
// 2. Routing memory cache (big objects)
|
||||||
TLongObjectHashMap<List<RoutingSubregionTile>> indexedSubregions = new TLongObjectHashMap<List<RoutingSubregionTile>>();
|
TLongObjectHashMap<List<RoutingSubregionTile>> indexedSubregions = new TLongObjectHashMap<List<RoutingSubregionTile>>();
|
||||||
TLongObjectHashMap<TLongHashSet> excludedIdsByTile = new TLongObjectHashMap<TLongHashSet>();
|
|
||||||
|
|
||||||
// Needs to be a sorted array list . Another option to use hashmap but it will be more memory expensive
|
// Needs to be a sorted array list . Another option to use hashmap but it will be more memory expensive
|
||||||
List<RoutingSubregionTile> subregionTiles = new ArrayList<RoutingSubregionTile>();
|
List<RoutingSubregionTile> subregionTiles = new ArrayList<RoutingSubregionTile>();
|
||||||
|
@ -234,7 +233,6 @@ public class RoutingContext {
|
||||||
}
|
}
|
||||||
subregionTiles.clear();
|
subregionTiles.clear();
|
||||||
indexedSubregions.clear();
|
indexedSubregions.clear();
|
||||||
excludedIdsByTile.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int searchSubregionTile(RouteSubregion subregion){
|
private int searchSubregionTile(RouteSubregion subregion){
|
||||||
|
@ -282,7 +280,7 @@ public class RoutingContext {
|
||||||
if (subregions != null) {
|
if (subregions != null) {
|
||||||
for (int j = 0; j < subregions.size(); j++) {
|
for (int j = 0; j < subregions.size(); j++) {
|
||||||
original = subregions.get(j).loadRouteSegment(x31, y31, this, excludeDuplications,
|
original = subregions.get(j).loadRouteSegment(x31, y31, this, excludeDuplications,
|
||||||
excludedIdsByTile.get(tileId), original, j);
|
original, subregions, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return original;
|
return original;
|
||||||
|
@ -495,7 +493,6 @@ public class RoutingContext {
|
||||||
List<RoutingSubregionTile> subregions = indexedSubregions.get(tileId);
|
List<RoutingSubregionTile> subregions = indexedSubregions.get(tileId);
|
||||||
if (subregions != null) {
|
if (subregions != null) {
|
||||||
boolean load = false;
|
boolean load = false;
|
||||||
TLongHashSet excludedIdsForTile = new TLongHashSet();
|
|
||||||
for (RoutingSubregionTile ts : subregions) {
|
for (RoutingSubregionTile ts : subregions) {
|
||||||
if (!ts.isLoaded()) {
|
if (!ts.isLoaded()) {
|
||||||
load = true;
|
load = true;
|
||||||
|
@ -511,11 +508,7 @@ public class RoutingContext {
|
||||||
excludeIds.addAll(ts.excludedIds);
|
excludeIds.addAll(ts.excludedIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (excludeIds != null) {
|
|
||||||
excludedIdsForTile.addAll(excludeIds);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
excludedIdsByTile.put(tileId, excludedIdsForTile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -622,7 +615,6 @@ public class RoutingContext {
|
||||||
private int isLoaded = 0;
|
private int isLoaded = 0;
|
||||||
private TLongObjectMap<RouteSegment> routes = null;
|
private TLongObjectMap<RouteSegment> routes = null;
|
||||||
private TLongHashSet excludedIds = null;
|
private TLongHashSet excludedIds = null;
|
||||||
private TLongHashSet excludedIdsForTile = null;
|
|
||||||
|
|
||||||
public RoutingSubregionTile(RouteSubregion subregion) {
|
public RoutingSubregionTile(RouteSubregion subregion) {
|
||||||
this.subregion = subregion;
|
this.subregion = subregion;
|
||||||
|
@ -660,8 +652,7 @@ public class RoutingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
private RouteSegment loadRouteSegment(int x31, int y31, RoutingContext ctx,
|
private RouteSegment loadRouteSegment(int x31, int y31, RoutingContext ctx,
|
||||||
TLongObjectHashMap<RouteDataObject> excludeDuplications,
|
TLongObjectHashMap<RouteDataObject> excludeDuplications, RouteSegment original, List<RoutingSubregionTile> subregions, int subregionIndex) {
|
||||||
TLongHashSet excludedIdsForTile, RouteSegment original, int subIndex) {
|
|
||||||
access++;
|
access++;
|
||||||
if (routes != null) {
|
if (routes != null) {
|
||||||
long l = (((long) x31) << 31) + (long) y31;
|
long l = (((long) x31) << 31) + (long) y31;
|
||||||
|
@ -669,7 +660,7 @@ public class RoutingContext {
|
||||||
while (segment != null) {
|
while (segment != null) {
|
||||||
RouteDataObject ro = segment.road;
|
RouteDataObject ro = segment.road;
|
||||||
RouteDataObject toCmp = excludeDuplications.get(calcRouteId(ro, segment.getSegmentStart()));
|
RouteDataObject toCmp = excludeDuplications.get(calcRouteId(ro, segment.getSegmentStart()));
|
||||||
if (!isExcluded(ro.id, excludedIdsForTile)
|
if (!isExcluded(ro.id, subregions, subregionIndex)
|
||||||
&& (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength())) {
|
&& (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength())) {
|
||||||
excludeDuplications.put(calcRouteId(ro, segment.getSegmentStart()), ro);
|
excludeDuplications.put(calcRouteId(ro, segment.getSegmentStart()), ro);
|
||||||
RouteSegment s = new RouteSegment(ro, segment.getSegmentStart());
|
RouteSegment s = new RouteSegment(ro, segment.getSegmentStart());
|
||||||
|
@ -684,9 +675,11 @@ public class RoutingContext {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isExcluded(long id, TLongHashSet excludedIdsForTile) {
|
private static boolean isExcluded(long id, List<RoutingSubregionTile> subregions, int subregionIndex) {
|
||||||
if (excludedIdsForTile != null && excludedIdsForTile.contains(id)) {
|
for (int i = 0; i < subregionIndex; i++ ) {
|
||||||
return true;
|
if (subregions.get(i).excludedIds != null && subregions.get(i).excludedIds.contains(id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue