Skip to content

Commit

Permalink
Merge branch 'enhancement/add-unassigned-type'
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoupey committed Mar 19, 2021
2 parents 76d04c1 + 8c76804 commit ffa1c6d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- Support Valhalla as routing engine (#306)
- Report `type` for unassigned tasks in output (#469)

### Changed

Expand Down
2 changes: 1 addition & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ The computed solution is written as `json` on standard output or a file
| `code` | status code |
| `error` | error message (present iff `code` is different from `0`) |
| [`summary`](#summary) | object summarizing solution indicators |
| `unassigned` | array of objects describing unassigned tasks with their `id` and `location` (if provided) |
| `unassigned` | array of objects describing unassigned tasks with their `id`, `type` and `location` (if provided) |
| [`routes`](#routes) | array of `route` objects |

## Code
Expand Down
15 changes: 15 additions & 0 deletions src/utils/output_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ rapidjson::Document to_json(const Solution& sol, bool geometry) {
to_json(job.location, allocator),
allocator);
}
json_job.AddMember("type", rapidjson::Value(), allocator);
std::string str_type;
switch (job.type) {
case JOB_TYPE::SINGLE:
str_type = "job";
break;
case JOB_TYPE::PICKUP:
str_type = "pickup";
break;
case JOB_TYPE::DELIVERY:
str_type = "delivery";
break;
}
json_job["type"].SetString(str_type.c_str(), str_type.size(), allocator);

json_unassigned.PushBack(json_job, allocator);
}

Expand Down

0 comments on commit ffa1c6d

Please sign in to comment.