1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2021 Barend Gehrels, Amsterdam, the Netherlands.
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)
9 #ifndef GEOMETRY_TEST_GEOMETRY_TO_CRC_HPP
10 #define GEOMETRY_TEST_GEOMETRY_TO_CRC_HPP
12 #include <boost/geometry/io/wkt/wkt.hpp>
14 #include <boost/crc.hpp>
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)
24 std::ostringstream out1;
25 out1 << bg::wkt(geometry);
27 const std::string str = out1.str();
29 boost::crc_ccitt_type result;
30 result.process_bytes(str.data(), str.length());
32 std::ostringstream out2;
33 out2 << std::setw(4) << std::setfill('0') << std::hex << result.checksum();
37 #endif // GEOMETRY_TEST_GEOMETRY_TO_CRC_HPP