Class TimeResponse

java.lang.Object
com.targomo.client.api.response.TimeResponse

public class TimeResponse extends Object
  • Constructor Details

    • TimeResponse

      public TimeResponse(TravelOptions travelOptions, org.json.JSONObject result, long requestStart) throws ResponseErrorException
      Create a response from JSON results.
      Parameters:
      travelOptions - Travel options used in request
      result - Travel times in JSON
      requestStart - Start time of execution
      Throws:
      ResponseErrorException
    • TimeResponse

      public TimeResponse(TravelOptions travelOptions, ResponseCode code, long requestTime, long requestStart)
      Create a response with custom response code and without results. Can be used in case of errors.
      Parameters:
      travelOptions - Travel options used in request
      code - Response code
      requestTime - Execution time in milliseconds
      requestStart - Start time of execution
  • Method Details

    • mapResults

      public void mapResults(org.json.JSONObject result)
      Parse results in JSON to travel times map.
      Parameters:
      result - resulting JSON
    • mapResults

      public void mapResults(TravelOptions travelOptions, org.json.JSONObject result)
      Parse results in JSON to travel times map.
      Parameters:
      travelOptions - options used in the request
      result - resulting JSON
    • addTravelWeight

      public void addTravelWeight(Coordinate source, Coordinate target, Integer travelTime, Integer length)
      Parameters:
      source - Source coordinate
      target - Target coordinate
      travelTime - Travel time to be added
      length - Travel distance to be added
    • getTravelTime

      public Integer getTravelTime(Coordinate source, Coordinate target)
      Parameters:
      source - Source coordinate
      target - Target coordinate
      Returns:
      null if the source or the target is not available, the travel time otherwise
    • getLength

      public Integer getLength(Coordinate source, Coordinate target)
      Parameters:
      source - Source coordinate
      target - Target coordinate
      Returns:
      null if the source or the target is not available, the travel time otherwise
    • getTravelWeight

      public TravelWeight getTravelWeight(Coordinate source, Coordinate target)
      Parameters:
      source - Source coordinate
      target - Target coordinate
      Returns:
      null if the source or the target is not available, the travel weight otherwise
    • getCode

      public ResponseCode getCode()
      Returns:
      the code
    • getRequestTimeMillis

      public long getRequestTimeMillis()
      Returns:
      the requestTimeMillis
    • getTravelOptions

      public TravelOptions getTravelOptions()
      Returns:
      the travelOptions
    • getTravelWeights

      public Map<Coordinate,Map<Coordinate,TravelWeight>> getTravelWeights()
      Get travel weights from each source point to each target point.
      Returns:
      map from each source to (targets, travel times)
    • getTravelTimes

      public Map<Coordinate,Map<Coordinate,Integer>> getTravelTimes()
      Get travel times from each source point to each target point.
      Returns:
      map from each source to (targets, travel times)
    • getLengths

      public Map<Coordinate,Map<Coordinate,Integer>> getLengths()
      Get travel distances from each source point to each target point.
      Returns:
      map from each source to (targets, lengths)
    • getTotalTime

      public long getTotalTime()
      Returns:
      Total execution time