Skip to content

Commit

Permalink
address bug for tdmatrix when shape_format -ne 'none'
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsnolde committed Dec 9, 2023
1 parent 1a01879 commit 89ec5a8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/tyr/matrix_serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ json::ArrayPtr serialize_shape(const valhalla::Matrix& matrix,
const ShapeFormat shape_format) {
// TODO(nils): shapes aren't implemented yet in TDMatrix
auto shapes = json::array({});
if (shape_format == no_shape)
if (shape_format == no_shape || matrix.algorithm() != Matrix::CostMatrix)
return shapes;

for (size_t i = start_td; i < start_td + td_count; ++i) {
Expand Down Expand Up @@ -145,8 +145,7 @@ json::ArrayPtr serialize_row(const valhalla::Matrix& matrix,
if (!date_time.empty()) {
map->emplace("date_time", date_time);
}
// TODO(nils): shapes aren't implemented yet in TDMatrix
if (matrix.shapes().size() && !matrix.shapes()[i].empty()) {
if (matrix.shapes().size()) {
switch (shape_format) {
case geojson:
map->emplace("shape",
Expand Down Expand Up @@ -200,7 +199,7 @@ std::string serialize(const Api& request, double distance_scale) {
}
matrix->emplace("distances", distance);
matrix->emplace("durations", time);
if (!(options.shape_format() == no_shape))
if (!(options.shape_format() == no_shape) && request.matrix().algorithm() == Matrix::CostMatrix)
matrix->emplace("shapes", shapes);

json->emplace("sources_to_targets", matrix);
Expand Down

0 comments on commit 89ec5a8

Please sign in to comment.