Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid::get_map_iter() function never returns an iterator for the first map #147

Closed
uleysky opened this issue Feb 11, 2021 · 2 comments
Closed

Comments

@uleysky
Copy link

uleysky commented Feb 11, 2021

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
Copy link
Member

jgallagher59701 commented Feb 14, 2022 via email

@jgallagher59701
Copy link
Member

Fixed

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

No branches or pull requests

2 participants