| 1086 | } |
| 1087 | |
| 1088 | inline route_parameters_ptr argumentsToRouteParameter(const Napi::CallbackInfo &args, |
| 1089 | bool requires_multiple_coordinates) |
| 1090 | { |
| 1091 | route_parameters_ptr params = std::make_unique<osrm::RouteParameters>(); |
| 1092 | bool has_base_params = argumentsToParameter(args, params, requires_multiple_coordinates); |
| 1093 | if (!has_base_params) |
| 1094 | return route_parameters_ptr(); |
| 1095 | |
| 1096 | Napi::Object obj = args[0].As<Napi::Object>(); |
| 1097 | |
| 1098 | if (obj.Has("continue_straight")) |
| 1099 | { |
| 1100 | auto value = obj.Get("continue_straight"); |
| 1101 | if (value.IsEmpty()) |
| 1102 | return route_parameters_ptr(); |
| 1103 | |
| 1104 | if (!value.IsBoolean() && !value.IsNull()) |
| 1105 | { |
| 1106 | ThrowError(args.Env(), "'continue_straight' param must be boolean or null"); |
| 1107 | return route_parameters_ptr(); |
| 1108 | } |
| 1109 | if (value.IsBoolean()) |
| 1110 | { |
| 1111 | params->continue_straight = value.ToBoolean().Value(); |
| 1112 | } |
| 1113 | } |
| 1114 | |
| 1115 | if (obj.Has("alternatives")) |
| 1116 | { |
| 1117 | auto value = obj.Get("alternatives"); |
| 1118 | if (value.IsEmpty()) |
| 1119 | return route_parameters_ptr(); |
| 1120 | |
| 1121 | if (value.IsBoolean()) |
| 1122 | { |
| 1123 | params->alternatives = value.ToBoolean().Value(); |
| 1124 | params->number_of_alternatives = value.ToBoolean().Value() ? 1u : 0u; |
| 1125 | } |
| 1126 | else if (value.IsNumber()) |
| 1127 | { |
| 1128 | params->alternatives = value.ToBoolean().Value(); |
| 1129 | params->number_of_alternatives = value.ToNumber().Int32Value(); |
| 1130 | } |
| 1131 | else |
| 1132 | { |
| 1133 | ThrowError(args.Env(), "'alternatives' param must be boolean or number"); |
| 1134 | return route_parameters_ptr(); |
| 1135 | } |
| 1136 | } |
| 1137 | |
| 1138 | if (obj.Has("waypoints")) |
| 1139 | { |
| 1140 | Napi::Value waypoints = obj.Get("waypoints"); |
| 1141 | if (waypoints.IsEmpty()) |
| 1142 | return route_parameters_ptr(); |
| 1143 | |
| 1144 | // must be array |
| 1145 | if (!waypoints.IsArray()) |
nothing calls this directly
no test coverage detected