mgastner / cartogram-cpp

Cartogram generator in C++
MIT License
8 stars 4 forks source link

Revamp `string_to_decimal_converter.cpp` #219

Open adisidev opened 1 day ago

adisidev commented 1 day ago

Currently, the following CSV will not work as expected because Thailand will will become 70.33, whereas we would treat others as if the decimal is absent.

name,Population (m. people),Color
Brunei,0.451,#7570b3
Cambodia,17.353,#e7298a
Indonesia,284.416,#7570b3
Laos,7.788,#66a61e
Malaysia,33.852,#7570b3
Myanmar,54.813,#d95f02
Philippines,114.365,#e7298a
Singapore,5.978,#1b9e77
Thailand,70.33,#1b9e77
Vietnam,101.589,#66a61e

We should either figure out how we can avoid such problems in the future, or we request the input CSV to be a particular format. What are your thoughts @mgastner

mgastner commented 1 day ago

Could you please elaborate? If Brunei's population is treated "as if the decimal is absent," would it be interpreted as zero? Additionally, why are the trailing decimals treated correctly only for Thailand?

adisidev commented 1 day ago

The decimal being absent would mean Brunei's population becomes 451. Our current assumption is that if there is a decimal point at the end followed by 3 numbers, we should treat it as a separator not a decimal. (101.589 --> 101,589, but 70.33 --> 70.33. Similarly, 5.978 --> 5,978)