Skip to content

Commit

Permalink
refactor lanelet2_projector
Browse files Browse the repository at this point in the history
Signed-off-by: Yutaka Kondo <[email protected]>
  • Loading branch information
youtalk committed Dec 17, 2024
1 parent f69bed9 commit 4194707
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions common/autoware_geography_utils/src/lanelet2_projector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,32 @@ namespace autoware::geography_utils
std::unique_ptr<lanelet::Projector> get_lanelet2_projector(const MapProjectorInfo & projector_info)
{
if (projector_info.projector_type == MapProjectorInfo::LOCAL_CARTESIAN_UTM) {
lanelet::GPSPoint position{
const lanelet::GPSPoint position{
projector_info.map_origin.latitude, projector_info.map_origin.longitude,
projector_info.map_origin.altitude};
lanelet::Origin origin{position};
lanelet::projection::UtmProjector projector{origin};
const lanelet::Origin origin{position};
const lanelet::projection::UtmProjector projector{origin};
return std::make_unique<lanelet::projection::UtmProjector>(projector);
}

} else if (projector_info.projector_type == MapProjectorInfo::MGRS) {
if (projector_info.projector_type == MapProjectorInfo::MGRS) {
lanelet::projection::MGRSProjector projector{};
projector.setMGRSCode(projector_info.mgrs_grid);
return std::make_unique<lanelet::projection::MGRSProjector>(projector);
}

} else if (projector_info.projector_type == MapProjectorInfo::TRANSVERSE_MERCATOR) {
lanelet::GPSPoint position{
if (projector_info.projector_type == MapProjectorInfo::TRANSVERSE_MERCATOR) {
const lanelet::GPSPoint position{
projector_info.map_origin.latitude, projector_info.map_origin.longitude,
projector_info.map_origin.altitude};
lanelet::Origin origin{position};
lanelet::projection::TransverseMercatorProjector projector{origin};
const lanelet::Origin origin{position};
const lanelet::projection::TransverseMercatorProjector projector{origin};

Check warning on line 50 in common/autoware_geography_utils/src/lanelet2_projector.cpp

View check run for this annotation

Codecov / codecov/patch

common/autoware_geography_utils/src/lanelet2_projector.cpp#L50

Added line #L50 was not covered by tests
return std::make_unique<lanelet::projection::TransverseMercatorProjector>(projector);
}
const std::string error_msg =

throw std::invalid_argument(
"Invalid map projector type: " + projector_info.projector_type +
". Currently supported types: MGRS, LocalCartesianUTM, and TransverseMercator";
throw std::invalid_argument(error_msg);
". Currently supported types: MGRS, LocalCartesianUTM, and TransverseMercator");

Check warning on line 56 in common/autoware_geography_utils/src/lanelet2_projector.cpp

View check run for this annotation

Codecov / codecov/patch

common/autoware_geography_utils/src/lanelet2_projector.cpp#L56

Added line #L56 was not covered by tests
}

} // namespace autoware::geography_utils

0 comments on commit 4194707

Please sign in to comment.