12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ #include " autoware/geography_utils/height.hpp"
16
+
15
17
#include < GeographicLib/Geoid.hpp>
16
- #include < autoware/geography_utils/height.hpp>
17
18
18
19
#include < map>
19
20
#include < stdexcept>
20
21
#include < string>
22
+ #include < string_view>
21
23
#include < utility>
22
24
23
25
namespace autoware ::geography_utils
@@ -39,12 +41,12 @@ double convert_egm2008_to_wgs84(const double height, const double latitude, cons
39
41
40
42
double convert_height (
41
43
const double height, const double latitude, const double longitude,
42
- const std::string & source_vertical_datum, const std::string & target_vertical_datum)
44
+ std::string_view source_vertical_datum, std::string_view target_vertical_datum)
43
45
{
44
46
if (source_vertical_datum == target_vertical_datum) {
45
47
return height;
46
48
}
47
- static const std::map<std::pair<std::string , std::string >, HeightConversionFunction>
49
+ static const std::map<std::pair<std::string_view , std::string_view >, HeightConversionFunction>
48
50
conversion_map{
49
51
{{" WGS84" , " EGM2008" }, convert_wgs84_to_egm2008},
50
52
{{" EGM2008" , " WGS84" }, convert_egm2008_to_wgs84},
@@ -55,8 +57,10 @@ double convert_height(
55
57
return it->second (height, latitude, longitude);
56
58
}
57
59
58
- throw std::invalid_argument (
59
- " Invalid conversion types: " + source_vertical_datum + " to " + target_vertical_datum);
60
+ throw std::invalid_argument (std::string{" Invalid conversion types: " }
61
+ .append (source_vertical_datum)
62
+ .append (" to " )
63
+ .append (target_vertical_datum));
60
64
}
61
65
62
66
} // namespace autoware::geography_utils
0 commit comments