osrm-backend/include/extractor/extraction_way.hpp

103 lines
2.9 KiB
C++
Raw Normal View History

#ifndef EXTRACTION_WAY_HPP
#define EXTRACTION_WAY_HPP
2016-01-02 11:13:44 -05:00
#include "extractor/travel_mode.hpp"
#include "util/typedefs.hpp"
#include <string>
#include <vector>
2015-04-08 12:53:10 -04:00
/**
* This struct is the direct result of the call to ```way_function```
* in the lua based profile.
*
* It is split into multiple edge segments in the ExtractorCallback.
*/
2014-05-09 10:17:31 -04:00
struct ExtractionWay
{
2014-11-19 04:53:28 -05:00
ExtractionWay() { clear(); }
2014-11-19 04:53:28 -05:00
void clear()
2014-05-09 10:17:31 -04:00
{
2014-08-18 09:38:07 -04:00
forward_speed = -1;
backward_speed = -1;
duration = -1;
roundabout = false;
is_startpoint = true;
2014-08-26 11:02:05 -04:00
is_access_restricted = false;
name.clear();
forward_travel_mode = TRAVEL_MODE_DEFAULT;
backward_travel_mode = TRAVEL_MODE_DEFAULT;
}
2014-05-09 10:17:31 -04:00
enum Directions
2015-01-22 06:19:11 -05:00
{
notSure = 0,
oneway,
bidirectional,
opposite
};
2014-08-26 11:02:05 -04:00
2014-08-20 05:37:47 -04:00
// These accessor methods exists to support the depreciated "way.direction" access
2014-08-26 11:02:05 -04:00
// in LUA. Since the direction attribute was removed from ExtractionWay, the
2014-08-20 05:37:47 -04:00
// accessors translate to/from the mode attributes.
void set_direction(const Directions m)
{
2014-08-19 10:38:53 -04:00
if (Directions::oneway == m)
{
2014-08-18 09:38:07 -04:00
forward_travel_mode = TRAVEL_MODE_DEFAULT;
backward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
}
2014-08-19 10:38:53 -04:00
else if (Directions::opposite == m)
{
2015-01-22 06:19:11 -05:00
forward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
backward_travel_mode = TRAVEL_MODE_DEFAULT;
}
2014-08-19 10:38:53 -04:00
else if (Directions::bidirectional == m)
{
2015-01-22 06:19:11 -05:00
forward_travel_mode = TRAVEL_MODE_DEFAULT;
backward_travel_mode = TRAVEL_MODE_DEFAULT;
}
}
Directions get_direction() const
{
2015-01-22 06:19:11 -05:00
if (TRAVEL_MODE_INACCESSIBLE != forward_travel_mode &&
TRAVEL_MODE_INACCESSIBLE != backward_travel_mode)
{
return Directions::bidirectional;
}
2014-08-19 10:38:53 -04:00
else if (TRAVEL_MODE_INACCESSIBLE != forward_travel_mode)
{
return Directions::oneway;
}
2014-08-19 10:38:53 -04:00
else if (TRAVEL_MODE_INACCESSIBLE != backward_travel_mode)
{
return Directions::opposite;
}
else
{
return Directions::notSure;
}
}
2014-08-20 05:37:47 -04:00
// These accessors exists because it's not possible to take the address of a bitfield,
// and LUA therefore cannot read/write the mode attributes directly.
void set_forward_mode(const TravelMode m) { forward_travel_mode = m; }
TravelMode get_forward_mode() const { return forward_travel_mode; }
void set_backward_mode(const TravelMode m) { backward_travel_mode = m; }
TravelMode get_backward_mode() const { return backward_travel_mode; }
2014-08-11 08:07:00 -04:00
2014-08-18 09:38:07 -04:00
double forward_speed;
double backward_speed;
double duration;
std::string name;
bool roundabout;
2014-08-26 11:02:05 -04:00
bool is_access_restricted;
bool is_startpoint;
2014-08-18 09:38:07 -04:00
TravelMode forward_travel_mode : 4;
2014-08-11 08:07:00 -04:00
TravelMode backward_travel_mode : 4;
};
#endif // EXTRACTION_WAY_HPP