PGROUTING  3.1
xy_vertex.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2  *
3 
4  Copyright (c) 2015 Celia Virginia Vergara Castillo
5  vicky_vergara@hotmail.com
6 
7  ------
8 
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 
23  ********************************************************************PGR-GNU*/
24 
27 #ifndef INCLUDE_CPP_COMMON_XY_VERTEX_H_
28 #define INCLUDE_CPP_COMMON_XY_VERTEX_H_
29 #pragma once
30 
31 
32 #include <vector>
33 
34 #include "cpp_common/bpoint.hpp"
35 #include "c_types/pgr_edge_xy_t.h"
36 
37 
38 namespace pgrouting {
39 
40 class XY_vertex {
41  public:
42  XY_vertex() = default;
43  XY_vertex(const XY_vertex &) = default;
44  XY_vertex(const int64_t _id, double _x, double _y) :
45  id(_id), point(_x, _y) {
46  }
47 
48  XY_vertex(const Pgr_edge_xy_t &other, bool is_source) :
49  id(is_source? other.source : other.target),
50  point(is_source? Bpoint(other.x1, other.y1) : Bpoint(other.x2, other.y2))
51  {}
52 
53 
54  double x() const {return point.x();}
55  double y() const {return point.y();}
56 
57  inline void cp_members(const XY_vertex &other) {
58  this->id = other.id;
59  this->point = other.point;
60  }
61 
62  friend std::ostream& operator<<(std::ostream& log, const XY_vertex &v);
63  bool operator==(const XY_vertex &rhs) const;
64 
65  public:
66  int64_t id;
68 };
69 
70 size_t
71 check_vertices(std::vector < XY_vertex > vertices);
72 
73 std::vector < XY_vertex >
75  const Pgr_edge_xy_t *data_edges, size_t count);
76 
77 std::vector < XY_vertex >
79  const std::vector < Pgr_edge_xy_t > &data_edges);
80 
81 #if 0
82 std::vector < XY_vertex > extract_vertices(
83  std::vector < XY_vertex > vertices,
84  const Pgr_edge_xy_t *data_edges, int64_t count);
85 
86 std::vector < XY_vertex > extract_vertices(
87  std::vector < XY_vertex > vertices,
88  const std::vector < Pgr_edge_xy_t > data_edges);
89 #endif
90 
91 } // namespace pgrouting
92 
93 #endif // INCLUDE_CPP_COMMON_XY_VERTEX_H_
double x() const
Definition: xy_vertex.h:54
bool operator==(const XY_vertex &rhs) const
Definition: xy_vertex.cpp:61
bg::model::d2::point_xy< double > Bpoint
Definition: bline.hpp:48
friend std::ostream & operator<<(std::ostream &log, const XY_vertex &v)
Definition: xy_vertex.cpp:55
std::vector< Basic_vertex > extract_vertices(std::vector< Basic_vertex > vertices, const std::vector< pgr_edge_t > data_edges)
XY_vertex(const Pgr_edge_xy_t &other, bool is_source)
Definition: xy_vertex.h:48
void cp_members(const XY_vertex &other)
Definition: xy_vertex.h:57
XY_vertex(const int64_t _id, double _x, double _y)
Definition: xy_vertex.h:44
Book keeping class for swapping orders between vehicles.
double y() const
Definition: xy_vertex.h:55
size_t check_vertices(std::vector< Basic_vertex > vertices)