MCPcopy Create free account
hub / github.com/Kitware/VTK / proj_grid_info

Function proj_grid_info

ThirdParty/libproj/vtklibproj/src/4D_api.cpp:1723–1793  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

1721
1722/*****************************************************************************/
1723PJ_GRID_INFO proj_grid_info(const char *gridname) {
1724/******************************************************************************
1725 Information about a named datum grid.
1726
1727 Returns PJ_GRID_INFO struct.
1728******************************************************************************/
1729 PJ_GRID_INFO grinfo;
1730
1731 /*PJ_CONTEXT *ctx = proj_context_create(); */
1732 PJ_CONTEXT *ctx = pj_get_default_ctx();
1733 memset(&grinfo, 0, sizeof(PJ_GRID_INFO));
1734
1735 const auto fillGridInfo = [&grinfo, ctx, gridname]
1736 (const NS_PROJ::Grid& grid, const std::string& format)
1737 {
1738 const auto& extent = grid.extentAndRes();
1739
1740 /* name of grid */
1741 strncpy (grinfo.gridname, gridname, sizeof(grinfo.gridname) - 1);
1742
1743 /* full path of grid */
1744 pj_find_file(ctx, gridname, grinfo.filename, sizeof(grinfo.filename) - 1);
1745
1746 /* grid format */
1747 strncpy (grinfo.format, format.c_str(), sizeof(grinfo.format) - 1);
1748
1749 /* grid size */
1750 grinfo.n_lon = grid.width();
1751 grinfo.n_lat = grid.height();
1752
1753 /* cell size */
1754 grinfo.cs_lon = extent.resX;
1755 grinfo.cs_lat = extent.resY;
1756
1757 /* bounds of grid */
1758 grinfo.lowerleft.lam = extent.west;
1759 grinfo.lowerleft.phi = extent.south;
1760 grinfo.upperright.lam = extent.east;
1761 grinfo.upperright.phi = extent.north;
1762 };
1763
1764 {
1765 const auto gridSet = NS_PROJ::VerticalShiftGridSet::open(ctx, gridname);
1766 if( gridSet )
1767 {
1768 const auto& grids = gridSet->grids();
1769 if( !grids.empty() )
1770 {
1771 const auto& grid = grids.front();
1772 fillGridInfo(*grid, gridSet->format());
1773 return grinfo;
1774 }
1775 }
1776 }
1777
1778 {
1779 const auto gridSet = NS_PROJ::HorizontalShiftGridSet::open(ctx, gridname);
1780 if( gridSet )

Callers

nothing calls this directly

Calls 8

pj_get_default_ctxFunction · 0.85
pj_find_fileFunction · 0.85
widthMethod · 0.80
heightMethod · 0.80
c_strMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected