Grid::get_map_iter() function never returns an iterator for the first map
uleysky opened this issue · 2 comments
uleysky commented
Example code:
#include <iostream>
#include <libdap/Connect.h>
#include <libdap/Array.h>
#include <libdap/Grid.h>
using namespace libdap;
int main()
{
Connect cn("http://tds.hycom.org/thredds/dodsC/GLBv0.08/expt_53.X/data/2008");
BaseTypeFactory btf;
DataDDS data(&btf);
cn.request_data(data,"surf_el[145:146]");
data.print(std::cout);
auto* elb=data.var("surf_el");
if(elb==nullptr) return 1;
std::cout<<elb->type_name()<<" "<<elb->length()<<std::endl;
auto* el=dynamic_cast<Grid*>(elb);
auto* arr=el->get_array();
std::cout<<arr->type_name()<<" "<<arr->length()<<std::endl;
std::cout<<el->components()<<std::endl;
for(size_t i=0; i<el->components()-1; ++i)
{
auto map=*(el->get_map_iter(i));
std::cout<<map->type_name()<<" "<<map->length()<<std::endl;
}
return 0;
}
Output:
Dataset {
Grid {
Array:
Int16 surf_el[time = 2][lat = 3251][lon = 4500];
Maps:
Float64 time[time = 2];
Float64 lat[lat = 3251];
Float64 lon[lon = 4500];
} surf_el;
} GLBv0.08/expt_53.X/data/2008;
Grid 1
Array 29259000
4
Array 3251
Array 4500
Segmentation fault
get_map_iter() skips map "time" and cause segmentation fault then called last time.
libdap 3.20.7.
jgallagher59701 commented
Fixed.
On Feb 10, 2021, at 22:20, Michael Uleysky ***@***.***> wrote:
Example code:
#include <iostream>
#include <libdap/Connect.h>
#include <libdap/Array.h>
#include <libdap/Grid.h>
using namespace libdap;
int main()
{
Connect cn("http://tds.hycom.org/thredds/dodsC/GLBv0.08/expt_53.X/data/2008");
BaseTypeFactory btf;
DataDDS data(&btf);
cn.request_data(data,"surf_el[145:146]");
data.print(std::cout);
auto* elb=data.var("surf_el");
if(elb==nullptr) return 1;
std::cout<<elb->type_name()<<" "<<elb->length()<<std::endl;
auto* el=dynamic_cast<Grid*>(elb);
auto* arr=el->get_array();
std::cout<<arr->type_name()<<" "<<arr->length()<<std::endl;
std::cout<<el->components()<<std::endl;
for(size_t i=0; i<el->components()-1; ++i)
{
auto map=*(el->get_map_iter(i));
std::cout<<map->type_name()<<" "<<map->length()<<std::endl;
}
return 0;
}
Output:
Dataset {
Grid {
Array:
Int16 surf_el[time = 2][lat = 3251][lon = 4500];
Maps:
Float64 time[time = 2];
Float64 lat[lat = 3251];
Float64 lon[lon = 4500];
} surf_el;
} GLBv0.08/expt_53.X/data/2008;
Grid 1
Array 29259000
4
Array 3251
Array 4500
Segmentation fault
get_map_iter() skips map "time" and cause segmentation fault then called last time.
libdap 3.20.7.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#147>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB7Q4KREZMCX5Y3EA3VG4JLS6NSJ3ANCNFSM4XOGYJDQ>.
—
James Gallagher
***@***.***
jgallagher59701 commented
Fixed