26 bool ProjValue(
const std::string &proj,
const std::string &key,
double &out) {
27 const std::string needle =
"+" + key +
"=";
28 const auto start = proj.find(needle);
29 if (start == std::string::npos) {
33 out = std::stod(proj.substr(start + needle.size()));
34 }
catch (
const std::exception &) {
44 "Osm2Odr: traffic light exclusions have no effect while traffic light generation is off.");
48 "Osm2Odr: osm_highways_types is not honoured yet; the converter's own drivable set "
56 WarnAboutUnsupported(settings);
64 double origin_lat = 0.0;
65 double origin_lon = 0.0;
66 const bool pinned = ProjValue(settings.
proj_string,
"lat_0", origin_lat) &&
67 ProjValue(settings.
proj_string,
"lon_0", origin_lon);
70 origin_lat = (extent.
south + extent.
north) * 0.5;
71 origin_lon = (extent.
west + extent.
east) * 0.5;
75 origin_lat = extent.
north;
76 origin_lon = extent.
west;
84 if (osm.
bbox.has_value()) {
85 double x0 = 0.0, y0 = 0.0, x1 = 0.0, y1 = 0.0;
94 if (model.
roads.empty()) {
95 throw std::runtime_error(
96 "Osm2Odr: the OSM data holds no drivable way, nothing to convert.");
std::map< std::string, unsigned int > road
WGS84 <-> local ENU metres, a transverse Mercator centred on the origin.
void ToLocal(double lon, double lat, double &x, double &y) const
static void log_warning(Args &&... args)
std::string ConvertOSMToOpenDRIVE(std::string osm_file, OSM2ODRSettings settings)
bg::model::d2::point_xy< double > Point
bg::model::box< Point > Box
std::string ExportXodr(const TwinModelData &model, const LocalFrame &frame)
Serialise the model as an OpenDRIVE 1.6 document.
OsmData ParseOsmXml(const std::string &xml)
Parse an OpenStreetMap XML document.
void BuildSignals(const OsmData &osm, const LocalFrame &frame, TwinModelData &model, const SignalOptions &options)
Read traffic lights, stop and give-way signs, speed limits and crossings out of the OSM tags and atta...
TwinModelData BuildLaneGraph(const OsmData &osm, const LocalFrame &frame, const std::string &name, const LaneGraphOptions &options)
OSM ways -> roads, lanes and junctions in model space.
std::vector< std::string > osm_highways_types
bool all_junctions_traffic_lights
double default_lane_width
double default_sidewalk_width
bool generate_traffic_lights
std::vector< std::string > tl_excluded_highways_types
std::optional< geom::Box > clip
Clip the network to this box in model metres, as the Python pipeline clips to the requested bbox.
bool all_junctions_traffic_lights
bool generate_traffic_lights
One lane of a road, numbered outward from the reference line.
BoundingBox NodeExtent() const
Extent of the nodes themselves, used when the file carries no <bounds> or the bounds are smaller than...
std::optional< BoundingBox > bbox
bool generate_traffic_lights
bool all_junctions_traffic_lights
Everything the OpenDRIVE writer reads.
std::vector< Road > roads