diff options
Diffstat (limited to 'src/proj.h')
| -rw-r--r-- | src/proj.h | 166 |
1 files changed, 166 insertions, 0 deletions
@@ -353,6 +353,166 @@ void PROJ_DLL proj_context_set_search_paths(PJ_CONTEXT *ctx, int count_paths, co void PROJ_DLL proj_context_use_proj4_init_rules(PJ_CONTEXT *ctx, int enable); int PROJ_DLL proj_context_get_use_proj4_init_rules(PJ_CONTEXT *ctx, int from_legacy_code_path); +/*! @endcond */ + +/** Opaque structure for PROJ for a file handle. Implementations might cast it to their + * structure/class of choice. */ +typedef struct PROJ_FILE_HANDLE PROJ_FILE_HANDLE; + +/** Open access / mode */ +typedef enum PROJ_OPEN_ACCESS +{ + /** Read-only access. Equivalent to "rb" */ + PROJ_OPEN_ACCESS_READ_ONLY, + + /** Read-update access. File should be created if not existing. Equivalent to "r+b" */ + PROJ_OPEN_ACCESS_READ_UPDATE, + + /** Create access. File should be truncated to 0-byte if already existing. Equivalent to "w+b" */ + PROJ_OPEN_ACCESS_CREATE +} PROJ_OPEN_ACCESS; + +/** File API callbacks */ +typedef struct PROJ_FILE_API +{ + /** Version of this structure. Should be set to 1 currently. */ + int version; + + /** Open file. Return NULL if error */ + PROJ_FILE_HANDLE* (*open_cbk)(PJ_CONTEXT *ctx, const char *filename, PROJ_OPEN_ACCESS access, void* user_data); + + /** Read sizeBytes into buffer from current position and return number of bytes read */ + size_t (*read_cbk)(PJ_CONTEXT *ctx, PROJ_FILE_HANDLE*, void* buffer, size_t sizeBytes, void* user_data); + + /** Write sizeBytes into buffer from current position and return number of bytes written */ + size_t (*write_cbk)(PJ_CONTEXT *ctx, PROJ_FILE_HANDLE*, const void* buffer, size_t sizeBytes, void* user_data); + + /** Seek to offset using whence=SEEK_SET/SEEK_CUR/SEEK_END. Return TRUE in case of success */ + int (*seek_cbk)(PJ_CONTEXT *ctx, PROJ_FILE_HANDLE*, long long offset, int whence, void* user_data); + + /** Return current file position */ + unsigned long long (*tell_cbk)(PJ_CONTEXT *ctx, PROJ_FILE_HANDLE*, void* user_data); + + /** Close file */ + void (*close_cbk)(PJ_CONTEXT *ctx, PROJ_FILE_HANDLE*, void* user_data); + + /** Return TRUE if a file exists */ + int (*exists_cbk)(PJ_CONTEXT *ctx, const char *filename, void* user_data); + + /** Return TRUE if directory exists or could be created */ + int (*mkdir_cbk)(PJ_CONTEXT *ctx, const char *filename, void* user_data); + + /** Return TRUE if file could be removed */ + int (*unlink_cbk)(PJ_CONTEXT *ctx, const char *filename, void* user_data); + + /** Return TRUE if file could be renamed */ + int (*rename_cbk)(PJ_CONTEXT *ctx, const char *oldPath, const char *newPath, void* user_data); +} PROJ_FILE_API; + +int PROJ_DLL proj_context_set_fileapi( + PJ_CONTEXT* ctx, const PROJ_FILE_API* fileapi, void* user_data); + +void PROJ_DLL proj_context_set_sqlite3_vfs_name(PJ_CONTEXT* ctx, const char* name); + +/** Opaque structure for PROJ for a network handle. Implementations might cast it to their + * structure/class of choice. */ +typedef struct PROJ_NETWORK_HANDLE PROJ_NETWORK_HANDLE; + +/** Network access: open callback + * + * Should try to read the size_to_read first bytes at the specified offset of + * the file given by URL url, + * and write them to buffer. *out_size_read should be updated with the actual + * amount of bytes read (== size_to_read if the file is larger than size_to_read). + * During this read, the implementation should make sure to store the HTTP + * headers from the server response to be able to respond to + * proj_network_get_header_value_cbk_type callback. + * + * error_string_max_size should be the maximum size that can be written into + * the out_error_string buffer (including terminating nul character). + * + * @return a non-NULL opaque handle in case of success. + */ +typedef PROJ_NETWORK_HANDLE* (*proj_network_open_cbk_type)( + PJ_CONTEXT* ctx, + const char* url, + unsigned long long offset, + size_t size_to_read, + void* buffer, + size_t* out_size_read, + size_t error_string_max_size, + char* out_error_string, + void* user_data); + +/** Network access: close callback */ +typedef void (*proj_network_close_cbk_type)(PJ_CONTEXT* ctx, + PROJ_NETWORK_HANDLE* handle, + void* user_data); + +/** Network access: get HTTP headers */ +typedef const char* (*proj_network_get_header_value_cbk_type)( + PJ_CONTEXT* ctx, + PROJ_NETWORK_HANDLE* handle, + const char* header_name, + void* user_data); + +/** Network access: read range + * + * Read size_to_read bytes from handle, starting at offset, into + * buffer. + * During this read, the implementation should make sure to store the HTTP + * headers from the server response to be able to respond to + * proj_network_get_header_value_cbk_type callback. + * + * error_string_max_size should be the maximum size that can be written into + * the out_error_string buffer (including terminating nul character). + * + * @return the number of bytes actually read (0 in case of error) + */ +typedef size_t (*proj_network_read_range_type)( + PJ_CONTEXT* ctx, + PROJ_NETWORK_HANDLE* handle, + unsigned long long offset, + size_t size_to_read, + void* buffer, + size_t error_string_max_size, + char* out_error_string, + void* user_data); + +int PROJ_DLL proj_context_set_network_callbacks( + PJ_CONTEXT* ctx, + proj_network_open_cbk_type open_cbk, + proj_network_close_cbk_type close_cbk, + proj_network_get_header_value_cbk_type get_header_value_cbk, + proj_network_read_range_type read_range_cbk, + void* user_data); + +int PROJ_DLL proj_context_set_enable_network(PJ_CONTEXT* ctx, + int enabled); + +void PROJ_DLL proj_context_set_url_endpoint(PJ_CONTEXT* ctx, const char* url); + +void PROJ_DLL proj_grid_cache_set_enable(PJ_CONTEXT* ctx, int enabled); + +void PROJ_DLL proj_grid_cache_set_filename(PJ_CONTEXT* ctx, const char* fullname); + +void PROJ_DLL proj_grid_cache_set_max_size(PJ_CONTEXT* ctx, int max_size_MB); + +void PROJ_DLL proj_grid_cache_set_ttl(PJ_CONTEXT* ctx, int ttl_seconds); + +void PROJ_DLL proj_grid_cache_clear(PJ_CONTEXT* ctx); + +int PROJ_DLL proj_is_download_needed(PJ_CONTEXT* ctx, + const char* url_or_filename, + int ignore_ttl_setting); +int PROJ_DLL proj_download_file(PJ_CONTEXT *ctx, const char *url_or_filename, + int ignore_ttl_setting, + int (*progress_cbk)(PJ_CONTEXT *, double pct, + void *user_data), + void *user_data); + +/*! @cond Doxygen_Suppress */ + /* Manage the transformation definition object PJ */ PJ PROJ_DLL *proj_create (PJ_CONTEXT *ctx, const char *definition); PJ PROJ_DLL *proj_create_argv (PJ_CONTEXT *ctx, int argc, char **argv); @@ -624,6 +784,12 @@ typedef enum { /** Ignore grid availability at all. Results will be presented as if * all grids were available. */ PROJ_GRID_AVAILABILITY_IGNORED, + + /** Results will be presented as if grids known to PROJ (that is + * registered in the grid_alternatives table of its database) were + * available. Used typically when networking is enabled. + */ + PROJ_GRID_AVAILABILITY_KNOWN_AVAILABLE, } PROJ_GRID_AVAILABILITY_USE; /** \brief PROJ string version. */ |
