diff --git a/lib/Biodiverse/BaseStruct/Export.pm b/lib/Biodiverse/BaseStruct/Export.pm index d3b2a6e99..90799b871 100644 --- a/lib/Biodiverse/BaseStruct/Export.pm +++ b/lib/Biodiverse/BaseStruct/Export.pm @@ -740,7 +740,7 @@ sub export_shapefile { if (defined $list_name) { # repeated polys per list item push @list_col_specs_gdal, {Name => 'KEY', Type => 'String'}, - {Name => 'VALUE', Type => 'Real'}, + {Name => 'VALUE', Type => $args{list_val_type} // 'Real'}, } my $layer = GetDriver('ESRI Shapefile') diff --git a/lib/Biodiverse/Cluster.pm b/lib/Biodiverse/Cluster.pm index 34ca0a3b1..94efe31c0 100644 --- a/lib/Biodiverse/Cluster.pm +++ b/lib/Biodiverse/Cluster.pm @@ -541,6 +541,40 @@ sub export_shapefile { return; } +sub get_metadata_export_shapefile_grouped { + my $self = shift; + + my $metadata = $self->get_metadata_export_shapefile; + $metadata->{format} = 'Shapefile grouped'; + push @{$metadata->{parameters}}, + $self->get_grouped_export_metadata; + splice @{$metadata->{parameters}}, 1, 1; # dirty hack + + for (@{$metadata->{parameters}}) { + bless $_, $parameter_metadata_class; + } + + return wantarray ? %$metadata : $metadata; +} + +sub export_shapefile_grouped { + my ($self, %args) = @_; + + my $bs = $self->to_basestruct_group_nodes( + %args, + terminals_only => 1, + #sub_list => $args{list}, + ); + $bs->set_param(CELL_SIZES => scalar $self->get_basedata_ref->get_cell_sizes); + + $bs->export_shapefile ( + %args, + list => 'node_data', + list_val_type => 'String', # hacky that we need to set this + ); + + return; +} # some of this can be refactored wth Spatial::get_spatial_conditions_ref sub process_spatial_conditions_and_def_query { diff --git a/lib/Biodiverse/Tree.pm b/lib/Biodiverse/Tree.pm index e0a27082f..c3eae7362 100644 --- a/lib/Biodiverse/Tree.pm +++ b/lib/Biodiverse/Tree.pm @@ -1221,11 +1221,8 @@ sub export_tabular_tree { return 1; } -sub get_metadata_export_table_grouped { - my ($self, %args) = @_; - - my @parameters = ( - $args{sub_list_meta} || $self->get_lists_export_metadata(), +sub get_grouped_export_metadata { + my @params = ( { name => 'num_clusters', label_text => 'Number of groups', @@ -1257,6 +1254,16 @@ sub get_metadata_export_table_grouped { type => 'boolean', default => 0, }, + ); + + return wantarray ? @params : \@params; +} + +sub get_metadata_export_table_grouped { + my ($self, %args) = @_; + + my @parameters = ( + $args{sub_list_meta} || $self->get_lists_export_metadata, { name => 'symmetric', label_text => 'Force output table to be symmetric', @@ -1290,7 +1297,8 @@ sub get_metadata_export_table_grouped { type => 'boolean', default => 1, }, - $self->get_table_export_metadata(), + $self->get_grouped_export_metadata, + $self->get_table_export_metadata, ); for (@parameters) {