23 #ifndef __UTILS_GRAPH_TOPOLOGICAL_MAP_EDGE_H_ 24 #define __UTILS_GRAPH_TOPOLOGICAL_MAP_EDGE_H_ 26 #include <utils/misc/string_conversions.h> 28 #include <navgraph/navgraph_node.h> 29 #include <utils/math/types.h> 47 bool directed =
false);
49 NavGraphEdge(
const std::string &from,
const std::string &to,
50 bool directed =
false);
54 const std::string &
from()
const 59 const std::string &
to()
const 66 {
return from_node_; }
74 bool intersects(
float x1,
float y1,
float x2,
float y2)
const;
75 bool intersection(
float x1,
float y1,
float x2,
float y2,
78 void set_from(
const std::string &from);
79 void set_to(
const std::string &to);
85 const std::map<std::string, std::string> &
properties()
const 86 {
return properties_; }
93 {
return properties_.find(property) != properties_.end(); }
95 void set_properties(
const std::map<std::string, std::string> &properties);
97 void set_property(
const std::string &property,
const char *value);
98 void set_property(
const std::string &property,
float value);
99 void set_property(
const std::string &property,
int value);
100 void set_property(
const std::string &property,
bool value);
128 {
return from_ !=
"" && to_ !=
""; }
134 {
return directed_; }
137 std::string
property(
const std::string &prop)
const;
167 {
return from_ == e.from_ && to_ == e.to_ && directed_ == e.directed_; }
176 {
return (from_ == e.from_ && to_ < e.to_) || (from_ < e.from_); }
184 operator bool()
const 185 {
return from_ !=
"" && to_ !=
""; }
193 std::map<std::string, std::string> properties_;
const std::string & from() const
Get edge originating node name.
void set_property(const std::string &property, const std::string &value)
Set property.
bool property_as_bool(const std::string &prop)
Get property converted to bol.
void set_nodes(const NavGraphNode &from_node, const NavGraphNode &to_node)
Set nodes.
Cartesian coordinates (2D).
Fawkes library namespace.
void set_properties(const std::map< std::string, std::string > &properties)
Overwrite properties with given ones.
bool is_directed() const
Check if edge is directed.
bool intersection(float x1, float y1, float x2, float y2, fawkes::cart_coord_2d_t &ip) const
Check if the edge intersects with another line segment.
std::string property(const std::string &prop) const
Get specified property as string.
float property_as_float(const std::string &prop)
Get property converted to float.
const NavGraphNode & from_node() const
Get edge originating node.
void set_to(const std::string &to)
Set target node name.
const std::map< std::string, std::string > & properties() const
Get all properties.
bool operator==(const NavGraphEdge &e) const
Check edges for equality.
void set_from(const std::string &from)
Set originating node name.
static int to_int(std::string s)
Convert string to an int value.
NavGraphEdge()
Constructor for an invalid edge.
int property_as_int(const std::string &prop) const
Get property converted to int.
fawkes::cart_coord_2d_t closest_point_on_edge(float x, float y) const
Get the point on edge closest to a given point.
bool property_as_bool(const std::string &prop) const
Get property converted to bol.
const std::string & to() const
Get edge target node name.
bool is_valid() const
Check if edge is valid.
bool intersects(float x1, float y1, float x2, float y2) const
Check if the edge intersects with another line segment.
void set_directed(bool directed)
Set directed state.
bool has_property(const std::string &property) const
Check if node has specified property.
float property_as_float(const std::string &prop) const
Get property converted to float.
int property_as_int(const std::string &prop)
Get property converted to int.
static float to_float(std::string s)
Convert string to a float value.
static bool to_bool(std::string s)
Convert string to a bool value.
const NavGraphNode & to_node() const
Get edge target node.
bool operator<(const NavGraphEdge &e) const
Less than operator based on node from and to names.