File: withPoints.hpp

package info (click to toggle)
pgrouting 4.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,332 kB
  • sloc: cpp: 21,315; sql: 10,419; ansic: 9,795; perl: 1,142; sh: 919; javascript: 314; xml: 182; makefile: 29
file content (103 lines) | stat: -rw-r--r-- 3,120 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*PGR-GNU*****************************************************************
File: withPoints.hpp

Copyright (c) 2007-2026 pgRouting developers
Mail: project@pgrouting.org

Function's developer:
Copyright (c) 2015 Celia Virginia Vergara Castillo
Mail:

------

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

 ********************************************************************PGR-GNU*/

#ifndef INCLUDE_WITHPOINTS_WITHPOINTS_HPP_
#define INCLUDE_WITHPOINTS_WITHPOINTS_HPP_
#pragma once

#include <vector>
#include <cstdint>

#include "cpp_common/point_on_edge_t.hpp"
#include "cpp_common/messages.hpp"
#include "cpp_common/path.hpp"

namespace pgrouting {

class Pg_points_graph : public Pgr_messages {
    struct pointCompare {
        bool operator() (
                const Point_on_edge_t& lhs,
                const Point_on_edge_t& rhs) const
        {return lhs.fraction < rhs.fraction? true : lhs.pid < rhs.pid;}
    };

 public:
     Pg_points_graph() = delete;
     Pg_points_graph(const Pg_points_graph &) = delete;
     Pg_points_graph(
             std::vector<Point_on_edge_t> p_points,
             std::vector<Edge_t>      p_edges_to_modify,
             bool p_normal,
             char p_driving_side,
             bool p_directed);

     std::vector<Point_on_edge_t> points() const;
     std::vector<Edge_t> edges_of_points() const;
     std::vector<Edge_t> new_edges() const;
     inline char driving_side() const {return m_driving_side;}


     Path eliminate_details(
             Path path) const;

     void eliminate_details_dd(
             Path &path) const;

     void adjust_pids(
             const std::vector< Point_on_edge_t > &points,
             Path &path);

     friend std::ostream& operator<<(
             std::ostream &os, const Pg_points_graph &g);

 private:
     void adjust_pids(
             const std::vector< Point_on_edge_t > &points,
             const int64_t &start_pid,
             const int64_t &end_pid,
             Path &path);

     void create_new_edges();
     void check_points();
     void reverse_sides();
     int64_t get_edge_id(int64_t pid) const;
     const Edge_t*  get_edge_data(int64_t eid) const;

 private:
     std::vector<Point_on_edge_t> m_points;
     std::vector<Point_on_edge_t> m_o_points;
     std::vector<Edge_t>      m_edges_of_points;
     std::vector<Edge_t>      m_new_edges;
     char m_driving_side;
     bool m_directed;
};

}  // namespace pgrouting

#endif  // INCLUDE_WITHPOINTS_WITHPOINTS_HPP_