Package com.targomo.client.api.response
Class TimeResponse
java.lang.Object
com.targomo.client.api.response.TimeResponse
-
Constructor Summary
ConstructorsConstructorDescriptionTimeResponse(TravelOptions travelOptions, ResponseCode code, long requestTime, long requestStart) Create a response with custom response code and without results.TimeResponse(TravelOptions travelOptions, org.json.JSONObject result, long requestStart) Create a response from JSON results. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTravelWeight(Coordinate source, Coordinate target, Integer travelTime, Integer length) getCode()getLength(Coordinate source, Coordinate target) Get travel distances from each source point to each target point.longlonggetTravelTime(Coordinate source, Coordinate target) Get travel times from each source point to each target point.getTravelWeight(Coordinate source, Coordinate target) Get travel weights from each source point to each target point.voidmapResults(TravelOptions travelOptions, org.json.JSONObject result) Parse results in JSON to travel times map.voidmapResults(org.json.JSONObject result) Parse results in JSON to travel times map.
-
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 requestresult- Travel times in JSONrequestStart- 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 requestcode- Response coderequestTime- Execution time in millisecondsrequestStart- 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
Parse results in JSON to travel times map.- Parameters:
travelOptions- options used in the requestresult- resulting JSON
-
addTravelWeight
public void addTravelWeight(Coordinate source, Coordinate target, Integer travelTime, Integer length) - Parameters:
source- Source coordinatetarget- Target coordinatetravelTime- Travel time to be addedlength- Travel distance to be added
-
getTravelTime
- Parameters:
source- Source coordinatetarget- Target coordinate- Returns:
- null if the source or the target is not available, the travel time otherwise
-
getLength
- Parameters:
source- Source coordinatetarget- Target coordinate- Returns:
- null if the source or the target is not available, the travel time otherwise
-
getTravelWeight
- Parameters:
source- Source coordinatetarget- Target coordinate- Returns:
- null if the source or the target is not available, the travel weight otherwise
-
getCode
- Returns:
- the code
-
getRequestTimeMillis
public long getRequestTimeMillis()- Returns:
- the requestTimeMillis
-
getTravelOptions
- Returns:
- the travelOptions
-
getTravelWeights
Get travel weights from each source point to each target point.- Returns:
- map from each source to (targets, travel times)
-
getTravelTimes
Get travel times from each source point to each target point.- Returns:
- map from each source to (targets, travel times)
-
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
-