]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/geometry_to_crc.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / geometry_to_crc.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2021 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 #ifndef GEOMETRY_TEST_GEOMETRY_TO_CRC_HPP
10 #define GEOMETRY_TEST_GEOMETRY_TO_CRC_HPP
11
12 #include <boost/geometry/io/wkt/wkt.hpp>
13
14 #include <boost/crc.hpp>
15
16 #include <iomanip>
17 #include <string>
18
19 // Convenience function for tests, it generates a 4 character CRC of a geometry
20 // which can be used in filenames and/or testcases such as 'nores_37f6'
21 template <typename Geometry>
22 inline std::string geometry_to_crc(Geometry const& geometry)
23 {
24 std::ostringstream out1;
25 out1 << bg::wkt(geometry);
26
27 const std::string str = out1.str();
28
29 boost::crc_ccitt_type result;
30 result.process_bytes(str.data(), str.length());
31
32 std::ostringstream out2;
33 out2 << std::setw(4) << std::setfill('0') << std::hex << result.checksum();
34 return out2.str();
35 }
36
37 #endif // GEOMETRY_TEST_GEOMETRY_TO_CRC_HPP