pgRouting
pgRouting extends the PostGIS / PostgreSQL geospatial database to provide geospatial routing functionality.
 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 #include <CGAL/Simple_cartesian.h>
30 #include <vector>
31 
32 #include "./pgr_types.h"
33 
34 
35 namespace pgrouting {
36 
37 // typedef boost::geometry::model::d2::point_xy<double> Point;
38 typedef CGAL::Simple_cartesian<double> Simple_cartasian;
39 typedef Simple_cartasian::Point_2 Point;
40 
41 
42 class XY_vertex {
43  public:
44  XY_vertex() = default;
45  XY_vertex(const XY_vertex &) = default;
46  XY_vertex(const int64_t _id, double _x, double _y) :
47  id(_id), point(_x, _y) {
48  }
49 
50  XY_vertex(const Pgr_edge_xy_t &other, bool is_source) :
51  id(is_source? other.source : other.target),
52  point(is_source? Point(other.x1, other.y1) : Point(other.x2, other.y2))
53  {}
54 
55 
56  double x() const {return point.x();}
57  double y() const {return point.y();}
58 
59  inline void cp_members(const XY_vertex &other) {
60  this->id = other.id;
61  this->point = other.point;
62  }
63 
64  friend std::ostream& operator<<(std::ostream& log, const XY_vertex &v);
65  bool operator==(const XY_vertex &rhs) const;
66 
67  public:
68  int64_t id;
70 };
71 
72 size_t
73 check_vertices(std::vector < XY_vertex > vertices);
74 
75 std::vector < XY_vertex >
77  const Pgr_edge_xy_t *data_edges, int64_t count);
78 
79 std::vector < XY_vertex >
81  const std::vector < Pgr_edge_xy_t > &data_edges);
82 
83 #if 0
84 std::vector < XY_vertex > extract_vertices(
85  std::vector < XY_vertex > vertices,
86  const Pgr_edge_xy_t *data_edges, int64_t count);
87 
88 std::vector < XY_vertex > extract_vertices(
89  std::vector < XY_vertex > vertices,
90  const std::vector < Pgr_edge_xy_t > data_edges);
91 #endif
92 
93 } // namespace pgrouting
94 
95 #endif // SRC_COMMON_SRC_XY_VERTEX_H_
float8 x
Definition: tsp.h:40
float8 y
Definition: tsp.h:41
Simple_cartasian::Point_2 Point
Definition: xy_vertex.h:39
bool operator==(const XY_vertex &rhs) const
Definition: xy_vertex.cpp:50
double y() const
Definition: xy_vertex.h:57
double x() const
Definition: xy_vertex.h:56
friend std::ostream & operator<<(std::ostream &log, const XY_vertex &v)
Definition: xy_vertex.cpp:44
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:50
void cp_members(const XY_vertex &other)
Definition: xy_vertex.h:59
CGAL::Simple_cartesian< double > Simple_cartasian
Definition: xy_vertex.h:38
XY_vertex(const int64_t _id, double _x, double _y)
Definition: xy_vertex.h:46
Definition: tsp.h:38
size_t check_vertices(std::vector< Basic_vertex > vertices)