Skip to content
Snippets Groups Projects
Commit e1e1e2ff authored by Andreas Gattringer's avatar Andreas Gattringer
Browse files

butterflies: save overlay grid

parent 7fab5a46
Branches
Tags
No related merge requests found
...@@ -40,6 +40,7 @@ void bf_register_actions(struct cats_configuration *conf) ...@@ -40,6 +40,7 @@ void bf_register_actions(struct cats_configuration *conf)
register_action_function(conf, bf_action_dispersal, "butterfly_action_dispersal", "egg dispersal"); register_action_function(conf, bf_action_dispersal, "butterfly_action_dispersal", "egg dispersal");
register_action_function(conf, bf_action_save_grid, "bf_action_save_grid", "output"); register_action_function(conf, bf_action_save_grid, "bf_action_save_grid", "output");
register_action_function(conf, bf_action_save_eggs_grid, "bf_action_save_egg_grid", "egg output"); register_action_function(conf, bf_action_save_eggs_grid, "bf_action_save_egg_grid", "egg output");
register_action_function(conf, bf_action_save_overlay, "bf_action_save_overlay_grid", "overlay output");
register_action_function(conf, bf_action_stats_gather, "bf_action_stats_gather", "gather stats"); register_action_function(conf, bf_action_stats_gather, "bf_action_stats_gather", "gather stats");
register_action_function(conf, bf_action_stats_reset, "bf_action_stats_reset", "reset stats"); register_action_function(conf, bf_action_stats_reset, "bf_action_stats_reset", "reset stats");
register_action_function(conf, bf_action_stats_write, "bf_action_stats_write", "write stats"); register_action_function(conf, bf_action_stats_write, "bf_action_stats_write", "write stats");
...@@ -58,8 +59,10 @@ void bf_add_actions(struct cats_configuration *conf) ...@@ -58,8 +59,10 @@ void bf_add_actions(struct cats_configuration *conf)
append_action(conf, bf_action_stats_reset, ALL_STAGES, "resetting butterfly statistics", module_name); append_action(conf, bf_action_stats_reset, ALL_STAGES, "resetting butterfly statistics", module_name);
append_action_by_name(conf, "action_load_environments", ALL_STAGES, "environment update", module_name); append_action_by_name(conf, "action_load_environments", ALL_STAGES, "environment update", module_name);
append_action_by_name(conf, "action_overlay_update", ALL_STAGES, "overlay update", module_name); append_action_by_name(conf, "action_overlay_update", ALL_STAGES, "overlay update", module_name);
append_action(conf, bf_action_overlay_update, ALL_STAGES, "updating resource layer", module_name); append_action(conf, bf_action_overlay_update, ALL_STAGES, "updating resource layer", module_name);
append_action(conf, bf_action_generation_update, ALL_STAGES, "update generations", module_name); append_action(conf, bf_action_generation_update, ALL_STAGES, "update generations", module_name);
append_action(conf, bf_action_save_overlay, ALL_STAGES, "save overlay", module_name);
for (int32_t generation = data->generations_max; generation > 0; generation--) { for (int32_t generation = data->generations_max; generation > 0; generation--) {
......
...@@ -96,6 +96,21 @@ enum action_status bf_action_save_grid(struct cats_grid *grid, struct cats_confi ...@@ -96,6 +96,21 @@ enum action_status bf_action_save_grid(struct cats_grid *grid, struct cats_confi
return ACTION_RUN; return ACTION_RUN;
} }
enum action_status bf_action_save_overlay(struct cats_grid *grid, struct cats_configuration *conf)
{
int32_t id = grid->id;
char *filename = bf_population_filename(conf, grid);
int module_id = CATS_MODULE_ID;
struct grid_data_butterflies *module_data = grid->grid_modules[module_id].module_data;
struct grid_wrapper data = gridwrapper(module_data->info_layer, grid->dimension);
save_grid_to_gdal(&data, GDT_Int32, conf, filename, conf->param[id].species_name);
free(filename);
return ACTION_RUN;
}
enum action_status bf_action_save_eggs_grid(struct cats_grid *grid, struct cats_configuration *conf) enum action_status bf_action_save_eggs_grid(struct cats_grid *grid, struct cats_configuration *conf)
{ {
......
...@@ -24,4 +24,7 @@ enum action_status bf_action_generation_start(struct cats_grid *grid, __attribut ...@@ -24,4 +24,7 @@ enum action_status bf_action_generation_start(struct cats_grid *grid, __attribut
enum action_status bf_action_generation_update(struct cats_grid *grid, struct cats_configuration *conf); enum action_status bf_action_generation_update(struct cats_grid *grid, struct cats_configuration *conf);
enum action_status bf_action_save_eggs_grid(struct cats_grid *grid, struct cats_configuration *conf); enum action_status bf_action_save_eggs_grid(struct cats_grid *grid, struct cats_configuration *conf);
enum action_status bf_action_save_overlay(struct cats_grid *grid, struct cats_configuration *conf)
#endif //CATS_BUTTERFLIES_ACTIONS_H #endif //CATS_BUTTERFLIES_ACTIONS_H
...@@ -63,6 +63,28 @@ char *bf_population_eggs_filename(struct cats_configuration *conf, struct cats_g ...@@ -63,6 +63,28 @@ char *bf_population_eggs_filename(struct cats_configuration *conf, struct cats_g
return filename; return filename;
} }
char *bf_population_overlay_filename(struct cats_configuration *conf, struct cats_grid *grid)
{
assert(grid != NULL);
assert(conf != NULL);
assert(conf->grid_count == 1);
struct string_array *path = get_output_directory(conf, "butterfly-overlay"); // FIXME MAKE DIRECTORY
char *extension = get_extension(conf, "overlay");
struct string_array *name = standard_output_file_name(conf, NULL, NULL, NULL);
char *filename = assemble_filename(path, name, "_", extension);
free_string_array(&path);
free_string_array(&name);
free(extension);
return filename;
}
char *bf_stats_filename(struct cats_configuration *conf, struct cats_grid *grid) char *bf_stats_filename(struct cats_configuration *conf, struct cats_grid *grid)
{ {
struct string_array *path = get_output_directory(conf, "stats"); struct string_array *path = get_output_directory(conf, "stats");
......
...@@ -5,4 +5,5 @@ ...@@ -5,4 +5,5 @@
char *bf_population_eggs_filename(struct cats_configuration *conf, struct cats_grid *grid); char *bf_population_eggs_filename(struct cats_configuration *conf, struct cats_grid *grid);
char *bf_population_filename(struct cats_configuration *conf, struct cats_grid *grid); char *bf_population_filename(struct cats_configuration *conf, struct cats_grid *grid);
char *bf_stats_filename(struct cats_configuration *conf, struct cats_grid *grid); char *bf_stats_filename(struct cats_configuration *conf, struct cats_grid *grid);
char *bf_population_overlay_filename(struct cats_configuration *conf, struct cats_grid *grid);
#endif //CATS_BUTTERFLIES_FILENAMES_H #endif //CATS_BUTTERFLIES_FILENAMES_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment