The region matching logic fails when the region ID in the CSV and the corresponding ID in the GeoJSON include any trailing whitespace. This behavior suggests that a preprocessing step, such as whitespace trimming, is being applied to one dataset (either CSV or GeoJSON) but not both, causing the two strings to become mismatched before comparison.
In the provided example, the region ID is present in both files as "San Andres y Providencia " (note the trailing space), yet the tool reports an error.
Steps to Reproduce
-
Use the following data files:
- GeoJSON:
https://raw.githubusercontent.com/go-cart-io/cartogram-web/refs/heads/main/internal/static/cartdata/colombia/Input.json
- CSV:
https://raw.githubusercontent.com/go-cart-io/cartogram-web/refs/heads/main/internal/static/cartdata/colombia/data.csv
- Note: Both files contain the ID
"San Andres y Providencia " with an identical trailing space.
-
Run the command:
cartogram-linux-amd64 Input.json data.csv --area "Population (people)"
-
Observe the output (Error):
ERROR: ID San Andres y Providencia in CSV is not in GeoJSON
Expected Behavior
The tool should successfully find a match because the strings are identical:
"San Andres y Providencia " (from CSV) SHOULD MATCH "San Andres y Providencia " (from GeoJSON).
The region matching logic fails when the region ID in the CSV and the corresponding ID in the GeoJSON include any trailing whitespace. This behavior suggests that a preprocessing step, such as whitespace trimming, is being applied to one dataset (either CSV or GeoJSON) but not both, causing the two strings to become mismatched before comparison.
In the provided example, the region ID is present in both files as
"San Andres y Providencia "(note the trailing space), yet the tool reports an error.Steps to Reproduce
Use the following data files:
https://raw.githubusercontent.com/go-cart-io/cartogram-web/refs/heads/main/internal/static/cartdata/colombia/Input.jsonhttps://raw.githubusercontent.com/go-cart-io/cartogram-web/refs/heads/main/internal/static/cartdata/colombia/data.csv"San Andres y Providencia "with an identical trailing space.Run the command:
cartogram-linux-amd64 Input.json data.csv --area "Population (people)"Observe the output (Error):
Expected Behavior
The tool should successfully find a match because the strings are identical:
"San Andres y Providencia "(from CSV) SHOULD MATCH"San Andres y Providencia "(from GeoJSON).