diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-09-26 14:14:44 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-10-23 09:56:43 -0700 |
commit | 4b2e1cddb4645fb6d2c5f9634dbeb7c21516cede (patch) | |
tree | f11bd97ea5abf17bc6956f254796f1e8cf4a96f9 /src/mbgl/style/conversion/position.cpp | |
parent | bb58ddaea8c2d9da9551601318944d9d143ee247 (diff) | |
download | qtlocation-mapboxgl-4b2e1cddb4645fb6d2c5f9634dbeb7c21516cede.tar.gz |
Replace compile-time polymorphism with runtime polymorphism in the conversion system
Diffstat (limited to 'src/mbgl/style/conversion/position.cpp')
-rw-r--r-- | src/mbgl/style/conversion/position.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mbgl/style/conversion/position.cpp b/src/mbgl/style/conversion/position.cpp new file mode 100644 index 0000000000..702d250dbf --- /dev/null +++ b/src/mbgl/style/conversion/position.cpp @@ -0,0 +1,22 @@ +#include <mbgl/style/conversion/position.hpp> +#include <mbgl/style/conversion/constant.hpp> + +#include <array> + +namespace mbgl { +namespace style { +namespace conversion { + +optional<Position> Converter<Position>::operator()(const Convertible& value, Error& error) const { + optional<std::array<float, 3>> spherical = convert<std::array<float, 3>>(value, error); + + if (!spherical) { + return {}; + } + + return Position(*spherical); +} + +} // namespace conversion +} // namespace style +} // namespace mbgl |