Skip to content

Commit

Permalink
GRIB: avoid quadratic performance on GRIB2 datasets using subgrids wi…
Browse files Browse the repository at this point in the history
…thin a single GRIB message (to be opposed to several GRIB messages concatenated) (fixes OSGeo#2288)
  • Loading branch information
rouault committed Mar 3, 2020
1 parent a794661 commit 9701f02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion gdal/frmts/grib/degrib/degrib/degrib2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,10 @@ int ReadGrib2Record (VSILFILE *fp, sChar f_unit, double **Grib_Data,

/* Note we are getting data back either as a float or an int, but not
* both, so we don't need to allocated room for both. */
unpk_g2ncep (&kfildo, (float *) (IS->iain), IS->iain, &(IS->nd2x3),
unpk_g2ncep (&kfildo,
j == subgNum ? (float *) (IS->iain) : nullptr,
j == subgNum ? IS->iain : nullptr,
&(IS->nd2x3),
IS->idat, &(IS->nidat), IS->rdat, &(IS->nrdat), IS->is[0],
&(IS->ns[0]), IS->is[1], &(IS->ns[1]), IS->is[2],
&(IS->ns[2]), IS->is[3], &(IS->ns[3]), IS->is[4],
Expand Down
2 changes: 1 addition & 1 deletion gdal/frmts/grib/degrib/g2clib/g2_getfld.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ g2int g2_getfld(unsigned char *cgrib,g2int cgrib_length, g2int ifldnum,g2int unp
// bitmap before the requested field.
//
if (isecnum == 6) {
if (unpack) { // unpack bitmap
if (numfld==ifldnum && unpack) { // unpack bitmap
iofst=iofst-40; // reset offset to beginning of section
bmpsave=lgfld->bmap; // save pointer to previous bitmap
jerr=g2_unpack6(cgrib,cgrib_length,&iofst,lgfld->ngrdpts,&lgfld->ibmap,
Expand Down

0 comments on commit 9701f02

Please sign in to comment.