Skip to content

Commit 2d5bfe7

Browse files
fix ci
1 parent 0757d9f commit 2d5bfe7

File tree

4 files changed

+41
-33
lines changed

4 files changed

+41
-33
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Unreleased
22
- Changes from 5.27.1
33
- Features
4-
- ADDED: Add generic support for obstacles [#9999](https://github.com/Project-OSRM/osrm-backend/pull/9999)
54
- ADDED: Route pedestrians over highway=platform [#6993](https://github.com/Project-OSRM/osrm-backend/pull/6993)
65
- REMOVED: Remove all core-CH left-overs [#6920](https://github.com/Project-OSRM/osrm-backend/pull/6920)
76
- ADDED: Add support for a keepalive_timeout flag. [#6674](https://github.com/Project-OSRM/osrm-backend/pull/6674)

include/extractor/obstacles.hpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct Obstacle
5858
// clang-format off
5959

6060
// The type of an obstacle
61+
// Note: must be kept in sync with scripting_environment_lua.cpp
6162
enum class Type : uint16_t
6263
{
6364
None = 0x0000,
@@ -77,22 +78,8 @@ struct Obstacle
7778
All = 0xFFFF
7879
};
7980

80-
// Initializer for enum made available to Lua through Sol. Must be kept in sync with the enum above.
81-
static constexpr std::initializer_list<std::pair<std::string_view, Obstacle::Type>> SolTypeInitializerList {
82-
{"none", Type::None},
83-
{"barrier", Type::Barrier},
84-
{"traffic_signals", Type::TrafficSignals},
85-
{"stop", Type::Stop},
86-
{"stop_minor", Type::StopMinor},
87-
{"give_way", Type::GiveWay},
88-
{"crossing", Type::Crossing},
89-
{"traffic_calming", Type::TrafficCalming},
90-
{"mini_roundabout", Type::MiniRoundabout},
91-
{"turning_loop", Type::TurningLoop},
92-
{"turning_circle", Type::TurningCircle}
93-
};
94-
9581
// The directions in which an obstacle applies.
82+
// Note: must be kept in sync with scripting_environment_lua.cpp
9683
enum class Direction : uint8_t
9784
{
9885
None = 0x0,
@@ -101,14 +88,6 @@ struct Obstacle
10188
Both = 0x3
10289
};
10390

104-
// Initializer for enum made available to Lua through Sol. Must be kept in sync with the enum above.
105-
static constexpr std::initializer_list<std::pair<std::string_view, Obstacle::Direction>> SolDirectionInitializerList {
106-
{"none", Direction::None},
107-
{"forward", Direction::Forward},
108-
{"backward", Direction::Backward},
109-
{"both", Direction::Both}
110-
};
111-
11291
// clang-format on
11392

11493
// use overloading instead of default arguments for sol::constructors
@@ -143,7 +122,7 @@ class ObstacleMap
143122
using FromToObstacle = std::tuple<NodeID, NodeID, Obstacle>;
144123

145124
public:
146-
ObstacleMap(){};
125+
ObstacleMap() {};
147126

148127
// Insert an obstacle using the OSM node id.
149128
//

src/extractor/extractor_callbacks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containe
5858
*/
5959
void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node, const ExtractionNode &)
6060
{
61-
const auto id = static_cast<OSMNodeID>(input_node.id());
61+
const auto id = to_alias<OSMNodeID>(input_node.id());
6262
external_memory.all_nodes_list.push_back(
6363
QueryNode{util::toFixed(util::UnsafeFloatLongitude{input_node.location().lon()}),
6464
util::toFixed(util::UnsafeFloatLatitude{input_node.location().lat()}),

src/extractor/scripting_environment_lua.cpp

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,39 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
311311
"direction_reverse",
312312
Obstacle::Direction::Backward);
313313

314-
context.state.new_enum<Obstacle::Type>("obstacle_type", Obstacle::SolTypeInitializerList);
315-
context.state.new_enum<Obstacle::Direction>("obstacle_direction",
316-
Obstacle::SolDirectionInitializerList);
314+
context.state.new_enum("obstacle_type",
315+
"none",
316+
Obstacle::Type::None,
317+
"barrier",
318+
Obstacle::Type::Barrier,
319+
"traffic_signals",
320+
Obstacle::Type::TrafficSignals,
321+
"stop",
322+
Obstacle::Type::Stop,
323+
"stop_minor",
324+
Obstacle::Type::StopMinor,
325+
"give_way",
326+
Obstacle::Type::GiveWay,
327+
"crossing",
328+
Obstacle::Type::Crossing,
329+
"traffic_calming",
330+
Obstacle::Type::TrafficCalming,
331+
"mini_roundabout",
332+
Obstacle::Type::MiniRoundabout,
333+
"turning_loop",
334+
Obstacle::Type::TurningLoop,
335+
"turning_circle",
336+
Obstacle::Type::TurningCircle);
337+
338+
context.state.new_enum("obstacle_direction",
339+
"none",
340+
Obstacle::Direction::None,
341+
"forward",
342+
Obstacle::Direction::Forward,
343+
"backward",
344+
Obstacle::Direction::Backward,
345+
"both",
346+
Obstacle::Direction::Both);
317347

318348
context.state.new_usertype<Obstacle>(
319349
"Obstacle",
@@ -334,7 +364,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
334364
"add",
335365
[](ObstacleMap &obstacles, const osmium::Node &from, Obstacle obstacle)
336366
{
337-
OSMNodeID id = static_cast<OSMNodeID>(from.id());
367+
OSMNodeID id = to_alias<OSMNodeID>(from.id());
338368
obstacles.emplace(id, obstacle);
339369
},
340370
"get",
@@ -362,7 +392,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
362392
if (obj.is<Obstacle::Direction>())
363393
{
364394
m_obstacle_map.emplace(
365-
static_cast<OSMNodeID>(node.node->id()),
395+
to_alias<OSMNodeID>(node.node->id()),
366396
Obstacle{Obstacle::Type::TrafficSignals,
367397
obj.as<Obstacle::Direction>(),
368398
static_cast<float>(context.properties.GetTrafficSignalPenalty()),
@@ -375,7 +405,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
375405
// state to the node
376406
// TODO: Make a breaking API change and remove this option.
377407
m_obstacle_map.emplace(
378-
static_cast<OSMNodeID>(node.node->id()),
408+
to_alias<OSMNodeID>(node.node->id()),
379409
Obstacle{Obstacle::Type::TrafficSignals,
380410
Obstacle::Direction::Both,
381411
static_cast<float>(context.properties.GetTrafficSignalPenalty()),
@@ -390,7 +420,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
390420
if (obj.is<bool>() && obj.as<bool>())
391421
{
392422
m_obstacle_map.emplace(
393-
static_cast<OSMNodeID>(node.node->id()),
423+
to_alias<OSMNodeID>(node.node->id()),
394424
Obstacle{Obstacle::Type::Barrier, Obstacle::Direction::Both});
395425
}
396426
}));

0 commit comments

Comments
 (0)