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