Skip to content

Export DF world map for use in GIS tools - #5376

Open
chdoc wants to merge 26 commits into
DFHack:developfrom
chdoc:export-map-2
Open

Export DF world map for use in GIS tools#5376
chdoc wants to merge 26 commits into
DFHack:developfrom
chdoc:export-map-2

Conversation

@chdoc

@chdoc chdoc commented Apr 3, 2025

Copy link
Copy Markdown
Member

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.

  • documentation and change log

Comment thread plugins/CMakeLists.txt Outdated
Comment thread plugins/export-map.cpp Outdated
@chdoc
chdoc marked this pull request as ready for review August 2, 2026 17:57
@@ -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) {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = "[",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::span instead of reference to vector

void print_range(
std::ostream &out,
const Range& elements,
const std::string &prefix = "[",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider std::string_view or const char * here to avoid heap allocations

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this code appear repetitive of code elsewhere, should there be an abstraction here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants