Add small fix (6)
This commit is contained in:
parent
c0827b8ced
commit
fe6854d90d
1 changed files with 1 additions and 67 deletions
|
@ -972,72 +972,6 @@ public class RouteProvider {
|
|||
return directions;
|
||||
}
|
||||
|
||||
protected RouteCalculationResult findORSRoute(RouteCalculationParams params) throws MalformedURLException, IOException, ParserConfigurationException, FactoryConfigurationError,
|
||||
SAXException {
|
||||
List<Location> res = new ArrayList<Location>();
|
||||
|
||||
String rpref = "Fastest";
|
||||
if (params.mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
|
||||
rpref = "Pedestrian";
|
||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
|
||||
rpref = "Bicycle";
|
||||
// } else if (ApplicationMode.LOWTRAFFIC == mode) {
|
||||
// rpref = "BicycleSafety";
|
||||
// } else if (ApplicationMode.RACEBIKE == mode) {
|
||||
// rpref = "BicycleRacer";
|
||||
// } else if (ApplicationMode.TOURBIKE == mode) {
|
||||
// rpref = "BicycleRoute";
|
||||
// } else if (ApplicationMode.MTBIKE == mode) {
|
||||
// rpref = "BicycleMTB";
|
||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
||||
if (!params.fast) {
|
||||
rpref = "Shortest";
|
||||
}
|
||||
} else {
|
||||
return applicationModeNotSupported(params);
|
||||
}
|
||||
|
||||
StringBuilder request = new StringBuilder();
|
||||
request.append("https://openls.geog.uni-heidelberg.de/osm/eu/routing?").append("start=").append(params.start.getLongitude()).append(',')
|
||||
.append(params.start.getLatitude()).append("&end=").append(params.end.getLongitude()).append(',').append(params.end.getLatitude())
|
||||
.append("&preference=").append(rpref);
|
||||
// TODO if we would get instructions from the service, we could use this language setting
|
||||
// .append("&language=").append(Locale.getDefault().getLanguage());
|
||||
|
||||
log.info("URL route " + request);
|
||||
URLConnection connection = NetworkUtils.getHttpURLConnection(request.toString());
|
||||
connection.setRequestProperty("User-Agent", Version.getFullVersion(params.ctx));
|
||||
|
||||
DocumentBuilder dom = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document doc = dom.parse(new InputSource(new InputStreamReader(connection.getInputStream())));
|
||||
NodeList list = doc.getElementsByTagName("xls:RouteGeometry"); //$NON-NLS-1$
|
||||
for (int i = 0; i < list.getLength(); i++) {
|
||||
NodeList poslist = ((Element) list.item(i)).getElementsByTagName("gml:pos"); //$NON-NLS-1$
|
||||
for (int j = 0; j < poslist.getLength(); j++) {
|
||||
String text = poslist.item(j).getFirstChild().getNodeValue();
|
||||
int s = text.indexOf(' ');
|
||||
try {
|
||||
double lon = Double.parseDouble(text.substring(0, s));
|
||||
double lat = Double.parseDouble(text.substring(s + 1));
|
||||
Location l = new Location("router"); //$NON-NLS-1$
|
||||
l.setLatitude(lat);
|
||||
l.setLongitude(lon);
|
||||
res.add(l);
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list.getLength() == 0) {
|
||||
if (doc.getChildNodes().getLength() == 1) {
|
||||
Node item = doc.getChildNodes().item(0);
|
||||
return new RouteCalculationResult(item.getNodeValue());
|
||||
|
||||
}
|
||||
}
|
||||
params.intermediates = null;
|
||||
return new RouteCalculationResult(res, null, params, null, true);
|
||||
}
|
||||
|
||||
public GPXFile createOsmandRouterGPX(RouteCalculationResult srcRoute, OsmandApplication ctx) {
|
||||
TargetPointsHelper helper = ctx.getTargetPointsHelper();
|
||||
int currentRoute = srcRoute.currentRoute;
|
||||
|
@ -1170,7 +1104,7 @@ public class RouteProvider {
|
|||
|
||||
protected RouteCalculationResult findOSRMRoute(RouteCalculationParams params)
|
||||
throws MalformedURLException, IOException, JSONException {
|
||||
// https://router.project-osrm.org/route/v1/driving/4.83,52.28;4.95,52.28
|
||||
// http://router.project-osrm.org/route/v1/driving/4.83,52.28;4.95,52.28
|
||||
List<Location> res = new ArrayList<Location>();
|
||||
StringBuilder uri = new StringBuilder();
|
||||
// possibly hide that API key because it is privacy of osmand
|
||||
|
|
Loading…
Reference in a new issue