Skip to content

new tool: gui/export-world-map - #1606

Merged
ab9rf merged 3 commits into
DFHack:masterfrom
chdoc:gui-export-world-map
Sep 15, 2026
Merged

ab9rf merged 3 commits into
DFHack:masterfrom
chdoc:gui-export-world-map

Conversation

@chdoc

@chdoc chdoc commented Aug 15, 2026

Copy link
Copy Markdown
Member

Depends on DFHack/dfhack#5376 to be merged first.

@chdoc
chdoc force-pushed the gui-export-world-map branch from 1ecec90 to 8e88b02 Compare August 15, 2026 12:36
@chdoc

chdoc commented Aug 15, 2026

Copy link
Copy Markdown
Member Author
gui-export-world-map

@ab9rf
ab9rf requested a review from SilasD September 1, 2026 20:07
@chdoc
chdoc force-pushed the gui-export-world-map branch from 58f77d0 to 109cc47 Compare September 2, 2026 18:25

@SilasD SilasD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No red flags in the GUI script. Some quibbles and some questions, but nothing to hold up accepting the PR.

I'll do the other scripts later, I have to go grocery shopping.

Comment thread gui/export-world-map.lua
Comment thread gui/export-world-map.lua
Comment thread gui/export-world-map.lua Outdated
Comment thread gui/export-world-map.lua
Comment thread gui/export-world-map.lua
Comment thread gui/export-world-map.lua Outdated
Comment thread gui/export-world-map.lua Outdated
Comment thread gui/export-world-map.lua Outdated
Comment thread docs/gui/export-world-map.rst

@SilasD SilasD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no red flags, it all looks reasonable. another question and a quibble or two.


for _, geo_biome in ipairs(df.global.world.world_data.geo_biomes) do
for _, layer in ipairs(geo_biome.layers) do
out:write(('%s;%s;%s;%s;%s\n'):format(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why semicolons when the output is named as a CSV file? Comma-separated values

(later) I see you're using this for most/all output files. I'm not going to comment on each occurance.

as an aside, I've never understood why people use the idiom
("a format string"):format(val, val)
instead of
string.format("a format string", val, val)
treating it as a sprintf-alike

if the format string is already defined, it makes sense, sure. but that's so seldom the case with string.format.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

why semicolons when the output is named as a CSV file? Comma-separated values

(later) I see you're using this for most/all output files. I'm not going to comment on each occurance.

This is a case of Europeans doing European things: https://discord.com/channels/793331351645323264/1340358673003712654/1540610890192134195

However, I agree that this should be documented for the benefit of others.

@ab9rf ab9rf Sep 13, 2026

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.

BTW, the rule for when you use a semicolon is "if the decimal separator is a comma, then the CSV separator is a semicolon, otherwise it's a comma". Microsoft's locale processing does this for you (they have a ListSeparator element in their locale library which is inferred using this rule) but in POSIX (and thus in the C++ standard, which is heavily POSIX-leaning) you have to do it yourself.

Most CSV libraries will accept either. Arguably, the best approach is to grab the current locale, identify its decimal separator, and from that infer whether a comma or a semicolon is most appropriate.

std::locale current_locale = std::locale{""};    
auto const& numeric_facet = std::use_facet<std::numpunct<char>>(current_locale);
char decimal_sep = numeric_facet.decimal_point();
char list_sep = decimal_sep == ',' ? ';' : ',';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I really would prefer if output of the world export tools would not depend on the user's locale. As far as I know, no other behavior of DFHack depends on it. If only you knew how much grief Microsoft's locale-dependent interpretation of CSV has caused on this side of the Atlantic...

Moreover, while semicolons do not naturally occur in our data, commas very much do

plant_pops.csv:736;Grass;BAMBOO, GOLDEN;10000001;10000001
plant_pops.csv:737;Grass;BAMBOO, ARROW;10000001;10000001
plant_pops.csv:746;Grass;BAMBOO, HEDGE;10000001;10000001
sites.csv:1434;-1;-10000;-1;lair;Emanomba Etrujulosm;Birdsrivers the Earthen Crab;NONE;NONE;NONE;NONE;NONE;POLYGON((84336 -52896,84384 -52896,84384 -52944,84336 -52944,84336 -52896))

The commas inside the WKT geometries obviously affects all layer files, including those generated by the C++ plugin.

Currently, all exports get away without doing any escaping. If you want commas, you also will get escaping.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

<meme> Um, ackchyually, </meme>

We've got a couple of locale-specific numbers. The trade overlays format prices per locale, and the notifications floating overlay formats time-since-last-save per locale.

Which is just quibbling really.

Commas crop up in the exported data; I think that's a good enough reason to go with semicolons. All good.

Comment thread internal/export-world-map/export-layers.lua
Comment thread internal/export-world-map/export-pops.lua Outdated
Comment thread internal/export-world-map/export-pops.lua
@SilasD

SilasD commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

looks great.

@ab9rf
ab9rf merged commit 0d0b2f5 into DFHack:master Sep 15, 2026
10 checks passed
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