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