Crate eccodes_sys[][src]

Expand description

Low-level Rust bindings for ecCodes

This is a -sys crate with raw, unsafe bindings to the library and its API should not be used directly. See the eccodes crate for high-level, safe bindings.

ecCodes is an open-source library for reading and writing GRIB and BUFR files developed by European Centre for Medium-Range Weather Forecasts.

Usage

By default this crate will look for existing libeccodes installation using pkg-config. If the library is not found, the crate will attempt to download the latest source code and build ecCodes from source. The ecCodes library is then linked and bindings are generated using bindgen.

Features

The eccodes-sys crate allows to choose several features. For a detailed explanation of ecCodes compilation options check the official website.

  • build_source - ecCodes library will be built from source even if other installation exists. This option by default builds static library with MEMFS activated.

All following features activate building from source:

  • jpeg - builds ecCodes with JPEG2000 support enabled (ENABLE_JPG=ON), requires libopenjp2-7-dev
  • png - builds ecCodes with PNG support enabled (ENABLE_PNG=ON), requires libpng-dev
  • netcdf - builds ecCodes with NetCDF support enabled (ENABLE_NETCDF=ON), requires libnetcdff-dev and libnetcdf-c++4-dev
  • aec - builds ecCodes with Adaptive Entropy Coding for decoding/encoding (CCSDS) enabled (ENABLE_AEC=ON), requires libaec-dev
  • posix - builds ecCodes with POSIX threads support enabled (ENABLE_ECCODES_THREADS=ON)

These are advanced features which should be used only when you know that compilation files will not be removed:

  • shared - builds ecCodes as shared library (BUILD_SHARED_LIBS=ON)
  • no_memfs - builds ecCodes with MEMFS deactivated (ENABLE_MEMFS=OFF)

There are also development features available:

  • docs - for documentation building, does not build or link ecCodes and includes bindings-docs.rs into lib.rs
  • tests - turns on generation of layout tests by bindgen, should not be used in production. Layout tests are off by default as they derefrence null pointers causing undefined behaviour

Structs

Constants

Statics

Functions

Create a BUFR handle from a file resource. The file is read until a BUFR message is found. The message is then copied. Remember always to delete the handle when it is not needed anymore to avoid memory leaks.

Create a handle from a BUFR message contained in a samples directory. The message is copied at the creation of the handle

Frees the cached definition files of the context

Get the static default context

Sets the search path for definition files.

Sets the search path for sample files.

Copy the keys belonging to a given namespace from a source handle to a destination handle

\defgroup codes_handle The message handle The codes_handle is the structure giving access to parsed message values by keys. Counts the messages contained in a file resource.

Counts the messages contained in a file.

Print all keys from the parsed definition files available in a context

Print all keys, with the context print procedure and dump mode to a resource

Get the API version

Get raw bytes values from a key. If several keys of the same name are present, the last one is returned @see codes_set_bytes

Get a double value from a key, if several keys of the same name are present, the last one is returned @see codes_set_double

Get double array values from a key. If several keys of the same name are present, the last one is returned @see codes_set_double_array

Get as double the i-th element of the “key” array

Get as double array the elements of the “key” array whose indexes are listed in the input array i

Convert an error code into a string @param code : the error code @return the error message

Get the Git version control SHA1 identifier

Get the GRIBEX mode.

Get the length of the string representation of the key, if several keys of the same name are present, the maximum length is returned

Get a long value from a key, if several keys of the same name are present, the last one is returned @see codes_set_long

Get long array values from a key. If several keys of the same name are present, the last one is returned @see codes_set_long_array

\defgroup handling_coded_messages Handling coded messages */ getting the message attached to a handle

getting a copy of the message attached to a handle

\defgroup get_set Accessing header and data values */ Get the number offset of a key, in a message if several keys of the same name are present, the offset of the last one is returned

Get the package name

Get the number of coded value from a key, if several keys of the same name are present, the total sum is returned

Get a string value from a key, if several keys of the same name are present, the last one is returned @see codes_set_string

Get string array values from a key. If several keys of the same name are present, the last one is returned @see codes_set_string_array

Get latitude/longitude and data values. The Latitudes, longitudes and values arrays must be properly allocated by the caller. Their required dimension can be obtained by getting the value of the integer key “numberOfPoints”.

Create a GRIB handle from a file resource. The file is read until a GRIB message is found. The message is then copied. Remember always to delete the handle when it is not needed anymore to avoid memory leaks.

Create a handle from a user message in memory. The message will not be freed at the end. The message will be copied as soon as a modification is needed. This function works also with multi-field messages.

Create a handle from a GRIB message contained in the samples directory. The message is copied at the creation of the handle

Frees the geoiterator from memory.

Test procedure for values in a geoiterator.

\brief Create a new geoiterator from a GRIB handle, using current geometry and values.

Get the next value from a geoiterator.

Get the previous value from a geoiterator.

Test procedure for values in a geoiterator.

Append the sections starting with start_section of the message pointed by h at the end of the multi-field GRIB handle mh. This is only applicable to GRIB edition 2. Remember always to delete the multi-handle when it is not needed any more to avoid memory leaks.

Delete multi-field GRIB handle. This is only applicable to GRIB edition 2.

Create an empty multi-field GRIB handle. This is only applicable to GRIB edition 2. Remember always to delete the multi-handle when it is not needed any more to avoid memory leaks.

Write a multi-field GRIB handle in a file. This is only applicable to GRIB edition 2. Remember always to delete the multi-handle when it is not needed any more to avoid memory leaks.

Turn off support for multi-fields in single GRIB messages

Turn on support for multi-fields in single GRIB messages

Reset file handle in multiple GRIB field support mode

Frees an nearest from memory

Find the 4 nearest points of a latitude longitude point. The flags are provided to speed up the process of searching. If you are sure that the point you are asking for is not changing from a call to another you can use CODES_NEAREST_SAME_POINT. The same is valid for the grid. Flags can be used together doing a bitwise OR. The distances are given in kilometres.

Find the nearest point of a set of points whose latitudes and longitudes are given in the inlats, inlons arrays respectively. If the flag is_lsm is 1 the nearest land point is returned and the GRIB passed as handle (h) is considered a land sea mask. The land nearest point is the nearest point with land sea mask value>=0.5. If no nearest land points are found the nearest value is returned. If the flag is_lsm is 0 the nearest point is returned. values, distances, indexes (in the “values” array) for the nearest points (ilons,ilats) are returned. The distances are given in kilometres.

\brief Create a new nearest neighbour object from a handle, using current geometry.

Set the GRIBEX mode off. GRIB files won’t be always compatible with GRIBEX.

Set the GRIBEX mode on. GRIB files will be compatible with GRIBEX.

Set the GTS header mode off. The GTS headers will be deleted.

Set the GTS header mode on. The GTS headers will be preserved.

Clone an existing handle using the context of the original handle, The message is copied and reparsed

Frees a handle, also frees the message if it is not a user message @see codes_handle_new_from_message @param h : The handle to be deleted @return 0 if OK, integer value on error

Create a handle from a file resource. The file is read until a message is found. The message is then copied. Remember always to delete the handle when it is not needed anymore to avoid memory leaks.

Create a new handle from an index after having selected the key values. All the keys belonging to the index must be selected before calling this function. Successive calls to this function will return all the handles compatible with the constraints defined selecting the values of the index keys. When no more handles are available from the index a NULL pointer is returned and the err variable is set to CODES_END_OF_INDEX.

Create a handle from a user message in memory. The message will not be freed at the end. The message will be copied as soon as a modification is needed.

Create a handle from a user message. The message is copied and will be freed with the handle

Indexes the file given in argument in the index given in argument.

Delete the index.

Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as double or when the native type of the key is double.

Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as long or when the native type of the key is long.

Get the number of distinct values of the key in argument contained in the index. The key must belong to the index.

Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as string or when the native type of the key is string.

Create a new index based on a set of keys.

Create a new index form a file. The file is indexed with the keys in argument.

Select the message subset with key==value. The value is a double. The key must have been created with double type or have double as native type if the type was not explicitly defined in the index creation.

Select the message subset with key==value. The value is a long. The key must have been created with long type or have long as native type if the type was not explicitly defined in the index creation.

Select the message subset with key==value. The value is a string. The key must have been created with string type or have string as native type if the type was not explicitly defined in the index creation.

Delete the keys iterator. @param kiter : valid codes_keys_iterator @return 0 if OK, integer value on error

get the key name from the keys iterator @param kiter : valid codes_keys_iterator @return key name

\defgroup keys_iterator Iterating on keys names The keys iterator is designed to get the key names defined in a message. Key names on which the iteration is carried out can be filtered through their attributes or by the namespace they belong to. @param h : the handle whose keys you want to iterate @param filter_flags : flags to filter out some of the keys through their attributes @param name_space : if not null the iteration is carried out only on keys belonging to the namespace passed. (NULL for all the keys) @return keys iterator ready to iterate through keys according to filter_flags and namespace

Step to the next item from the keys iterator. @param kiter : valid codes_keys_iterator @return 1 if next iterator exists, 0 if no more elements to iterate on

Rewind the keys iterator. @param kiter : valid codes_keys_iterator @return 0 if OK, integer value on error

Prints the API version

Set a bytes array from a key. If several keys of the same name are present, the last one is set @see codes_get_bytes

Set a double value from a key. If several keys of the same name are present, the last one is set @see codes_get_double

Set a double array from a key. If several keys of the same name are present, the last one is set @see codes_get_double_array

Same as codes_set_double_array but allows setting of READ-ONLY keys like codedValues. Use with great caution!!

Set a long value from a key. If several keys of the same name are present, the last one is set @see codes_get_long

Set a long array from a key. If several keys of the same name are present, the last one is set @see codes_get_long_array

Set a string value from a key. If several keys of the same name are present, the last one is set @see codes_get_string

Set a string array from a key. If several keys of the same name are present, the last one is set @see codes_get_long_array

Write a coded message to a file.

Frees the cached definition files of the context

Get the static default context

Sets memory procedures of the context for large buffers

Sets the search path for definition files.

Sets the context logging procedure used for system (warning, errors, infos …) messages

Sets memory procedures of the context

Sets memory procedures of the context for persistent data

Sets the context printing procedure used for user interaction

Sets the search path for sample files.

Copy the keys belonging to a given namespace from a source handle to a destination handle

\defgroup grib_handle The grib_handle The grib_handle is the structure giving access to parsed grib values by keys. Counts the messages contained in a file resource.

Counts the messages contained in a file.

Print all keys from the parsed definition files available in a context

Print all keys, with the context print procedure and dump mode to a resource

Get the API version

Get raw bytes values from a key. If several keys of the same name are present, the last one is returned @see grib_set_bytes

Get latitude/longitude and data values. The Latitudes, longitudes and values arrays must be properly allocated by the caller. Their required dimension can be obtained by getting the value of the integer key “numberOfPoints”.

Get a double value from a key, if several keys of the same name are present, the last one is returned @see grib_set_double

Get double array values from a key. If several keys of the same name are present, the last one is returned @see grib_set_double_array

Get as double the i-th element of the “key” array

Get as double array the elements of the “key” array whose indexes are listed in the input array i

Convert an error code into a string @param code : the error code @return the error message

Get the Git version control SHA1 identifier

Get the GRIBEX mode.

Get the length of the string representation of the key, if several keys of the same name are present, the maximum length is returned

Get a long value from a key, if several keys of the same name are present, the last one is returned @see grib_set_long

Get long array values from a key. If several keys of the same name are present, the last one is returned @see grib_set_long_array

\defgroup handling_coded_messages Handling coded messages */ getting the message attached to a handle

getting a copy of the message attached to a handle

\defgroup get_set Accessing header and data values */ Get the number offset of a key, in a message if several keys of the same name are present, the offset of the last one is returned

Get the package name

Get the number of coded value from a key, if several keys of the same name are present, the total sum is returned

Get a string value from a key, if several keys of the same name are present, the last one is returned @see grib_set_string

Get string array values from a key. If several keys of the same name are present, the last one is returned @see grib_set_string_array

Set the GRIBEX mode off. GRIB files won’t be always compatible with GRIBEX.

Set the GRIBEX mode on. Grib files will be compatible with GRIBEX.

Set the GTS header mode off. The GTS headers will be deleted.

Set the GTS header mode on. The GTS headers will be preserved.

Clone an existing handle using the context of the original handle, The message is copied and reparsed

Frees a handle, also frees the message if it is not a user message @see grib_handle_new_from_message @param h : The handle to be deleted @return 0 if OK, integer value on error

Create a handle from a file resource. The file is read until a message is found. The message is then copied. Remember always to delete the handle when it is not needed anymore to avoid memory leaks.

Create a new handle from an index after having selected the key values. All the keys belonging to the index must be selected before calling this function. Successive calls to this function will return all the handles compatible with the constraints defined selecting the values of the index keys. When no more handles are available from the index a NULL pointer is returned and the err variable is set to GRIB_END_OF_INDEX.

Create a handle from a user message in memory. The message will not be freed at the end. The message will be copied as soon as a modification is needed.

Create a handle from a user message. The message is copied and will be freed with the handle

Create a handle from a user message in memory. The message will not be freed at the end. The message will be copied as soon as a modification is needed. This function works also with multi-field messages. Note: The data pointer argument may be modified

Create a handle from a GRIB message contained in the samples directory. The message is copied at the creation of the handle

Indexes the file given in argument in the index given in argument.

Delete the index.

Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as double or when the native type of the key is double.

Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as long or when the native type of the key is long.

Get the number of distinct values of the key in argument contained in the index. The key must belong to the index.

Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as string or when the native type of the key is string.

Create a new index based on a set of keys.

Create a new index form a file. The file is indexed with the keys in argument.

Select the message subset with key==value. The value is a double. The key must have been created with double type or have double as native type if the type was not explicitly defined in the index creation.

Select the message subset with key==value. The value is a long. The key must have been created with long type or have long as native type if the type was not explicitly defined in the index creation.

Select the message subset with key==value. The value is a string. The key must have been created with string type or have string as native type if the type was not explicitly defined in the index creation.

Frees a geoiterator from memory

Test procedure for values in a geoiterator.

\brief Create a new geoiterator from a handle, using current geometry and values.

Get the next value from a geoiterator.

Get the previous value from a geoiterator.

Test procedure for values in a geoiterator.

Delete the iterator. @param kiter : valid grib_keys_iterator @return 0 if OK, integer value on error

get the key name from the iterator @param kiter : valid grib_keys_iterator @return key name

\defgroup keys_iterator Iterating on keys names The keys iterator is designed to get the key names defined in a message. Key names on which the iteration is carried out can be filtered through their attributes or by the namespace they belong to. @param h : the handle whose keys you want to iterate @param filter_flags : flags to filter out some of the keys through their attributes @param name_space : if not null the iteration is carried out only on keys belonging to the namespace passed. (NULL for all the keys) @return keys iterator ready to iterate through keys according to filter_flags and namespace

Step to the next iterator. @param kiter : valid grib_keys_iterator @return 1 if next iterator exists, 0 if no more elements to iterate on

Rewind the iterator. @param kiter : valid grib_keys_iterator @return 0 if OK, integer value on error

Append the sections starting with start_section of the message pointed by h at the end of the multi-field handle mh. Remember always to delete the multi handle when it is not needed anymore to avoid memory leaks.

Delete multi-field handle.

Create an empty multi-field handle. Remember always to delete the multi handle when it is not needed anymore to avoid memory leaks.

Write a multi-field handle in a file. Remember to delete the multi handle when it is not needed anymore to avoid memory leaks.

Turn off support for multi-fields in single GRIB messages

Turn on support for multi-fields in single GRIB messages

Reset file handle in multi-field support mode

Frees a nearest neighbour object from memory

Find the 4 nearest points of a latitude longitude point. The flags are provided to speed up the process of searching. If you are sure that the point you are asking for is not changing from a call to another you can use GRIB_NEAREST_SAME_POINT. The same is valid for the grid. Flags can be used together doing a bitwise OR. The distances are given in kilometres.

Find the nearest point of a set of points whose latitudes and longitudes are given in the inlats, inlons arrays respectively. If the flag is_lsm is 1 the nearest land point is returned and the GRIB passed as handle (h) is considered a land sea mask. The land nearest point is the nearest point with land sea mask value>=0.5. If no nearest land points are found the nearest value is returned. If the flag is_lsm is 0 the nearest point is returned. values, distances, indexes (in the “values” array) for the nearest points (ilons,ilats) are returned. The distances are given in kilometres.

\brief Create a new nearest neighbour object from a handle, using current geometry.

Prints the API version

Set a bytes array from a key. If several keys of the same name are present, the last one is set @see grib_get_bytes

Set a double value from a key. If several keys of the same name are present, the last one is set @see grib_get_double

Set a double array from a key. If several keys of the same name are present, the last one is set @see grib_get_double_array

Same as grib_set_double_array but allows setting of READ-ONLY keys like codedValues. Use with great caution!!

Set a long value from a key. If several keys of the same name are present, the last one is set @see grib_get_long

Set a long array from a key. If several keys of the same name are present, the last one is set @see grib_get_long_array

Set a string value from a key. If several keys of the same name are present, the last one is set @see grib_get_string

Set a string array from a key. If several keys of the same name are present, the last one is set @see grib_get_string_array

Write a coded message in a file.

Type Definitions

Codes context, structure containing the memory methods, the parsers and the formats. \ingroup codes_context \struct codes_context

Codes handle, structure giving access to parsed values by keys \ingroup codes_handle \struct codes_handle

index structure to access messages in a file. \ingroup codes_index \struct codes_index

GRIB geoiterator, structure supporting a geographic iteration of values in a GRIB message. \ingroup iterators \struct codes_iterator

Codes keys iterator. Iterator over keys. \ingroup keys_iterator \struct codes_keys_iterator

GRIB multi-field handle, structure used to build multi-field messages. \ingroup codes_handle \struct codes_multi_handle

Codes nearest, structure used to find the nearest points of a latitude longitude point in a GRIB message. \ingroup iterators \struct codes_nearest

Grib data eof, format of a procedure referenced in the context that is used to test end of file

Grib data read proc, format of a procedure referenced in the context that is used to read from a stream in a resource

Grib data seek, format of a procedure referenced in the context that is used to seek the current position in a stream

Grib data tell, format of a procedure referenced in the context that is used to tell the current position in a stream

Grib data read write, format of a procedure referenced in the context that is used to write to a stream from a resource

\defgroup context The context object The context is a long life configuration object of the grib_api. It is used to define special allocation and free routines or to set special grib_api behaviours and variables. Grib free procedure, format of a procedure referenced in the context that is used to free memory

Grib loc proc, format of a procedure referenced in the context that is used to log internal messages

Grib malloc procedure, format of a procedure referenced in the context that is used to allocate memory @param c : the context where the memory allocation will apply @param length : length to be allocated in number of bytes @return a pointer to the allocated memory, NULL if no memory can be allocated must match @see grib_free_proc

Grib print proc, format of a procedure referenced in the context that is used to print external messages

Grib realloc procedure, format of a procedure referenced in the context that is used to reallocate memory @param c : the context where the memory allocation will apply @param data : pointer to the data to be reallocated @param length : length to be allocated in number of bytes @return a pointer to the allocated memory

Unions