@@ -176,6 +176,64 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
176176 return engine_config_ptr ();
177177 }
178178
179+ // Set EngineConfig system-wide limits on construction, if requested
180+
181+ auto max_locations_trip = params->Get (Nan::New (" max_locations_trip" ).ToLocalChecked ());
182+ auto max_locations_viaroute = params->Get (Nan::New (" max_locations_viaroute" ).ToLocalChecked ());
183+ auto max_locations_distance_table =
184+ params->Get (Nan::New (" max_locations_distance_table" ).ToLocalChecked ());
185+ auto max_locations_map_matching =
186+ params->Get (Nan::New (" max_locations_map_matching" ).ToLocalChecked ());
187+ auto max_results_nearest = params->Get (Nan::New (" max_results_nearest" ).ToLocalChecked ());
188+ auto max_alternatives = params->Get (Nan::New (" max_alternatives" ).ToLocalChecked ());
189+
190+ if (!max_locations_trip->IsUndefined () && !max_locations_trip->IsNumber ())
191+ {
192+ Nan::ThrowError (" max_locations_trip must be an integral number" );
193+ return engine_config_ptr ();
194+ }
195+ if (!max_locations_viaroute->IsUndefined () && !max_locations_viaroute->IsNumber ())
196+ {
197+ Nan::ThrowError (" max_locations_viaroute must be an integral number" );
198+ return engine_config_ptr ();
199+ }
200+ if (!max_locations_distance_table->IsUndefined () && !max_locations_distance_table->IsNumber ())
201+ {
202+ Nan::ThrowError (" max_locations_distance_table must be an integral number" );
203+ return engine_config_ptr ();
204+ }
205+ if (!max_locations_map_matching->IsUndefined () && !max_locations_map_matching->IsNumber ())
206+ {
207+ Nan::ThrowError (" max_locations_map_matching must be an integral number" );
208+ return engine_config_ptr ();
209+ }
210+ if (!max_results_nearest->IsUndefined () && !max_results_nearest->IsNumber ())
211+ {
212+ Nan::ThrowError (" max_results_nearest must be an integral number" );
213+ return engine_config_ptr ();
214+ }
215+ if (!max_alternatives->IsUndefined () && !max_alternatives->IsNumber ())
216+ {
217+ Nan::ThrowError (" max_alternatives must be an integral number" );
218+ return engine_config_ptr ();
219+ }
220+
221+ if (max_locations_trip->IsNumber ())
222+ engine_config->max_locations_trip = static_cast <int >(max_locations_trip->NumberValue ());
223+ if (max_locations_viaroute->IsNumber ())
224+ engine_config->max_locations_viaroute =
225+ static_cast <int >(max_locations_viaroute->NumberValue ());
226+ if (max_locations_distance_table->IsNumber ())
227+ engine_config->max_locations_distance_table =
228+ static_cast <int >(max_locations_distance_table->NumberValue ());
229+ if (max_locations_map_matching->IsNumber ())
230+ engine_config->max_locations_map_matching =
231+ static_cast <int >(max_locations_map_matching->NumberValue ());
232+ if (max_results_nearest->IsNumber ())
233+ engine_config->max_results_nearest = static_cast <int >(max_results_nearest->NumberValue ());
234+ if (max_alternatives->IsNumber ())
235+ engine_config->max_alternatives = static_cast <int >(max_alternatives->NumberValue ());
236+
179237 return engine_config;
180238}
181239
0 commit comments