Returns the full filename corresponding to a proj resource file specified * as a short filename. * * @param ctx context. * @param short_filename short filename (e.g. us_nga_egm96_15.tif). * Must not be NULL. * @param out_full_filename output buffer, of size out_full_filename_size, that * will receive the full filename on success. *
| 1743 | * @return 1 if the file was found, 0 otherwise. |
| 1744 | */ |
| 1745 | int pj_find_file(PJ_CONTEXT *ctx, const char *short_filename, |
| 1746 | char *out_full_filename, size_t out_full_filename_size) { |
| 1747 | auto file = std::unique_ptr<NS_PROJ::File>( |
| 1748 | reinterpret_cast<NS_PROJ::File *>(pj_open_lib_internal( |
| 1749 | ctx, short_filename, "rb", pj_open_file_with_manager, |
| 1750 | out_full_filename, out_full_filename_size))); |
| 1751 | |
| 1752 | // Retry with the old proj grid name if the file name ends with .tif |
| 1753 | if (file == nullptr && strstr(short_filename, ".tif") != nullptr) { |
| 1754 | |
| 1755 | auto dbContext = getDBcontext(ctx); |
| 1756 | if (dbContext) { |
| 1757 | try { |
| 1758 | auto filename = dbContext->getOldProjGridName(short_filename); |
| 1759 | if (!filename.empty()) { |
| 1760 | file.reset(reinterpret_cast<NS_PROJ::File *>( |
| 1761 | pj_open_lib_internal(ctx, filename.c_str(), "rb", |
| 1762 | pj_open_file_with_manager, |
| 1763 | out_full_filename, |
| 1764 | out_full_filename_size))); |
| 1765 | } |
| 1766 | } catch (const std::exception &e) { |
| 1767 | pj_log(ctx, PJ_LOG_DEBUG, "%s", e.what()); |
| 1768 | return false; |
| 1769 | } |
| 1770 | } |
| 1771 | } |
| 1772 | |
| 1773 | return file != nullptr; |
| 1774 | } |
| 1775 | |
| 1776 | /************************************************************************/ |
| 1777 | /* trim() */ |
no test coverage detected