cleanup unused things
This commit is contained in:
parent
ea3399d761
commit
956557fa94
@ -19,8 +19,6 @@ public class AreaInfo {
|
||||
public int riverWays = 0;
|
||||
public double elevStart = 0;
|
||||
public int elev50 = 0;
|
||||
public int elev100 = 0;
|
||||
public int elevMore = 0;
|
||||
|
||||
public AreaInfo(int dir) {
|
||||
direction = dir;
|
||||
@ -43,7 +41,6 @@ public class AreaInfo {
|
||||
riverWays++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int getElev50Weight() {
|
||||
@ -65,9 +62,9 @@ public class AreaInfo {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Area ").append(direction).append(" ").append(elevStart).append("m ways ").append(ways);
|
||||
if (ways > 0) {
|
||||
sb.append("\nArea ways <50m " + elev50 + " " + getElev50Weight() + "%");
|
||||
sb.append("\nArea ways green " + greenWays + " " + getGreen() + "% " /*+ (greenWaysWeight/greenWays)*/);
|
||||
sb.append("\nArea ways river " + riverWays + " " + getRiver() + "% " /*+ (greenWaysWeight/greenWays)*/);
|
||||
sb.append("\nArea ways <50m ").append(elev50).append(" ").append(getElev50Weight()).append("%");
|
||||
sb.append("\nArea ways green ").append(greenWays).append(" ").append(getGreen()).append("%");
|
||||
sb.append("\nArea ways river ").append(riverWays).append(" ").append(getRiver()).append("%");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@ -135,7 +135,8 @@ public class AreaReader {
|
||||
used++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
System.err.println("AreaReader: after " + used + "/" + count + " " + e.getMessage());
|
||||
ais.clear();
|
||||
} finally {
|
||||
if (pf != null)
|
||||
try {
|
||||
@ -159,14 +160,14 @@ public class AreaReader {
|
||||
OsmFile osmf = new OsmFile(pf, lonDegree, latDegree, dataBuffers);
|
||||
if (osmf.hasData()) {
|
||||
int cellsize = 1000000 / div;
|
||||
int tmplon = inlon; // + cellsize * idxLon;
|
||||
int tmplat = inlat; // + cellsize * idxLat;
|
||||
int tmplon = inlon;
|
||||
int tmplat = inlat;
|
||||
int lonIdx = tmplon / cellsize;
|
||||
int latIdx = tmplat / cellsize;
|
||||
|
||||
MicroCache segment = osmf.createMicroCache(lonIdx, latIdx, dataBuffers, expctxWay, null, true, null);
|
||||
|
||||
if (segment != null /*&& segment.getDataSize()>0*/) {
|
||||
if (segment != null) {
|
||||
int size = segment.getSize();
|
||||
for (int i = 0; i < size; i++) {
|
||||
long id = segment.getIdForIndex(i);
|
||||
@ -196,8 +197,7 @@ public class AreaReader {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
} finally {
|
||||
System.err.println("AreaReader: " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -205,9 +205,8 @@ public class AreaReader {
|
||||
boolean ignoreCenter(int maxscale, int idxLon, int idxLat) {
|
||||
int centerScale = (int) Math.round(maxscale * .2) - 1;
|
||||
if (centerScale < 0) return false;
|
||||
if (idxLon >= -centerScale && idxLon <= centerScale &&
|
||||
idxLat >= -centerScale && idxLat <= centerScale) return true;
|
||||
return false;
|
||||
return idxLon >= -centerScale && idxLon <= centerScale &&
|
||||
idxLat >= -centerScale && idxLat <= centerScale;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -490,7 +490,6 @@ public class RoutingEngine extends Thread {
|
||||
double searchRadius = (routingContext.roundTripDistance == null ? 1500 :routingContext.roundTripDistance);
|
||||
double direction = (routingContext.startDirection == null ? -1 :routingContext.startDirection);
|
||||
double directionAdd = (routingContext.roundTripDirectionAdd == null ? ROUNDTRIP_DEFAULT_DIRECTIONADD :routingContext.roundTripDirectionAdd);
|
||||
//if (direction == -1) direction = getRandomDirectionFromRouting(waypoints.get(0), searchRadius);
|
||||
if (direction == -1) direction = getRandomDirectionFromData(waypoints.get(0), searchRadius);
|
||||
|
||||
if (routingContext.allowSamewayback) {
|
||||
@ -503,7 +502,6 @@ public class RoutingEngine extends Thread {
|
||||
onn.name = "rt1";
|
||||
waypoints.add(onn);
|
||||
} else {
|
||||
//buildPointsFromAngle(waypoints, direction, directionAdd, searchRadius, true);
|
||||
buildPointsFromCircle(waypoints, direction, searchRadius, routingContext.roundTripPoints == null ? 5 : routingContext.roundTripPoints);
|
||||
}
|
||||
|
||||
@ -520,34 +518,6 @@ public class RoutingEngine extends Thread {
|
||||
|
||||
}
|
||||
|
||||
void buildPointsFromAngle(List<OsmNodeNamed> waypoints, double startAngle, double addAngle, double searchRadius, boolean withNogoCenter) {
|
||||
int[] pos = CheapRuler.destination(waypoints.get(0).ilon, waypoints.get(0).ilat, searchRadius, startAngle - addAngle);
|
||||
OsmNodeNamed onn = new OsmNodeNamed(new OsmNode(pos[0], pos[1]));
|
||||
onn.name = "rt1";
|
||||
waypoints.add(onn);
|
||||
|
||||
pos = CheapRuler.destination(waypoints.get(0).ilon, waypoints.get(0).ilat, searchRadius, startAngle + addAngle);
|
||||
onn = new OsmNodeNamed(new OsmNode(pos[0], pos[1]));
|
||||
onn.name = "rt2";
|
||||
waypoints.add(onn);
|
||||
|
||||
onn = new OsmNodeNamed(waypoints.get(0));
|
||||
onn.name = "to_rt";
|
||||
waypoints.add(onn);
|
||||
|
||||
if (withNogoCenter) { // add a nogo area
|
||||
pos = CheapRuler.destination(waypoints.get(0).ilon, waypoints.get(0).ilat, searchRadius/2, startAngle);
|
||||
OsmNodeNamed n = new OsmNodeNamed();
|
||||
n.name = "nogo" + (int) (searchRadius/3);
|
||||
n.ilon = pos[0];
|
||||
n.ilat = pos[1];
|
||||
n.isNogo = true;
|
||||
n.radius = (int) (searchRadius/3);
|
||||
n.nogoWeight = Double.NaN;
|
||||
routingContext.setWaypoint(n, false);
|
||||
}
|
||||
}
|
||||
|
||||
void buildPointsFromCircle(List<OsmNodeNamed> waypoints, double startAngle, double searchRadius, int points) {
|
||||
//startAngle -= 90;
|
||||
for (int i = 1; i < points; i++) {
|
||||
@ -719,141 +689,6 @@ public class RoutingEngine extends Thread {
|
||||
return angle - 30 + (int) (Math.random() * 60);
|
||||
}
|
||||
|
||||
int getRandomDirectionFromRouting(OsmNodeNamed wp, double searchRadius) {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
int preferredRandomType = 0;
|
||||
boolean consider_elevation = routingContext.expctxWay.getVariableValue("consider_elevation", 0f) == 1f;
|
||||
boolean consider_forest = routingContext.expctxWay.getVariableValue("consider_forest", 0f) == 1f;
|
||||
boolean consider_river = routingContext.expctxWay.getVariableValue("consider_river", 0f) == 1f;
|
||||
if (consider_elevation) {
|
||||
preferredRandomType = AreaInfo.RESULT_TYPE_ELEV50;
|
||||
} else if (consider_forest) {
|
||||
preferredRandomType = AreaInfo.RESULT_TYPE_GREEN;
|
||||
} else if (consider_river) {
|
||||
preferredRandomType = AreaInfo.RESULT_TYPE_RIVER;
|
||||
} else {
|
||||
return (int) (Math.random()*360);
|
||||
}
|
||||
|
||||
MatchedWaypoint wpt1 = new MatchedWaypoint();
|
||||
wpt1.waypoint = wp;
|
||||
wpt1.name = "start_info";
|
||||
List<MatchedWaypoint> listStart = new ArrayList<>();
|
||||
listStart.add(wpt1);
|
||||
|
||||
List<OsmNodeNamed> wpliststart = new ArrayList<>();
|
||||
wpliststart.add(wp);
|
||||
|
||||
List<OsmNodeNamed> listSearch = new ArrayList<>();
|
||||
|
||||
for (int a = 45; a < 360; a +=90) {
|
||||
int[] pos = CheapRuler.destination(wp.ilon, wp.ilat, searchRadius * 2, a);
|
||||
OsmNodeNamed onn = new OsmNodeNamed(new OsmNode(pos[0], pos[1]));
|
||||
onn.name = "via" + a;
|
||||
|
||||
MatchedWaypoint wpt = new MatchedWaypoint();
|
||||
wpt.waypoint = onn;
|
||||
wpt.name = onn.name;
|
||||
listStart.add(wpt);
|
||||
}
|
||||
|
||||
for (int a = 0; a < 360; a +=90) {
|
||||
int[] pos = CheapRuler.destination(wp.ilon, wp.ilat, searchRadius, a);
|
||||
OsmNodeNamed onn = new OsmNodeNamed(new OsmNode(pos[0], pos[1]));
|
||||
onn.name = "via" + a;
|
||||
listSearch.add(onn);
|
||||
}
|
||||
|
||||
RoutingEngine re = null;
|
||||
RoutingContext rc = new RoutingContext();
|
||||
String name = routingContext.localFunction;
|
||||
int idx = name.lastIndexOf(File.separator);
|
||||
rc.localFunction = idx == -1 ? "dummy" : name.substring(0, idx+1) + "dummy.brf";
|
||||
|
||||
re = new RoutingEngine(null, null, segmentDir, wpliststart, rc, BROUTER_ENGINEMODE_ROUNDTRIP);
|
||||
rc.useDynamicDistance = true;
|
||||
re.matchWaypointsToNodes(listStart);
|
||||
re.resetCache(true);
|
||||
|
||||
int numForest = rc.expctxWay.getLookupKey("estimated_forest_class");
|
||||
int numRiver = rc.expctxWay.getLookupKey("estimated_river_class");
|
||||
|
||||
OsmNode start1 = re.nodesCache.getStartNode(listStart.get(0).node1.getIdFromPos());
|
||||
|
||||
double elev = (start1 == null ? 0 : start1.getElev());
|
||||
|
||||
List<AreaInfo> ais = new ArrayList<>();
|
||||
|
||||
listStart.remove(0);
|
||||
for (int a = 0; a < 4; a++) {
|
||||
rc.ai = new AreaInfo(a * 90 +90);
|
||||
rc.ai.elevStart = elev;
|
||||
rc.ai.numForest = numForest;
|
||||
rc.ai.numRiver = numRiver;
|
||||
|
||||
List<OsmNodeNamed> wplist = new ArrayList<>();
|
||||
wplist.add(new OsmNodeNamed(listStart.get(a).waypoint));
|
||||
if (a == 3) wplist.add(new OsmNodeNamed(listStart.get(0).waypoint));
|
||||
else wplist.add(new OsmNodeNamed(listStart.get(a+1).waypoint));
|
||||
|
||||
rc.ai.polygon = new OsmNogoPolygon(true);
|
||||
rc.ai.polygon.addVertex(wp.ilon, wp.ilat);
|
||||
rc.ai.polygon.addVertex(wplist.get(0).ilon, wplist.get(0).ilat);
|
||||
rc.ai.polygon.addVertex(wplist.get(1).ilon, wplist.get(1).ilat);
|
||||
|
||||
List<OsmNodeNamed> wpsearchlist = new ArrayList<>();
|
||||
wpsearchlist.add(listSearch.get(a));
|
||||
if (a == 3) wpsearchlist.add(listSearch.get(0));
|
||||
else wpsearchlist.add(listSearch.get(a+1));
|
||||
|
||||
rc.useDynamicDistance = true;
|
||||
re = new RoutingEngine(null, null, segmentDir, wpsearchlist, rc, 0);
|
||||
rc.processUnusedTags = true;
|
||||
rc.turnInstructionMode = 9;
|
||||
re.doRun(0);
|
||||
|
||||
ais.add(rc.ai);
|
||||
}
|
||||
|
||||
logInfo("execution time get area = " + (System.currentTimeMillis() - start) / 1000. + " seconds");
|
||||
|
||||
|
||||
// for (AreaInfo ai: ais) {
|
||||
// System.out.println("\n" + ai.toString());
|
||||
//}
|
||||
|
||||
switch (preferredRandomType) {
|
||||
case AreaInfo.RESULT_TYPE_ELEV50:
|
||||
Collections.sort(ais, new Comparator<>() {
|
||||
public int compare(AreaInfo o1, AreaInfo o2) {
|
||||
return o2.getElev50Weight() - o1.getElev50Weight();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case AreaInfo.RESULT_TYPE_GREEN:
|
||||
Collections.sort(ais, new Comparator<>() {
|
||||
public int compare(AreaInfo o1, AreaInfo o2) {
|
||||
return o2.getGreen() - o1.getGreen();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case AreaInfo.RESULT_TYPE_RIVER:
|
||||
Collections.sort(ais, new Comparator<>() {
|
||||
public int compare(AreaInfo o1, AreaInfo o2) {
|
||||
return o2.getRiver() - o1.getRiver();
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
return (int) (Math.random()*360);
|
||||
}
|
||||
|
||||
int angle = ais.get(ais.size()-1).direction;
|
||||
return angle - 45 + (int) (Math.random()*90);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void postElevationCheck(OsmTrack track) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user