Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix speed field #58

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
check speed unit
jiawlu committed Aug 16, 2024

Verified

This commit was signed with the committer’s verified signature.
CraftSpider Rune Tynan
commit 0801f2162ba01816fc06ce0dbe9d08f353ff1607
11 changes: 6 additions & 5 deletions dev/osm2gmns_dev.cpp
Original file line number Diff line number Diff line change
@@ -21,12 +21,13 @@ int main(int /*argc*/, char* /*argv*/[]) {
absl::InitializeLog();
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);

// const auto map_folder = std::filesystem::path("dev/maps/District_of_Columbia");
const auto map_folder = std::filesystem::path("dev/maps/District_of_Columbia");
// const auto map_folder = std::filesystem::path("dev/maps/gatech");
const auto map_folder = std::filesystem::path("dev/maps/debug");
// const auto map_folder = std::filesystem::path("dev/maps/Ile-de-France");
// const auto map_folder = std::filesystem::path("dev/maps/debug");

// const std::string map_filename = "map.osm.pbf";
const std::string map_filename = "illinois-latest.osm.pbf";
const std::string map_filename = "map.osm.pbf";
// const std::string map_filename = "illinois-latest.osm.pbf";
// const std::string map_filename = "map.osm";

Network* network = getNetFromFile(map_folder / map_filename, {ModeType::AUTO},
@@ -36,7 +37,7 @@ int main(int /*argc*/, char* /*argv*/[]) {

// consolidateComplexIntersections(network, true);

generateNodeActivityInfo(network);
// generateNodeActivityInfo(network);

// fillLinkAttributesWithDefaultValues(network, true, {}, false, {{HighWayLinkType::MOTORWAY, 1}}, true,
// {{HighWayLinkType::MOTORWAY, 1}});
1 change: 1 addition & 0 deletions src/constants.h
Original file line number Diff line number Diff line change
@@ -6,5 +6,6 @@
#define OSM2GMNS_CONSTANTS_H

constexpr double MICROSECONDS_TO_SECOND = 1e-6;
constexpr float MPH_TO_KPH = 1.609;

#endif // OSM2GMNS_CONSTANTS_H
6 changes: 5 additions & 1 deletion src/osmnetwork.cpp
Original file line number Diff line number Diff line change
@@ -384,7 +384,11 @@ void OsmWay::configAttributes() {
if (!max_speed_raw_.empty()) {
std::smatch match;
if (std::regex_search(max_speed_raw_, match, getFloatNumMatchingPattern())) {
max_speed_ = std::stof(match.str());
if (absl::StrContains(max_speed_raw_, "mph")) {
max_speed_ = std::round(std::stof(match.str()) * MPH_TO_KPH);
} else {
max_speed_ = std::stof(match.str());
}
}
}