|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Sets and checks options for netwrite 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 00020 00021 // =========================================================================== 00022 // included modules 00023 // =========================================================================== 00024 #ifdef _MSC_VER 00025 #include <windows_config.h> 00026 #else 00027 #include <config.h> 00028 #endif 00029 00030 #include <string> 00031 #include <utils/options/Option.h> 00032 #include <utils/options/OptionsCont.h> 00033 #include <utils/common/MsgHandler.h> 00034 #include <utils/common/SystemFrame.h> 00035 #include <utils/iodevices/OutputDevice.h> 00036 #include <netbuild/NBNetBuilder.h> 00037 #include "NWFrame.h" 00038 #include "NWWriter_SUMO.h" 00039 #include "NWWriter_MATSim.h" 00040 #include "NWWriter_XML.h" 00041 #include "NWWriter_OpenDrive.h" 00042 00043 #ifdef CHECK_MEMORY_LEAKS 00044 #include <foreign/nvwa/debug_new.h> 00045 #endif // CHECK_MEMORY_LEAKS 00046 00047 00048 // =========================================================================== 00049 // method definitions 00050 // =========================================================================== 00051 void 00052 NWFrame::fillOptions() { 00053 OptionsCont& oc = OptionsCont::getOptions(); 00054 // register options 00055 oc.doRegister("output-file", 'o', new Option_FileName()); 00056 oc.addSynonyme("output-file", "sumo-output"); 00057 oc.addSynonyme("output-file", "output"); 00058 oc.addDescription("output-file", "Output", "The generated net will be written to FILE"); 00059 00060 oc.doRegister("plain-output-prefix", new Option_FileName()); 00061 oc.addSynonyme("plain-output-prefix", "plain-output"); 00062 oc.addDescription("plain-output-prefix", "Output", "Prefix of files to write plain xml nodes, edges and connections to"); 00063 00064 oc.doRegister("map-output", 'M', new Option_FileName()); 00065 oc.addDescription("map-output", "Output", "Writes joined edges information to FILE"); 00066 00067 oc.doRegister("matsim-output", new Option_FileName()); 00068 oc.addDescription("matsim-output", "Output", "The generated net will be written to FILE using MATsim format."); 00069 00070 oc.doRegister("opendrive-output", new Option_FileName()); 00071 oc.addDescription("opendrive-output", "Output", "The generated net will be written to FILE using openDRIVE format."); 00072 00073 oc.doRegister("output.street-names", new Option_Bool(false)); 00074 oc.addDescription("output.street-names", "Output", "Street names will be included in the output (if available)."); 00075 } 00076 00077 00078 bool 00079 NWFrame::checkOptions() { 00080 OptionsCont& oc = OptionsCont::getOptions(); 00081 bool ok = true; 00082 // check whether the output is valid and can be build 00083 if (!oc.isSet("output-file")&&!oc.isSet("plain-output-prefix")&&!oc.isSet("matsim-output")) { 00084 oc.set("output-file", "net.net.xml"); 00085 } 00086 return ok; 00087 } 00088 00089 00090 void 00091 NWFrame::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) { 00092 NWWriter_SUMO::writeNetwork(oc, nb); 00093 NWWriter_MATSim::writeNetwork(oc, nb); 00094 NWWriter_OpenDrive::writeNetwork(oc, nb); 00095 NWWriter_XML::writeNetwork(oc, nb); 00096 // save the mapping information when wished 00097 if (oc.isSet("map-output")) { 00098 OutputDevice& mdevice = OutputDevice::getDevice(oc.getString("map-output")); 00099 mdevice << nb.getJoinedEdgesMap(); 00100 mdevice.close(); 00101 } 00102 } 00103 00104 00105 void 00106 NWFrame::writePositionLong(const Position& pos, OutputDevice& dev) { 00107 dev.writeAttr(SUMO_ATTR_X, pos.x()); 00108 dev.writeAttr(SUMO_ATTR_Y, pos.y()); 00109 if (pos.z() != 0) { 00110 dev.writeAttr(SUMO_ATTR_Z, pos.z()); 00111 } 00112 } 00113 00114 /****************************************************************************/ 00115