diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index 4fb730f1c..87eca1dd6 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -1140,7 +1140,22 @@ void PostprocessElement(OsmElement * p, FeatureBuilderParams & params) // And most of this junctions are assumed to be oneway. {"junction", "circular", [&addOneway] { addOneway = true; }}, {"junction", "roundabout", [&addOneway] { addOneway = true; }}, - +// Add faux oneways as access keys don't support forward/backward modifiers +// Bicycles are not motor vehicles, so don't add oneways for them. + {"motor_vehicle:backward", "no", [&addOneway] { addOneway = true; }}, + {"vehicle:backward", "no", [&addOneway] { addOneway = true; }}, + {"motor_vehicle:forward", "no", + [&addOneway, ¶ms] { + addOneway = true; + params.SetReversedGeometry(true); + }}, + {"vehicle:forward", "no", + [&addOneway, ¶ms] { + addOneway = true; + params.SetReversedGeometry(true); + }}, + {"motor_vehicle:backward", "no", [&AddParam] { AddParam(CachedTypes::BicycleBidir); }}, + {"motor_vehicle:forward", "no", [&AddParam] { AddParam(CachedTypes::BicycleBidir); }}, {"access", "private", [&AddParam] { AddParam(CachedTypes::Private); }}, {"access", "!", [&AddParam] { AddParam(CachedTypes::Private); }}, diff --git a/routing/routing_integration_tests/route_test.cpp b/routing/routing_integration_tests/route_test.cpp index 57b3c1d22..ff5b6405b 100644 --- a/routing/routing_integration_tests/route_test.cpp +++ b/routing/routing_integration_tests/route_test.cpp @@ -1030,4 +1030,15 @@ UNIT_TEST(USA_UseDirt_WithMaxspeed) FromLatLon(42.3878106, 19.7831402), 247.139); } +// https://codeberg.org/comaps/comaps/issues/304 +UNIT_TEST(Norway_FauxOneway_MotorVehicleBackward_No) +{ + CalculateRouteAndTestRouteLength(GetVehicleComponents(VehicleType::Car), + FromLatLon(59.919189, 10.759355), {0., 0.}, + FromLatLon(59.921042, 10.759302), 410); + CalculateRouteAndTestRouteLength(GetVehicleComponents(VehicleType::Bicycle), + FromLatLon(59.919189, 10.759355), {0., 0.}, + FromLatLon(59.921042, 10.759302), 210); +} + } // namespace route_test