Eclipse SUMO - Simulation of Urban MObility
testlibsumo_main.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Testing libsumo for C++
19 /****************************************************************************/
20 #ifdef _MSC_VER
21 // Avoid some noisy warnings with Visual Studio
22 #pragma warning(disable:4820 4514 5045 4710 4668)
23 #endif
24 
25 #include <iostream>
26 #include <libsumo/libsumo.h>
27 
28 
29 // ===========================================================================
30 // main function
31 // ===========================================================================
32 int
33 main(int argc, char** argv) {
34  std::vector<std::string> options;
35  for (int i = 1; i < argc; i++) {
36  options.push_back(argv[i]);
37  }
38  libsumo::Simulation::load(options);
39  std::cout << "Simulation loaded\n";
40  if (options.size() == 0 || (options[0] != "sumo" && options[0] != "sumo-gui")) {
41  options.insert(options.begin(), "sumo");
42  }
43  libsumo::Simulation::start(options);
44  std::cout << "Simulation started\n";
45  libsumo::Simulation::close();
46  /*
47  std::vector<libsumo::TraCIStage> result = libsumo::Simulation::findIntermodalRoute("64455492", "-22913705", "public", 21600, 3, -1, -1, 0, 0,0,"ped");
48  double cost = 0;
49  double time = 0;
50  for (const auto& stage : result)
51  {
52  std::cout << " type=" << stage.type << " line=" << stage.line << " travelTime=" << stage.travelTime << " cost=" << stage.cost << " destination: "<< stage.destStop<<"\n";
53  std::cout << "Descr:\n" << stage.description<< std::endl<<std::endl;
54  cost += stage.cost;
55  time += stage.travelTime;
56  }
57  std::cout<<"end cost: "<<cost<<std::endl;
58  std::cout<<"end time: "<<time<<std::endl;
59  */
60 }
61 
62 
63 /****************************************************************************/
int main(int argc, char **argv)