NIImporter_OpenStreetMap::SubstituteNode Class Reference

Inheritance diagram for NIImporter_OpenStreetMap::SubstituteNode:

unary_function

Detailed Description

A functor to substitute a node in the node list of an Edge.

Definition at line 99 of file NIImporter_OpenStreetMap.cpp.


Public Member Functions

void operator() (const std::pair< std::string, Edge * > &p) const
 Substitutes the nodes in the edge of the given pair.
 SubstituteNode (const NIOSMNode *const toSubstitute, const NIOSMNode *const substituteWith)
 Initializes the functor with the node to substitute and the node with that the node in the first argument is substituted.

Private Attributes

const NIOSMNode *const *const mySubstituteWith
const NIOSMNode *const myToSubstitute

Constructor & Destructor Documentation

NIImporter_OpenStreetMap::SubstituteNode::SubstituteNode ( const NIOSMNode *const   toSubstitute,
const NIOSMNode *const   substituteWith 
) [inline]

Initializes the functor with the node to substitute and the node with that the node in the first argument is substituted.

Parameters:
[in] toSubstitute Every occurrence of this node should substituted
[in] substituteWith This node is overwrites the occurrences of toSubstitute

Definition at line 111 of file NIImporter_OpenStreetMap.cpp.

00112                                                           :
00113             myToSubstitute(toSubstitute), mySubstituteWith(substituteWith) {
00114     }


Member Function Documentation

void NIImporter_OpenStreetMap::SubstituteNode::operator() ( const std::pair< std::string, Edge * > &  p  )  const [inline]

Substitutes the nodes in the edge of the given pair.

In the node list, all occurrences of toSubstitute are substituted with substituteWith. The final list has no equal adjacent nodes.

Parameters:
[in] p A pair with the edge in which the nodes are substituted

Definition at line 123 of file NIImporter_OpenStreetMap.cpp.

References NIImporter_OpenStreetMap::NIOSMNode::id, mySubstituteWith, and myToSubstitute.

00123                                                               {
00124         std::vector<int>& edgeNodes = p.second->myCurrentNodes;
00125         // Substitute nodes
00126         std::replace_if(edgeNodes.begin(), edgeNodes.end(), std::bind2nd(
00127                             std::equal_to<int>(), myToSubstitute->id), mySubstituteWith->id);
00128 
00129         // Remove adjacent duplicates
00130         std::vector<int>::iterator newEnd = std::unique(edgeNodes.begin(),
00131                                             edgeNodes.end());
00132         edgeNodes.erase(newEnd, edgeNodes.end());
00133     }


Field Documentation

Definition at line 136 of file NIImporter_OpenStreetMap.cpp.

Referenced by operator()().

Definition at line 136 of file NIImporter_OpenStreetMap.cpp.

Referenced by operator()().


The documentation for this class was generated from the following file:

Generated on Wed May 5 00:06:52 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6