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?
There was a problem hiding this comment.
Apart from the fact that it now allows using brace initialization using the correct type for the members, I have not noticed any adverse effects. I haven't played a whole lot on this branch, but I did play a few hours in total and I didn't notice anything off.
|
|
||
| // 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?
There was a problem hiding this comment.
I went with constexpr std::array<std::string_view, _> and I did factor out the print_csv definitions. Beyond that, one would actually have to use a real class of a CSV writer. However, that wouldn't really be a good fit, because the current implementation uses unfinished lines to then add the geometry as a separate step.
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.