Skip to content

Commit

Permalink
proj_grid_info(): check pj_find_file() output (CID 383357)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Feb 22, 2022
1 parent dd96597 commit bc34a84
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/4D_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2276,24 +2276,25 @@ PJ_GRID_INFO proj_grid_info(const char *gridname) {
strncpy (grinfo.gridname, gridname, sizeof(grinfo.gridname) - 1);

/* full path of grid */
pj_find_file(ctx, gridname, grinfo.filename, sizeof(grinfo.filename) - 1);

/* grid format */
strncpy (grinfo.format, format.c_str(), sizeof(grinfo.format) - 1);

/* grid size */
grinfo.n_lon = grid.width();
grinfo.n_lat = grid.height();

/* cell size */
grinfo.cs_lon = extent.resX;
grinfo.cs_lat = extent.resY;

/* bounds of grid */
grinfo.lowerleft.lam = extent.west;
grinfo.lowerleft.phi = extent.south;
grinfo.upperright.lam = extent.east;
grinfo.upperright.phi = extent.north;
if( pj_find_file(ctx, gridname, grinfo.filename, sizeof(grinfo.filename) - 1) )
{
/* grid format */
strncpy (grinfo.format, format.c_str(), sizeof(grinfo.format) - 1);

/* grid size */
grinfo.n_lon = grid.width();
grinfo.n_lat = grid.height();

/* cell size */
grinfo.cs_lon = extent.resX;
grinfo.cs_lat = extent.resY;

/* bounds of grid */
grinfo.lowerleft.lam = extent.west;
grinfo.lowerleft.phi = extent.south;
grinfo.upperright.lam = extent.east;
grinfo.upperright.phi = extent.north;
}
};

{
Expand Down

0 comments on commit bc34a84

Please sign in to comment.