Commit d762cdd2 authored by DaGal's avatar DaGal

Get rid of most of the debug info as it can generate a lot of overhead

parent f3a8e616
......@@ -35,7 +35,6 @@ import com.graphhopper.storage.index.QueryResult;
import com.graphhopper.util.Parameters.Routing;
import com.graphhopper.util.PathMerger;
import com.graphhopper.util.PointList;
import com.graphhopper.util.StopWatch;
import com.graphhopper.util.Translation;
import com.graphhopper.util.shapes.GHPoint;
......@@ -61,18 +60,12 @@ public class OneToManyRoutingTemplate extends ViaRoutingTemplate {
int pointCounts = ghRequest.getPoints().size();
pathList = new ArrayList<>(pointCounts - 1);
QueryResult fromQResult = queryResults.get(0);
StopWatch sw;
RoutingAlgorithm algo = algoFactory.createAlgo(queryGraph, algoOpts);
for (int placeIndex = 1; placeIndex < pointCounts; placeIndex++) {
QueryResult toQResult = queryResults.get(placeIndex);
sw = new StopWatch().start();
String debug = ", algoInit:" + sw.stop().getSeconds() + "s";
sw = new StopWatch().start();
List<Path> tmpPathList = algo.calcPaths(fromQResult.getClosestNode(), toQResult.getClosestNode());
debug += ", " + algo.getName() + "-routing:" + sw.stop().getSeconds() + "s";
if (tmpPathList.isEmpty())
throw new IllegalStateException("At least one path has to be returned for " + fromQResult + " -> " + toQResult);
......@@ -82,11 +75,9 @@ public class OneToManyRoutingTemplate extends ViaRoutingTemplate {
throw new RuntimeException("Time was negative " + path.getTime() + " for index " + idx + ". Please report as bug and include:" + ghRequest);
pathList.add(path);
debug += ", " + path.getDebugInfo();
idx++;
}
altResponse.addDebugInfo(debug);
// reset all direction enforcements in queryGraph to avoid influencing next path
queryGraph.clearUnfavoredStatus();
......@@ -94,7 +85,7 @@ public class OneToManyRoutingTemplate extends ViaRoutingTemplate {
if (algo.getVisitedNodes() >= algoOpts.getMaxVisitedNodes())
throw new IllegalArgumentException("No path found due to maximum nodes exceeded " + algoOpts.getMaxVisitedNodes());
visitedNodesSum += algo.getVisitedNodes();
visitedNodesSum = algo.getVisitedNodes();
}
ghResponse.getHints().put("visited_nodes.sum", visitedNodesSum);
......
......@@ -17,16 +17,21 @@
*/
package com.graphhopper.http;
import com.graphhopper.GHRequest;
import com.graphhopper.GHResponse;
import com.graphhopper.GraphHopperAPI;
import com.graphhopper.PathWrapper;
import com.graphhopper.routing.util.EncodingManager;
import com.graphhopper.routing.util.FlagEncoder;
import com.graphhopper.util.StopWatch;
import com.graphhopper.util.shapes.GHPoint;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import static com.graphhopper.util.Parameters.DETAILS.PATH_DETAILS;
import static com.graphhopper.util.Parameters.Routing.CALC_POINTS;
import static com.graphhopper.util.Parameters.Routing.INSTRUCTIONS;
import static com.graphhopper.util.Parameters.Routing.POINT_HINT;
import static com.graphhopper.util.Parameters.Routing.WAY_POINT_MAX_DISTANCE;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
......@@ -39,13 +44,18 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.IOException;
import java.io.StringWriter;
import java.util.*;
import static com.graphhopper.util.Parameters.DETAILS.PATH_DETAILS;
import static com.graphhopper.util.Parameters.Routing.*;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import com.graphhopper.GHRequest;
import com.graphhopper.GHResponse;
import com.graphhopper.GraphHopperAPI;
import com.graphhopper.PathWrapper;
import com.graphhopper.routing.util.EncodingManager;
import com.graphhopper.routing.util.FlagEncoder;
import com.graphhopper.util.StopWatch;
import com.graphhopper.util.shapes.GHPoint;
/**
* Servlet to use GraphHopper in a remote client application like mobile or browser. Note: If type
......@@ -67,6 +77,11 @@ public class GraphHopperServlet extends GHBaseServlet {
@Named("hasElevation")
private boolean hasElevation;
@Override
public void doPost(HttpServletRequest httpReq, HttpServletResponse httpRes) throws ServletException, IOException {
doGet(httpReq, httpRes);
}
@Override
public void doGet(HttpServletRequest httpReq, HttpServletResponse httpRes) throws ServletException, IOException {
List<GHPoint> requestPoints = getPoints(httpReq, "point");
......@@ -151,7 +166,7 @@ public class GraphHopperServlet extends GHBaseServlet {
float took = sw.stop().getSeconds();
String infoStr = httpReq.getRemoteAddr() + " " + httpReq.getLocale() + " " + httpReq.getHeader("User-Agent");
String logStr = httpReq.getQueryString() + " " + infoStr + " " + requestPoints + ", took:"
String logStr = httpReq.getQueryString() + " " + infoStr + " " + (requestPoints.size() > 10 ? "" : requestPoints) + ", took:"
+ took + ", " + algoStr + ", " + weighting + ", " + vehicleStr;
httpRes.setHeader("X-GH-Took", "" + Math.round(took * 1000));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment