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 serialized warnings array to JSON output #3588

Merged
merged 90 commits into from Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
f6a577f
[src/worker.cc] add warnings for deprecated auto-shorter
MuluhGodson Apr 5, 2022
28cec35
[tyr/serializers.cc] function to serialize warnings
MuluhGodson Apr 5, 2022
a0edec8
[serializers.h] declare function for serializeWarnings
MuluhGodson Apr 5, 2022
6ad5852
[serializers.cc] refactor function for serializeWarnings
MuluhGodson Apr 5, 2022
7a52fc5
[route_serializer_valhalla.cc] add warnings serializing function to r…
MuluhGodson Apr 5, 2022
d85b06e
[serializer.cc] add warning type
MuluhGodson Apr 5, 2022
2a5154e
[warning] add warning for deprecated auto shorter
MuluhGodson Apr 6, 2022
c39ea82
[warning] add warning for deprecated hov costing
MuluhGodson Apr 6, 2022
c53b702
[warning] add waring for deprecated auto_data_fix
MuluhGodson Apr 6, 2022
9c3f845
[warning] add warning for deprecated best_paths
MuluhGodson Apr 6, 2022
a1387e0
[tyr/serializers.cc] refactor serializeWarnings function
MuluhGodson Apr 6, 2022
ec1370a
[src/worker.cc] refactor warnings object into a function
MuluhGodson Apr 6, 2022
eba2c5c
[tyr/serializer] convert warnings array object to flat array
MuluhGodson Apr 7, 2022
d44404e
make warning_text const
MuluhGodson Apr 8, 2022
869cfd2
overload serializeWarnings function for baldr/json.h
MuluhGodson Apr 8, 2022
b20f996
make warning_text a reference
MuluhGodson Apr 8, 2022
aec22b6
add function overload for serializeWarnings for other endpoints
MuluhGodson Apr 8, 2022
042c5ba
[isochrone_serializer.cc] add warnings to json output
MuluhGodson Apr 8, 2022
94f92b4
[locate_serializer.cc] add warning to locate endpoint json output
MuluhGodson Apr 8, 2022
b4d3361
[matrix_serializer.cc] add warnings to json response
MuluhGodson Apr 8, 2022
cf9da92
[height_serializer.cc] add warnings to json response
MuluhGodson Apr 8, 2022
acdb943
[transit_available_serializer.cc] add warnings to json output
MuluhGodson Apr 8, 2022
8d0878f
[src/tyr/serializers.cc] refactor serializeWarnings function to remov…
MuluhGodson Apr 8, 2022
e1f5208
[trace_serializer.cc] add warnings to json output
MuluhGodson Apr 8, 2022
5d997e0
refactor function to serialize warnings
MuluhGodson Apr 8, 2022
fecb297
[src/worker.cc] make best_paths warning only valid for request with b…
MuluhGodson Apr 8, 2022
453cdd6
prevent json response from containing an empty warnings array
MuluhGodson Apr 8, 2022
231bba5
[test] add test for route endpoint warnings
MuluhGodson Apr 9, 2022
817b58a
add array of deprecated costing options for test cases
MuluhGodson Apr 9, 2022
a65c191
add test case for locate endpoint
MuluhGodson Apr 9, 2022
e2b17f0
loop through deprecated costing options for route test case
MuluhGodson Apr 9, 2022
5e2560c
add test case for isochrone endpoint
MuluhGodson Apr 10, 2022
e6c4f43
add test case for transit_available endpoint
MuluhGodson Apr 10, 2022
52049c8
add test case for heights endpoint
MuluhGodson Apr 10, 2022
acfaeb1
add test case for map_matching endpoints
MuluhGodson Apr 11, 2022
51d1290
add test case for matrix endpoint
MuluhGodson Apr 11, 2022
24fb7f3
change add warnings function to lambda function
MuluhGodson Apr 11, 2022
1a82c87
[routes] update documentation to include info about warnings
MuluhGodson Apr 11, 2022
3e7a32f
[transit_available] update documentation with information about warnings
MuluhGodson Apr 11, 2022
7295285
[matrix] update documentation with info about warnings
MuluhGodson Apr 11, 2022
507274b
[map-matching] update documentation add information about warnings
MuluhGodson Apr 11, 2022
834dc06
[locate] update documentation with information about warnings
MuluhGodson Apr 11, 2022
efb7ee5
[isochrone] update documentation with information about warnings
MuluhGodson Apr 11, 2022
09d6ce1
[elevation] update documentation with information about warnings
MuluhGodson Apr 11, 2022
5e9f246
code clean up - remove superflfous proto includes
MuluhGodson Apr 11, 2022
6cedf81
move lambda add_warnings function to worker.h
MuluhGodson Apr 11, 2022
f0fdaf2
update CHANGELOG.md with added enhancements
MuluhGodson Apr 11, 2022
bd77452
remove loop indexes from route warnings array
MuluhGodson Apr 11, 2022
b2b1ada
convert warnings function to a normal function
MuluhGodson Apr 14, 2022
4ba4d4f
Merge branch 'master' into mg_warnings_array
MuluhGodson Apr 14, 2022
63779ce
add unordered map for warning pairs
MuluhGodson Apr 14, 2022
2dfc963
modify add_warnings function to utilizie unordered_map for warning pairs
MuluhGodson Apr 14, 2022
7b725da
modify warnings messages to use unorderd_map for warning pairs
MuluhGodson Apr 14, 2022
9119c81
add codes to serialized warnings
MuluhGodson Apr 14, 2022
a188925
Merge branch 'mg_warnings_array' of https://github.com/MuluhGodson/va…
MuluhGodson Apr 14, 2022
c660995
Merge branch 'master' into mg_warnings_array
MuluhGodson Apr 16, 2022
1a81f8a
add more context to the warnings array output.
MuluhGodson Apr 20, 2022
acfdfda
add more context to warnings array output.
MuluhGodson Apr 20, 2022
2fc8ac3
update to add more context to warnings array output
MuluhGodson Apr 20, 2022
cb8062c
add more context to warnings array output
MuluhGodson Apr 20, 2022
ec19dd8
add more context to warnings array
MuluhGodson Apr 20, 2022
91d1937
add more context to warnings json
MuluhGodson Apr 20, 2022
e2634c6
move function definition and warning codes to worker.cc
MuluhGodson Apr 20, 2022
f7a9f4a
rewrite tests to all use one map
MuluhGodson Apr 20, 2022
f9e2834
change variable name from i to costing for looping costing methods
MuluhGodson Apr 20, 2022
67dec12
refactor test_warnings.cc to parametized gtest
MuluhGodson Apr 21, 2022
c7ab2ae
revert test cases
MuluhGodson May 2, 2022
3e0a19b
remove warnings from transit endpoint
MuluhGodson May 4, 2022
bec286e
remove warnings test for transit endpoint
MuluhGodson May 4, 2022
40e10ca
Merge remote-tracking branch 'upstream/master' into mg_warnings_array
nilsnolde Sep 21, 2022
76586e6
finish off PR
nilsnolde Sep 21, 2022
1509b97
lint & format; change some docs stuff
nilsnolde Sep 21, 2022
027d22c
untidy
nilsnolde Sep 21, 2022
6cd7d63
Merge remote-tracking branch 'upstream/master' into mg_warnings_array
nilsnolde Sep 26, 2022
524639b
Merge remote-tracking branch 'upstream/master' into mg_warnings_array
nilsnolde Sep 26, 2022
d63423f
changelog update
nilsnolde Sep 26, 2022
9b9ad42
Update src/tyr/serializers.cc
nilsnolde Oct 12, 2022
4c5a868
Apply suggestions from code review
nilsnolde Oct 12, 2022
233f923
github UI conflict resolve failed format.sh
nilsnolde Oct 12, 2022
1836a4f
Merge remote-tracking branch 'upstream/master' into mg_warnings_array
nilsnolde Oct 14, 2022
70da775
raw strings instead of escaping quotes
nilsnolde Oct 14, 2022
e6d6a35
changelog
nilsnolde Oct 14, 2022
07b1f41
typo
nilsnolde Oct 14, 2022
4aa63e2
Merge branch 'mg_warnings_array' of https://github.com/MuluhGodson/va…
nilsnolde Oct 14, 2022
75c3aea
revert gurka changes
nilsnolde Oct 14, 2022
1b3cc09
Merge remote-tracking branch 'upstream/master' into mg_warnings_array
nilsnolde Oct 14, 2022
a82eddb
changelog
nilsnolde Oct 14, 2022
145f001
wtf
nilsnolde Oct 15, 2022
e624e2f
still..
nilsnolde Oct 15, 2022
9b84b39
remove redundant include
nilsnolde Oct 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/tyr/route_serializer_valhalla.cc
Expand Up @@ -6,6 +6,7 @@
#include "odin/util.h"
#include "proto_conversions.h"
#include "tyr/serializers.h"
#include "proto/info.pb.h"

using namespace valhalla;
using namespace valhalla::midgard;
Expand Down Expand Up @@ -537,6 +538,9 @@ std::string serialize(const Api& api) {

// summary time/distance and other stats
summary(api, i, writer);

// get serialized warnings
valhalla::tyr::serializeWarnings(api, writer);

writer.end_object(); // trip

Expand Down
13 changes: 13 additions & 0 deletions src/tyr/serializers.cc
Expand Up @@ -25,6 +25,7 @@
#include "proto/incidents.pb.h"
#include "proto/options.pb.h"
#include "proto/trip.pb.h"
#include "proto/info.pb.h"

using namespace valhalla;
using namespace valhalla::baldr;
Expand Down Expand Up @@ -157,6 +158,18 @@ void openlr(const valhalla::Api& api, int route_index, rapidjson::writer_wrapper
writer.end_array();
}

void serializeWarnings(const valhalla::Api& api, rapidjson::writer_wrapper_t& writer){
MuluhGodson marked this conversation as resolved.
Show resolved Hide resolved
valhalla::Info warning;
MuluhGodson marked this conversation as resolved.
Show resolved Hide resolved
writer.start_array("warnings");
writer.start_object();
for(int i = 0; i < warning.warnings_size(); i++){
writer(std::to_string(i), warning.warnings(i).description());
}
writer("warning_count", std::to_string(warning.warnings_size()));
MuluhGodson marked this conversation as resolved.
Show resolved Hide resolved
writer.end_object();
writer.end_array();
}

std::string serializePbf(Api& request) {
// if they dont want to select the parts just pick the obvious thing they would want based on action
PbfFieldSelector selection = request.options().pbf_field_selector();
Expand Down
16 changes: 16 additions & 0 deletions src/worker.cc
Expand Up @@ -16,6 +16,7 @@
#include "sif/costfactory.h"
#include "thor/worker.h"
#include "worker.h"
#include "proto/info.pb.h"

#include <boost/property_tree/ptree.hpp>
#include <cpp-statsd-client/StatsdClient.hpp>
Expand Down Expand Up @@ -616,6 +617,11 @@ void from_json(rapidjson::Document& doc, Options::Action action, Api& api) {
// auto_shorter is deprecated and will be turned into
// shortest=true costing option. maybe remove in v4?
if (costing_str == "auto_shorter") {

// add warnign for auto shorter
valhalla::Info info;
info.add_warnings()->set_description("auto shorter is deprecated and will be turned into the shotest costing option");

costing_str = "auto";
rapidjson::SetValueByPointer(doc, "/costing", "auto");
auto json_options = rapidjson::GetValueByPointer(doc, "/costing_options/auto_shorter");
Expand All @@ -628,6 +634,11 @@ void from_json(rapidjson::Document& doc, Options::Action action, Api& api) {
// hov costing is deprecated and will be turned into auto costing with
// include_hov2=true costing option.
if (costing_str == "hov") {

// add warning for hov costing
valhalla::Info info;
info.add_warnings()->set_description("hov costing is deprecated and will be turned into auto costing with hov2=true costing option");

costing_str = "auto";
rapidjson::SetValueByPointer(doc, "/costing", "auto");
auto json_options = rapidjson::GetValueByPointer(doc, "/costing_options/hov");
Expand All @@ -640,6 +651,11 @@ void from_json(rapidjson::Document& doc, Options::Action action, Api& api) {
// auto_data_fix is deprecated and will be turned into
// ignore all the things costing option. maybe remove in v4?
if (costing_str == "auto_data_fix") {

// warning for auto data fix
valhalla::Info info;
info.add_warnings()->set_description("auto_data_fix is deprecated and will be turned to ignore all the things costing option");
MuluhGodson marked this conversation as resolved.
Show resolved Hide resolved

costing_str = "auto";
rapidjson::SetValueByPointer(doc, "/costing", "auto");
auto json_options = rapidjson::GetValueByPointer(doc, "/costing_options/auto_data_fix");
Expand Down
8 changes: 8 additions & 0 deletions valhalla/tyr/serializers.h
Expand Up @@ -16,6 +16,7 @@
#include <valhalla/meili/match_result.h>
#include <valhalla/midgard/gridded_data.h>
#include <valhalla/proto/api.pb.h>
#include <valhalla/proto/info.pb.h>
MuluhGodson marked this conversation as resolved.
Show resolved Hide resolved
#include <valhalla/thor/costmatrix.h>
#include <valhalla/tyr/actor.h>

Expand Down Expand Up @@ -117,6 +118,13 @@ void openlr(const valhalla::Api& api, int route_index, rapidjson::writer_wrapper
*/
std::string serializePbf(Api& request);

/**
* @brief Turns warnings into json
* @param request The protobuf warnings object
* @return json string
*/
void serializeWarnings(const valhalla::Api& api, rapidjson::writer_wrapper_t& writer);

} // namespace tyr
} // namespace valhalla

Expand Down