Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add has_transit_tiles and osm_changeset ID to verbose /status response #4062

Merged
merged 18 commits into from
May 8, 2023

Conversation

nilsnolde
Copy link
Member

fixes #4053

Is that small enough?;)

I'll add a changelog later to see if the CI script works again.

R"(","tileset_last_modified":0,"available_actions":["status","centroid","expansion","transit_available","trace_attributes","trace_route","isochrone","optimized_route","sources_to_targets","height","route","locate"]})"},
{200,
R"({"version":")" VALHALLA_VERSION
R"(","tileset_last_modified":0,"available_actions":["status","centroid","expansion","transit_available","trace_attributes","trace_route","isochrone","optimized_route","sources_to_targets","height","route","locate"],"has_tiles":false,"has_admins":false,"has_timezones":false,"has_live_traffic":false,"has_transit_tiles":false,"osm_changeset":0,"bbox":{"features":[],"type":"FeatureCollection"}})"},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops.. not that small after all.. obviously I only changed this line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't show in the test of course..

@nilsnolde
Copy link
Member Author

Jep, re-generating the circleci token seems to have worked @kevinkreiser

Comment on lines +22 to +24
string version = 6;
uint32 tileset_last_modified = 7;
repeated string available_actions = 8;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these didn't need a oneof actually

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neither do the new ones

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is true!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess in an earlier implementation they did but 🤷

Copy link
Member Author

@nilsnolde nilsnolde May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no @kevinkreiser they're needed, just as the other ones which are only available via "verbose": true: in the serializer we're using their has_ method to check if we should set it in the output JSON or leave it out. I guess that wouldn't necessarily need to be handled with oneofs, one could also look at the verbose() in the serializer, but that way we'd tightly couple those outputs to verbose() while now we're more flexible and could disallow including them in the JSON based on other logic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think tightly coupling to verbose makes perfect sense in this case but also i dont care that much! we should just upgrade to newer protobuf and forget the idiocy in the earlier versions of proto3, then we can remove oneof and still have the has_ methods

@nilsnolde nilsnolde mentioned this pull request Apr 7, 2023
@nilsnolde nilsnolde mentioned this pull request Apr 7, 2023
src/loki/status_action.cc Outdated Show resolved Hide resolved
Comment on lines +64 to +69
const bool has_transit_tiles =
connectivity_map->level_color_exists(TileHierarchy::GetTransitLevel().level);
status->set_has_transit_tiles(has_transit_tiles);
} else {
const static bool has_transit_tiles = !reader->GetTileSet(3).empty();
status->set_has_transit_tiles(has_transit_tiles);
Copy link
Member Author

@nilsnolde nilsnolde Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have a connectivity map, great, we'll use the newly added transit level in there via a new tiny function, else we fall back to the much more expensive tile parsing (static so only the first request has to pay that penalty)

@@ -55,15 +57,23 @@ void loki_worker_t::status(Api& request) const {

// get _some_ tile
const static baldr::graph_tile_ptr tile = get_graphtile(reader);
// TODO: get this from the connectivity_map once transit is implemented there
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this, it's done

}

status->set_has_tiles(static_cast<bool>(tile));
status->set_has_admins(tile && tile->header()->admincount() > 0);
status->set_has_timezones(tile && tile->node(0)->timezone() > 0);
status->set_has_live_traffic(reader->HasLiveTraffic());
status->set_osm_changeset(tile && tile->header()->dataset_id());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is no good. the result is a boolean

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh, good catch!

}

status->set_has_tiles(static_cast<bool>(tile));
status->set_has_admins(tile && tile->header()->admincount() > 0);
status->set_has_timezones(tile && tile->node(0)->timezone() > 0);
status->set_has_live_traffic(reader->HasLiveTraffic());
status->set_osm_changeset(tile ? tile->header()->dataset_id() : 0);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we set the changeset here, but don't set it in the serializer's output JSON if it was 0

// a 0 changeset indicates there's none, so don't write in the output
// TODO: currently this can't be tested as gurka isn't adding changeset IDs to OSM objects (yet)
if (request.status().has_osm_changeset_case() && request.status().osm_changeset())
status_doc.AddMember("osm_changeset",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we only set the changeset when there was one, this code path isn't tested. gurka doesn't add changeset IDs to objects. I left a todo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return more info on /status
2 participants