Export DF world map for use in GIS tools - #5376
Conversation
| @@ -1,4 +1,4 @@ | |||
| coord2d(uint16_t _x, uint16_t _y) : x(_x), y(_y) {} | |||
| coord2d(int16_t _x, int16_t _y) : x(_x), y(_y) {} | |||
There was a problem hiding this comment.
I've been reluctant to make this change myself because I've been uncertain of the consequences - how well tested is this behaviorally?
| std::ostream &out, | ||
| const Range &elements, | ||
| Callable&& print_element, | ||
| const std::string &prefix = "[", |
There was a problem hiding this comment.
const std::string & is usually an indication that std::string_view should be used instead
|
|
||
| // If you change anything in this vector, don't forget to change the | ||
| // corresponding comments and arguments in the call to print_csv below | ||
| vector<std::string> headings = { |
There was a problem hiding this comment.
consider using const char* or std::string_view here, to avoid potentially unneeded heap allocations/deallocations
| * (i.e. 16 region tiles per world tile) and emits a WKT path in GIS-compatible | ||
| * local tile coordinates (negative y-coordinates, 48 stepts per region tile) | ||
| */ | ||
| static void print_path(std::ostream &out, const std::vector<coord> &path) { |
There was a problem hiding this comment.
std::span instead of reference to vector
| void print_range( | ||
| std::ostream &out, | ||
| const Range& elements, | ||
| const std::string &prefix = "[", |
There was a problem hiding this comment.
these should all be std::string_view
|
|
||
| // If you change anything in this vector, don't forget to change the | ||
| // corresponding comments and arguments in the call to print_csv below | ||
| vector<std::string> headings = { |
There was a problem hiding this comment.
consider std::string_view or const char * here to avoid heap allocations
There was a problem hiding this comment.
Also this code appear repetitive of code elsewhere, should there be an abstraction here?
The goal of this plugin is to export the world map at the region-tile (i.e., embark tile or midmap-tile) level for use with GIS programs like ArcGIS or QGIS. For a medium-sized map, this amounts to (129*16)^2 = 4260096 region tiles with biome information for every region tile fetched from one of the surrounding world tiles.
In order to keep the output down to a manageable size (17 MB of CSV for a medium-sized world), region tiles are clustered by the world tile they take their information from, and every cluster is exported as a single feature with its geometry described as a WKT (MULTI)POLYGON, resulting in an export of only 129^2 = 16641 features.