Skip to content

Commit

Permalink
fixed up optimization waypoint object
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Mace committed Jul 18, 2017
1 parent a88d374 commit dfd079a
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mapbox.services.api.directions.v5.models;

import com.google.gson.annotations.SerializedName;
import com.mapbox.services.commons.models.Position;

/**
Expand All @@ -12,8 +11,6 @@ public class DirectionsWaypoint {

private String name;
private double[] location;
@SerializedName("waypoint_index")
private int waypointIndex;

/**
* Empty constructor
Expand Down Expand Up @@ -73,30 +70,4 @@ public void setLocation(double[] location) {
public Position asPosition() {
return Position.fromCoordinates(location[0], location[1]);
}

/**
* Index of the waypoint inside the matched route (MapMatching API) or within the trip (Optimization API).
* <p>
* Note: Only used with Optimization and MapMatching APIs.
* </p>
*
* @return an integer representing the waypoint position within the trip or matched route
* @since 2.2.0
*/
public int getWaypointIndex() {
return waypointIndex;
}

/**
* Set the index of the waypoint inside the matched route (MapMatching API) or within the trip (Optimization API).
* <p>
* Note: Only used with Optimization and MapMatching APIs.
* </p>
*
* @param waypointIndex an integer representing the waypoint position within the trip or matched route
* @since 2.2.0
*/
public void setWaypointIndex(int waypointIndex) {
this.waypointIndex = waypointIndex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class MapMatchingTracepoint extends DirectionsWaypoint {
@SerializedName("waypoint_index")
private int waypointIndex;

/**
* Public constructor
*/
public MapMatchingTracepoint() {
}

Expand All @@ -28,6 +31,7 @@ public MapMatchingTracepoint(int matchingsIndex, int alternativesCount, int wayp
* Index to the match object in matchings the sub-trace was matched to.
*
* @return index value
* @since 2.2.0
*/
public int getMatchingsIndex() {
return matchingsIndex;
Expand All @@ -37,6 +41,7 @@ public int getMatchingsIndex() {
* Index value
*
* @param matchingsIndex value
* @since 2.2.0
*/
public void setMatchingsIndex(int matchingsIndex) {
this.matchingsIndex = matchingsIndex;
Expand All @@ -46,6 +51,7 @@ public void setMatchingsIndex(int matchingsIndex) {
* Index of the waypoint inside the matched route.
*
* @return index value
* @since 2.2.0
*/
public int getWaypointIndex() {
return waypointIndex;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.mapbox.services.api.optimizedtrips.v1.models;

import com.google.gson.annotations.SerializedName;
import com.mapbox.services.api.directions.v5.models.DirectionsWaypoint;

public class OptimizationWaypoint extends DirectionsWaypoint {

@SerializedName("waypoint_index")
private int waypointIndex;
@SerializedName("trips_index")
private int tripsIndex;

/**
* Empty constructor
*
* @since 2.2.0
*/
public OptimizationWaypoint() {
}

/**
* Construct an OptimizationWaypoint object.
*
* @param waypointIndex index of position of the waypoint within the trip
* @param tripsIndex index to the trip object in the trips array that contains this waypoint
* @since 2.2.0
*/
public OptimizationWaypoint(int waypointIndex, int tripsIndex) {
this.waypointIndex = waypointIndex;
this.tripsIndex = tripsIndex;
}

/**
* Index of the waypoint inside the optimization route.
*
* @return index value
* @since 2.2.0
*/
public int getWaypointIndex() {
return waypointIndex;
}

/**
* Index value
*
* @param waypointIndex value
* @since 2.2.0
*/
public void setWaypointIndex(int waypointIndex) {
this.waypointIndex = waypointIndex;
}

/**
* Index to the trip object in the trips array that contains this waypoint.
*
* @return index value
* @since 2.2.0
*/
public int getTripsIndex() {
return tripsIndex;
}

/**
* Index to the trip object in the trips array that contains this waypoint.
*
* @param tripsIndex index value
* @since 2.2.0
*/
public void setTripsIndex(int tripsIndex) {
this.tripsIndex = tripsIndex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class OptimizedTripsResponse {

private String code;
private List<DirectionsWaypoint> waypoints;
private List<OptimizationWaypoint> waypoints;
private List<DirectionsRoute> trips;

/**
Expand All @@ -27,7 +27,7 @@ public OptimizedTripsResponse() {
* want the waypoints to match the ones making up the directions route.
* @since 2.1.0
*/
public OptimizedTripsResponse(List<DirectionsRoute> trips, List<DirectionsWaypoint> waypoints) {
public OptimizedTripsResponse(List<DirectionsRoute> trips, List<OptimizationWaypoint> waypoints) {
this.trips = trips;
this.waypoints = waypoints;
}
Expand Down Expand Up @@ -71,24 +71,24 @@ public void setCode(String code) {
}

/**
* List of {@link DirectionsWaypoint} objects. Each waypoint is an input coordinate snapped to the road and path
* List of {@link OptimizationWaypoint} objects. Each waypoint is an input coordinate snapped to the road and path
* network. The waypoints appear in the list in the order of the input coordinates.
*
* @return a list of {@link DirectionsWaypoint}s in the order of the input coordinates.
* @return a list of {@link OptimizationWaypoint}s in the order of the input coordinates.
* @since 2.1.0
*/
public List<DirectionsWaypoint> getWaypoints() {
public List<OptimizationWaypoint> getWaypoints() {
return waypoints;
}

/**
* List of {@link DirectionsWaypoint} objects. Each waypoint should be an input coordinate snapped to the road and
* List of {@link OptimizationWaypoint} objects. Each waypoint should be an input coordinate snapped to the road and
* path network. The waypoints should appear in the list in the order of the input coordinates.
*
* @param waypoints a list of {@link DirectionsWaypoint}s in the order of the input coordinates.
* @param waypoints a list of {@link OptimizationWaypoint}s in the order of the input coordinates.
* @since 2.1.0
*/
public void setWaypoints(List<DirectionsWaypoint> waypoints) {
public void setWaypoints(List<OptimizationWaypoint> waypoints) {
this.waypoints = waypoints;
}

Expand Down

0 comments on commit dfd079a

Please sign in to comment.