Skip to content

Commit

Permalink
Merge pull request #471 from mapbox/danpat_remove_optimization_limits
Browse files Browse the repository at this point in the history
fix: optimization limits should only be enforced server-side.
  • Loading branch information
danpat authored Aug 2, 2023
2 parents 54d95db + cecd173 commit af0dd71
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ to understand all of the available options.
* `config` **[Object][207]** 

* `config.profile` **(`"driving"` | `"driving-traffic"` | `"walking"` | `"cycling"`)** (optional, default `"driving"`)
* `config.waypoints` **[Array][216]<[OptimizationWaypoint][180]>** An ordered array of [`OptimizationWaypoint`][180] objects, between 2 and 12 (inclusive).
* `config.waypoints` **[Array][216]<[OptimizationWaypoint][180]>** An ordered array of [`OptimizationWaypoint`][180] objects, with at least 2
* `config.annotations` **[Array][216]<(`"duration"` | `"distance"` | `"speed"`)>?** Specify additional metadata that should be returned.
* `config.destination` **(`"any"` | `"last"`)** Returned route ends at `any` or `last` coordinate. (optional, default `"any"`)
* `config.distributions` **[Array][216]<[Distribution][203]>?** An ordered array of [`Distribution`][203] objects, each of which includes a `pickup` and `dropoff` property. `pickup` and `dropoff` properties correspond to an index in the OptimizationWaypoint array.
Expand Down
2 changes: 1 addition & 1 deletion services/__tests__/optimization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('getOptimization', () => {
},
error => {
expect(error.message).toMatch(
'waypoints must include between 2 and 12 OptimizationWaypoints'
'waypoints must include at least 2 OptimizationWaypoints'
);
}
);
Expand Down
6 changes: 3 additions & 3 deletions services/optimization.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var Optimization = {};
*
* @param {Object} config
* @param {'driving'|'driving-traffic'|'walking'|'cycling'} [config.profile="driving"]
* @param {Array<OptimizationWaypoint>} config.waypoints - An ordered array of [`OptimizationWaypoint`](#optimizationwaypoint) objects, between 2 and 12 (inclusive).
* @param {Array<OptimizationWaypoint>} config.waypoints - An ordered array of [`OptimizationWaypoint`](#optimizationwaypoint) objects, with at least 2
* @param {Array<'duration'|'distance'|'speed'>} [config.annotations] - Specify additional metadata that should be returned.
* @param {'any'|'last'} [config.destination="any"] - Returned route ends at `any` or `last` coordinate.
* @param {Array<Distribution>} [config.distributions] - An ordered array of [`Distribution`](#distribution) objects, each of which includes a `pickup` and `dropoff` property. `pickup` and `dropoff` properties correspond to an index in the OptimizationWaypoint array.
Expand Down Expand Up @@ -72,9 +72,9 @@ Optimization.getOptimization = function(config) {
};

var waypointCount = config.waypoints.length;
if (waypointCount < 2 || waypointCount > 12) {
if (waypointCount < 2) {
throw new Error(
'waypoints must include between 2 and 12 OptimizationWaypoints'
'waypoints must include at least 2 OptimizationWaypoints'
);
}

Expand Down

0 comments on commit af0dd71

Please sign in to comment.