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

proj_grid_info returns only name for grids mapped via proj.db #3238

Closed
gaige opened this issue Jun 26, 2022 · 2 comments
Closed

proj_grid_info returns only name for grids mapped via proj.db #3238

gaige opened this issue Jun 26, 2022 · 2 comments
Assignees
Labels

Comments

@gaige
Copy link

gaige commented Jun 26, 2022

Example of problem

char *gridname = "stlrnc";
setenv( "PROJ_DEBUG", "4", 1); 
PJ_GRID_INFO info = proj_grid_info(gridname);
if (strcmp(info.format,"gtiff")==0) {
   printf("Not using TIFF");
}

Meanwhile with grid name above set to us_noaa_stlrnc.tif (which is the mapped file), the full data is presented.

Problem description

proj_grid_info no longer returns full information on grids that were coerced using the LUT in proj.db. In this case, the problem was triggered when running some automated tests we had based on using older proj formats. The result is that anything entries such as stlrnc, which can be resolved into a grid set (us_noaa_stlrnc.tif) by using the LUT in proj.db were returning only .name because pj_find_file() does not perform the same lookup as is done by NS_PROJ::HorizontalShiftGridSet::open(). At the time of the call to fillGridInfo(), the gridset contains the full path for these types of grids, available in gridset->name(), but isn't passed in.

Before the call to fillGridInfo(), the gridset contains:

 osgeo::proj::Grid = {
    m_name = "<thepath>/us_noaa_stlrnc.tif"
    m_width = 81
    m_height = 41
    m_extent = {
      isGeographic = true
      west = -3.001966313430247
      south = 1.0821041362364843
      east = -2.9321531433504737
      north = 1.1170107212763709
      resX = 0.00087266462599716479
      resY = 0.00087266462599716479
      invResX = 1145.9155902616465
      invResY = 1145.9155902616465
    }
  }
  m_children = size=0 {}
}

However, the returned data is:

(PJ_GRID_INFO) grinfo = {
  gridname = "stlrnc"
  filename = ""
  format = ""
  lowerleft = (lam = 0, phi = 0)
  upperright = (lam = 0, phi = 0)
  n_lon = 0
  n_lat = 0
  cs_lon = 0
  cs_lat = 0
}

Expected Output

Prior to the changes in bc34a84, the data structure was complete.

Existing tests in gie_self_tests.cpp do not test for the situation where the grid is mapped from an old proj string.

There seems to be minimal use outside of gie, and the tests there are specifically for either directly-named grids.

Environment Information

  • 9.0.1 (built from source using cmake)
  • macOS 12.4

Installation method

  • built from source
@gaige gaige added the bug label Jun 26, 2022
@rouault rouault self-assigned this Jun 26, 2022
@rouault
Copy link
Member

rouault commented Jun 26, 2022

In master, FileManager::open_resource_file() (called by HorizontalShiftGridSet::open(()) now calls pj_find_file() by disabling networking, so the scope of the bug in master was reduced to querying information on remote known grids, compared to the 9.0 branch.

@gaige
Copy link
Author

gaige commented Jun 26, 2022

Thank you for the speedy confirmation and fix! I replaced my initial fix with this one and it is working well.

rouault added a commit that referenced this issue Jun 27, 2022
proj_grid_info(): make it work again with remote grids (refs #3238)
@rouault rouault closed this as completed Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants