PGROUTING  2.6-dev
pgrouting::vrp::Node Class Reference

The Node class defines a point in 2D space with an id. More...

#include "node.h"

Inheritance diagram for pgrouting::vrp::Node:
Collaboration diagram for pgrouting::vrp::Node:

Public Member Functions

 Node ()=default
 
 Node (size_t id, int64_t original_id, double _x, double _y)
 
double distance (const Base_node *) const
 Calculates distance between two Node. More...
 
int64_t id () const
 
size_t idx () const
 
void reset_id (int64_t)
 
to be or not to be
bool operator== (const Node &rhs) const
 
to be or not to be
virtual bool operator== (const Base_node &rhs) const
 

Private Member Functions

double distance (const Node &) const
 
void print (std::ostream &os) const
 

Private Attributes

pgrouting::Point m_point
 

Friends

std::ostream & operator<< (std::ostream &log, const Node &node)
 

Detailed Description

The Node class defines a point in 2D space with an id.

A Node is a point that defines a location in 2D space. It maintains a user id and an internal nid along with its x, y location. This is the base object that things like depots, customer locations, etc. are built upon.

Definition at line 50 of file node.h.

Constructor & Destructor Documentation

pgrouting::vrp::Node::Node ( )
default
pgrouting::vrp::Node::Node ( size_t  _idx,
int64_t  _id,
double  _x,
double  _y 
)
Parameters
[in]_idxindex to a container
[in]_idoriginal identifier
[in]_xcoordinate value
[in]_ycoordinate value

Definition at line 68 of file node.cpp.

69  : Base_node(_idx, _id),
70  m_point(_x, _y) {
71  }
pgrouting::Point m_point
Definition: node.h:71

Member Function Documentation

double pgrouting::vrp::Node::distance ( const Base_node n) const
virtual

Calculates distance between two Node.

para[in] n bas node to be casted as Node

Implements pgrouting::vrp::Base_node.

Definition at line 58 of file node.cpp.

58  {
59  return distance(*dynamic_cast<const Node*>(n));
60 }
double distance(const Base_node *) const
Calculates distance between two Node.
Definition: node.cpp:58
double pgrouting::vrp::Node::distance ( const Node other) const
private

Definition at line 48 of file node.cpp.

References m_point.

48  {
49  auto dx = m_point.x() - other.m_point.x();
50  auto dy = m_point.y() - other.m_point.y();
51  return sqrt(dx * dx + dy * dy);
52 }
pgrouting::Point m_point
Definition: node.h:71
bool pgrouting::vrp::Base_node::operator== ( const Base_node rhs) const
virtualinherited

Definition at line 48 of file base_node.cpp.

References pgrouting::Identifier::id(), and pgrouting::Identifier::idx().

48  {
49  if (&rhs == this) return true;
50  return
51  (idx() == rhs.idx())
52  && (id() == rhs.id());
53 }
size_t idx() const
Definition: identifier.cpp:37

Here is the call graph for this function:

bool pgrouting::vrp::Node::operator== ( const Node rhs) const

Definition at line 74 of file node.cpp.

References pgrouting::Identifier::id(), pgrouting::Identifier::idx(), and m_point.

74  {
75  if (&rhs == this) return true;
76  return
77  (idx() == rhs.idx())
78  && (id() == rhs.id())
79  && (m_point == rhs.m_point);
80 }
pgrouting::Point m_point
Definition: node.h:71
size_t idx() const
Definition: identifier.cpp:37

Here is the call graph for this function:

void pgrouting::vrp::Node::print ( std::ostream &  os) const
privatevirtual

Reimplemented from pgrouting::vrp::Base_node.

Definition at line 39 of file node.cpp.

References pgrouting::Identifier::id(), pgrouting::Identifier::idx(), and m_point.

Referenced by pgrouting::vrp::operator<<().

39  {
40  os << id()
41 #ifndef NDEBUG
42  << "(" << idx() << ")"
43 #endif
44  << " (x,y) = (" << m_point.x() << ", " << m_point.y() << ")";
45 }
int64_t id() const
Definition: identifier.cpp:42
pgrouting::Point m_point
Definition: node.h:71
size_t idx() const
Definition: identifier.cpp:37

Here is the call graph for this function:

Here is the caller graph for this function:

void pgrouting::Identifier::reset_id ( int64_t  _id)
inherited

Definition at line 47 of file identifier.cpp.

References pgrouting::Identifier::m_id.

Referenced by pgrouting::vrp::Tw_node::Tw_node().

47  {
48  m_id = _id;
49 }

Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  log,
const Node node 
)
friend

Definition at line 33 of file node.cpp.

33  {
34  node.print(log);
35  return log;
36 }

Member Data Documentation

pgrouting::Point pgrouting::vrp::Node::m_point
private

Definition at line 71 of file node.h.

Referenced by distance(), operator==(), and print().


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