PGROUTING  2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 #ifdef Max
32 #undef Max
33 #endif
34 #ifdef Min
35 #undef Min
36 #endif
37 
38 #include <CGAL/Simple_cartesian.h>
39 #include <vector>
40 
41 #include "c_types/pgr_edge_xy_t.h"
42 
43 
44 namespace pgrouting {
45 
46 // typedef boost::geometry::model::d2::point_xy<double> Point;
47 typedef CGAL::Simple_cartesian<double> Simple_cartasian;
48 typedef Simple_cartasian::Point_2 Point;
49 
50 
51 class XY_vertex {
52  public:
53  XY_vertex() = default;
54  XY_vertex(const XY_vertex &) = default;
55  XY_vertex(const int64_t _id, double _x, double _y) :
56  id(_id), point(_x, _y) {
57  }
58 
59  XY_vertex(const Pgr_edge_xy_t &other, bool is_source) :
60  id(is_source? other.source : other.target),
61  point(is_source? Point(other.x1, other.y1) : Point(other.x2, other.y2))
62  {}
63 
64 
65  double x() const {return point.x();}
66  double y() const {return point.y();}
67 
68  inline void cp_members(const XY_vertex &other) {
69  this->id = other.id;
70  this->point = other.point;
71  }
72 
73  friend std::ostream& operator<<(std::ostream& log, const XY_vertex &v);
74  bool operator==(const XY_vertex &rhs) const;
75 
76  public:
77  int64_t id;
79 };
80 
81 size_t
82 check_vertices(std::vector < XY_vertex > vertices);
83 
84 std::vector < XY_vertex >
86  const Pgr_edge_xy_t *data_edges, int64_t count);
87 
88 std::vector < XY_vertex >
90  const std::vector < Pgr_edge_xy_t > &data_edges);
91 
92 #if 0
93 std::vector < XY_vertex > extract_vertices(
94  std::vector < XY_vertex > vertices,
95  const Pgr_edge_xy_t *data_edges, int64_t count);
96 
97 std::vector < XY_vertex > extract_vertices(
98  std::vector < XY_vertex > vertices,
99  const std::vector < Pgr_edge_xy_t > data_edges);
100 #endif
101 
102 } // namespace pgrouting
103 
104 #endif // INCLUDE_CPP_COMMON_XY_VERTEX_H_
Simple_cartasian::Point_2 Point
Definition: xy_vertex.h:48
bool operator==(const XY_vertex &rhs) const
Definition: xy_vertex.cpp:42
double y() const
Definition: xy_vertex.h:66
double x() const
Definition: xy_vertex.h:65
friend std::ostream & operator<<(std::ostream &log, const XY_vertex &v)
Definition: xy_vertex.cpp:36
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:59
void cp_members(const XY_vertex &other)
Definition: xy_vertex.h:68
CGAL::Simple_cartesian< double > Simple_cartasian
Definition: xy_vertex.h:47
XY_vertex(const int64_t _id, double _x, double _y)
Definition: xy_vertex.h:55
size_t check_vertices(std::vector< Basic_vertex > vertices)