23 fs.open(csvFilename.c_str());
24 if (not
fs.is_open()){
25 const std::string
msg =
"Failed to open the mapping file: " + csvFilename;
26 throw std::runtime_error(
msg);
30 std::regex re(R
"delim(^(.*), (\d+), (-?\d+), (\d+), (\d+), (-?\d+)$)delim");
31 auto dissectMatch=[](
const std::smatch &
m)->std::pair<std::string, Coordinates>{
32 static constexpr
size_t expectedSize(7);
33 static constexpr
size_t coordStart(2);
34 std::pair<std::string, PixelMapping::Coordinates>
result{};
35 if (
m.size()!=expectedSize)
return result;
36 const std::string
name =
m[1];
39 for (
size_t i(0);
i!=coords.size();++
i){
41 coords[
i] = std::stoi(
m.str(
i+coordStart));
42 }
catch (std::invalid_argument &
e){
43 const std::string
msg =
"PixelMapping: Line of csv file in unexpected format, \n"+ std::string(
m[0]);
44 throw std::runtime_error(
msg);
51 while (std::getline(
fs,
line)){
53 if (
line[0] ==
'#')
continue;
57 std::cout<<
"line in unexpected format:\n"<<
line<<std::endl;
62 std::cout<<
"repeated entry:\n"<<
line<<std::endl;
73 std::cout<<
"id "<<geographicalID<<
" not found in mapping"<<std::endl;
76 const auto & coordinates = pName->second;
77 *hashID = coordinates[0];
78 *
bec = coordinates[1];
79 *
layer = coordinates[2];
89 std::cout<<
"id "<<geographicalID<<
" not found in mapping"<<std::endl;
92 const auto & coordinates = pName->second;
93 return coordinates[0];