use of net.osmand.router.GeneralRouter in project OsmAnd-tools by osmandapp.
the class ManyToOneRoadCalculation method calculateManyToMany.
private void calculateManyToMany(RoutingContext ctx, TLongObjectHashMap<ManyToManySegment> allSegments, List<ManyToManySegment> topIntersects, List<ManyToManySegment> bottomIntersects, int stop, final int sbottom) {
final GeneralRouter router = ctx.config.router;
float DISTANCE_THRESHOLD = 50000;
// TODO depth search from one top intersect
List<TLongArrayList> sets = new ArrayList<TLongArrayList>();
for (int i = 0; i < topIntersects.size(); i++) {
ManyToManySegment oneTop = topIntersects.get(i);
clearAllSegments(allSegments);
List<ManyToManySegment> finalSegmentResult = calculateOneToMany(allSegments, bottomIntersects, sbottom, router, oneTop);
for (ManyToManySegment fnsResult : finalSegmentResult) {
TLongArrayList set = convertToRoadIds(fnsResult, DISTANCE_THRESHOLD / router.getMaxSpeed());
combineWithLocal(sets, set);
}
System.out.println(oneTop.road.getHighway() + " " + oneTop.road.id + " " + oneTop.segmentIndex + " common ways=" + sets.size());
}
System.out.println(sets.size());
for (TLongArrayList s : sets) {
System.out.println(s);
}
}
use of net.osmand.router.GeneralRouter in project OsmAnd-tools by osmandapp.
the class RoutingController method routingParams.
@RequestMapping(path = "/routing-modes", produces = { MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<?> routingParams() {
Map<String, RoutingMode> routers = new LinkedHashMap<String, RoutingMode>();
RoutingParameter nativeRouting = new RoutingParameter("nativerouting", "Development", "[Dev] C++ routing", true);
RoutingParameter nativeTrack = new RoutingParameter("nativeapproximation", "Development", "[Dev] C++ route track", true);
RoutingParameter calcMode = new RoutingParameter("calcmode", "[Dev] Route mode", "Algorithm to calculate route", null, RoutingParameterType.SYMBOLIC.name().toLowerCase());
calcMode.section = "Development";
calcMode.value = "";
calcMode.valueDescriptions = new String[] { "Optimal", "Basic", "Slow" };
calcMode.values = new String[] { RouteCalculationMode.COMPLEX.name(), RouteCalculationMode.BASE.name(), RouteCalculationMode.NORMAL.name() };
for (Map.Entry<String, GeneralRouter> e : RoutingConfiguration.getDefault().getAllRouters().entrySet()) {
if (!e.getKey().equals("geocoding") && !e.getKey().equals("public_transport")) {
RoutingMode rm = new RoutingMode();
rm.key = e.getKey();
rm.name = Algorithms.capitalizeFirstLetter(rm.key).replace('_', ' ');
routers.put(rm.key, rm);
List<RoutingParameter> rps = new ArrayList<RoutingParameter>();
for (Entry<String, GeneralRouter.RoutingParameter> epm : e.getValue().getParameters().entrySet()) {
net.osmand.router.GeneralRouter.RoutingParameter pm = epm.getValue();
RoutingParameter rp = new RoutingParameter(pm.getId(), pm.getName(), pm.getDescription(), pm.getGroup(), pm.getType().name().toLowerCase());
if (pm.getId().startsWith("avoid")) {
rp.section = "Avoid";
} else if (pm.getId().startsWith("allow") || pm.getId().startsWith("prefer")) {
rp.section = "Allow";
} else if (pm.getGroup() != null) {
rp.section = Algorithms.capitalizeFirstLetter(pm.getGroup().replace('_', ' '));
}
if (pm.getType() == RoutingParameterType.BOOLEAN) {
rp.value = pm.getDefaultBoolean();
} else {
if (pm.getType() == RoutingParameterType.NUMERIC) {
rp.value = 0;
} else {
rp.value = "";
}
rp.valueDescriptions = pm.getPossibleValueDescriptions();
rp.values = pm.getPossibleValues();
}
int lastIndex = -1;
for (int i = 0; i < rps.size(); i++) {
if (Algorithms.objectEquals(rp.section, rps.get(i).section)) {
lastIndex = i;
}
}
if (lastIndex != -1 && !Algorithms.isEmpty(rp.section)) {
rps.add(lastIndex + 1, rp);
} else {
rps.add(rp);
}
}
for (RoutingParameter rp : rps) {
rm.params.put(rp.key, rp);
}
rm.params.put(nativeRouting.key, nativeRouting);
rm.params.put(nativeTrack.key, nativeTrack);
rm.params.put(calcMode.key, calcMode);
}
}
for (RoutingServerConfigEntry rs : osmAndMapsService.getRoutingConfig().config.values()) {
RoutingMode rm = new RoutingMode();
rm.key = rs.name;
rm.name = Algorithms.capitalizeFirstLetter(rs.name).replace('_', ' ');
routers.put(rm.key, rm);
rm.params.put(nativeRouting.key, nativeRouting);
rm.params.put(nativeTrack.key, nativeTrack);
}
return ResponseEntity.ok(gson.toJson(routers));
}
Aggregations