mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 22:53:43 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
62
routing/vehicle_mask.cpp
Normal file
62
routing/vehicle_mask.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "routing/vehicle_mask.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
namespace routing
|
||||
{
|
||||
std::string DebugPrint(VehicleType vehicleType)
|
||||
{
|
||||
switch (vehicleType)
|
||||
{
|
||||
case VehicleType::Pedestrian: return "Pedestrian";
|
||||
case VehicleType::Bicycle: return "Bicycle";
|
||||
case VehicleType::Car: return "Car";
|
||||
case VehicleType::Transit: return "Transit";
|
||||
case VehicleType::Count: return "Count";
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
std::string ToString(VehicleType vehicleType) { return DebugPrint(vehicleType); }
|
||||
|
||||
void FromString(std::string_view s, VehicleType & vehicleType)
|
||||
{
|
||||
if (s == "Pedestrian")
|
||||
vehicleType = VehicleType::Pedestrian;
|
||||
else if (s == "Bicycle")
|
||||
vehicleType = VehicleType::Bicycle;
|
||||
else if (s == "Car")
|
||||
vehicleType = VehicleType::Car;
|
||||
else if (s == "Transit")
|
||||
vehicleType = VehicleType::Transit;
|
||||
else
|
||||
{
|
||||
ASSERT(false, ("Could not read VehicleType from string", s));
|
||||
vehicleType = VehicleType::Count;
|
||||
}
|
||||
}
|
||||
|
||||
std::string DebugPrint(VehicleMask vehicleMask)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "VehicleMask [";
|
||||
bool first = true;
|
||||
for (size_t i = 0; i < static_cast<size_t>(VehicleType::Count); ++i)
|
||||
{
|
||||
auto const vt = static_cast<VehicleType>(i);
|
||||
if ((vehicleMask & GetVehicleMask(vt)) == 0)
|
||||
continue;
|
||||
|
||||
if (!first)
|
||||
oss << ", ";
|
||||
first = false;
|
||||
|
||||
oss << DebugPrint(vt);
|
||||
}
|
||||
oss << "]";
|
||||
return oss.str();
|
||||
}
|
||||
} // namespace routing
|
||||
Reference in New Issue
Block a user