SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // ------------------- 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This file is part of SUMO. 00014 // SUMO is free software: you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation, either version 3 of the License, or 00017 // (at your option) any later version. 00018 // 00019 /****************************************************************************/ 00020 00021 00022 // =========================================================================== 00023 // included modules 00024 // =========================================================================== 00025 #ifdef _MSC_VER 00026 #include <windows_config.h> 00027 #else 00028 #include <config.h> 00029 #endif 00030 00031 00032 #include <map> 00033 #include "NIVissimEdgePosMap.h" 00034 00035 #ifdef CHECK_MEMORY_LEAKS 00036 #include <foreign/nvwa/debug_new.h> 00037 #endif // CHECK_MEMORY_LEAKS 00038 00039 00040 NIVissimEdgePosMap::NIVissimEdgePosMap() {} 00041 00042 00043 NIVissimEdgePosMap::~NIVissimEdgePosMap() {} 00044 00045 00046 void 00047 NIVissimEdgePosMap::add(int edgeid, SUMOReal pos) { 00048 add(edgeid, pos, pos); 00049 } 00050 00051 00052 void 00053 NIVissimEdgePosMap::add(int edgeid, SUMOReal from, SUMOReal to) { 00054 if (from > to) { 00055 SUMOReal tmp = from; 00056 from = to; 00057 to = tmp; 00058 } 00059 ContType::iterator i = myCont.find(edgeid); 00060 if (i == myCont.end()) { 00061 myCont[edgeid] = Range(from, to); 00062 } else { 00063 SUMOReal pfrom = (*i).second.first; 00064 SUMOReal pto = (*i).second.second; 00065 if (pfrom < from) { 00066 from = pfrom; 00067 } 00068 if (pto > to) { 00069 to = pto; 00070 } 00071 myCont[edgeid] = Range(from, to); 00072 } 00073 } 00074 00075 00076 void 00077 NIVissimEdgePosMap::join(NIVissimEdgePosMap& with) { 00078 for (ContType::iterator i = with.myCont.begin(); i != with.myCont.end(); i++) { 00079 add((*i).first, (*i).second.first, (*i).second.second); 00080 } 00081 } 00082 00083 00084 00085 /****************************************************************************/ 00086