/usr/include/grib_api.h is in libgrib-api-dev 1.14.4-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 | /*
* Copyright 2005-2015 ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/*! \file grib_api.h
\brief grib_api C header file
This is the only file that must be included to use the grib_api library
from C.
*/
#ifndef grib_api_H
#define grib_api_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
/* Microsoft Windows Visual Studio support */
#include "grib_api_windef.h"
#ifndef GRIB_ON_WINDOWS
#include <sys/time.h>
#endif
#include <math.h>
#if defined( __GNUC__) || defined(__clang__)
#define DEPRECATED __attribute__((deprecated))
#else
#define DEPRECATED
#endif
#include "grib_api_version.h"
/* sections */
#define GRIB_SECTION_PRODUCT (1<<0)
#define GRIB_SECTION_GRID (1<<1)
#define GRIB_SECTION_LOCAL (1<<2)
#define GRIB_SECTION_DATA (1<<3)
#define GRIB_SECTION_BITMAP (1<<4)
/* LOG MODES
Log mode for information for processing information
*/
/* Log mode for info */
#define GRIB_LOG_INFO 0
/* Log mode for warnings */
#define GRIB_LOG_WARNING 1
/* Log mode for errors */
#define GRIB_LOG_ERROR 2
/* Log mode for fatal errors */
#define GRIB_LOG_FATAL 3
/* Log mode for debug */
#define GRIB_LOG_DEBUG 4
/* Types */
/* undefined */
#define GRIB_TYPE_UNDEFINED 0
/* long integer */
#define GRIB_TYPE_LONG 1
/* double */
#define GRIB_TYPE_DOUBLE 2
/* char* */
#define GRIB_TYPE_STRING 3
/* bytes */
#define GRIB_TYPE_BYTES 4
/* section */
#define GRIB_TYPE_SECTION 5
/* label */
#define GRIB_TYPE_LABEL 6
/* missing */
#define GRIB_TYPE_MISSING 7
/* Missing values */
/* #define GRIB_MISSING_LONG 0x80000001*/
#define GRIB_MISSING_LONG 0xffffffff
#define GRIB_MISSING_DOUBLE -1e+100
/*set spec flags*/
#define GRIB_UTIL_SET_SPEC_FLAGS_ONLY_PACKING (1<<0)
/* Dump option flags*/
#define GRIB_DUMP_FLAG_READ_ONLY (1<<0)
#define GRIB_DUMP_FLAG_DUMP_OK (1<<1)
#define GRIB_DUMP_FLAG_VALUES (1<<2)
#define GRIB_DUMP_FLAG_CODED (1<<3)
#define GRIB_DUMP_FLAG_OCTECT (1<<4)
#define GRIB_DUMP_FLAG_ALIASES (1<<5)
#define GRIB_DUMP_FLAG_TYPE (1<<6)
#define GRIB_DUMP_FLAG_HEXADECIMAL (1<<7)
#define GRIB_DUMP_FLAG_NO_DATA (1<<8)
#define GRIB_DUMP_FLAG_ALL_DATA (1<<9)
/* grib_nearest flags */
#define GRIB_NEAREST_SAME_GRID (1<<0)
#define GRIB_NEAREST_SAME_DATA (1<<1)
#define GRIB_NEAREST_SAME_POINT (1<<2)
/*! Iteration is carried out on all the keys available in the message
\ingroup keys_iterator
\see grib_keys_iterator_new
*/
#define GRIB_KEYS_ITERATOR_ALL_KEYS 0
/*! read only keys are skipped by keys iterator.
\ingroup keys_iterator
\see grib_keys_iterator_new
*/
#define GRIB_KEYS_ITERATOR_SKIP_READ_ONLY (1<<0)
/*! optional keys are skipped by keys iterator.
\ingroup keys_iterator
\see grib_keys_iterator_new */
#define GRIB_KEYS_ITERATOR_SKIP_OPTIONAL (1<<1)
/*! edition specific keys are skipped by keys iterator.
\ingroup keys_iterator
\see grib_keys_iterator_new */
#define GRIB_KEYS_ITERATOR_SKIP_EDITION_SPECIFIC (1<<2)
/*! coded keys are skipped by keys iterator.
\ingroup keys_iterator
\see grib_keys_iterator_new */
#define GRIB_KEYS_ITERATOR_SKIP_CODED (1<<3)
/*! computed keys are skipped by keys iterator.
\ingroup keys_iterator
\see grib_keys_iterator_new */
#define GRIB_KEYS_ITERATOR_SKIP_COMPUTED (1<<4)
/*! duplicates of a key are skipped by keys iterator.
\ingroup keys_iterator
\see grib_keys_iterator_new */
#define GRIB_KEYS_ITERATOR_SKIP_DUPLICATES (1<<5)
/*! function keys are skipped by keys iterator.
\ingroup keys_iterator
\see grib_keys_iterator_new */
#define GRIB_KEYS_ITERATOR_SKIP_FUNCTION (1<<6)
typedef struct grib_key_value_list grib_key_value_list;
typedef struct grib_values grib_values;
struct grib_values {
const char* name;
int type;
long long_value;
double double_value;
const char* string_value;
int error;
int has_value;
int equal;
grib_values* next;
} ;
/*! Grib handle, structure giving access to parsed grib values by keys
\ingroup grib_handle
*/
typedef struct grib_handle grib_handle;
/*! Grib multi field handle, structure used to build multi fields messages.
\ingroup grib_handle
*/
typedef struct grib_multi_handle grib_multi_handle;
/*! Grib context, structure containing the memory methods, the parsers and the formats.
\ingroup grib_context
*/
typedef struct grib_context grib_context;
/*! Grib iterator, structure supporting a geographic iteration of values on a grib message.
\ingroup grib_iterator
*/
typedef struct grib_iterator grib_iterator;
/*! Grib nearest, structure used to find the nearest points of a latitude longitude point.
\ingroup grib_iterator
*/
typedef struct grib_nearest grib_nearest;
/*! Grib box, structure used to crop a box given north/west/south/east boundaries.
\ingroup grib_box
*/
typedef struct grib_box grib_box;
typedef struct grib_points grib_points;
/*! Grib keys iterator. Iterator over keys.
\ingroup keys_iterator
*/
typedef struct grib_keys_iterator grib_keys_iterator;
typedef struct grib_fieldset grib_fieldset;
typedef struct grib_order_by grib_order_by;
typedef struct grib_where grib_where;
typedef struct grib_darray grib_darray;
typedef struct grib_iarray grib_iarray;
grib_fieldset *grib_fieldset_new_from_files(grib_context *c, char *filenames[], int nfiles, char **keys, int nkeys, char *where_string, char *order_by_string, int *err);
void grib_fieldset_delete(grib_fieldset* set);
void grib_fieldset_rewind(grib_fieldset* set);
int grib_fieldset_apply_order_by(grib_fieldset* set,const char* order_by_string);
grib_handle* grib_fieldset_next_handle(grib_fieldset* set,int* err);
int grib_fieldset_count(grib_fieldset *set);
int grib_values_check(grib_handle* h, grib_values* values, int count);
/*! \defgroup grib_index The grib_index
The grib_index is the structure giving indexed access to messages in a file.
*/
/*! @{*/
/*! index structure to access messages in a file.
*/
typedef struct grib_index grib_index;
/**
* Create a new index form a file. The file is indexed with the keys in argument.
*
* @param c : context (NULL for default context)
* @param filename : name of the file of messages to be indexed
* @param keys : comma separated list of keys for the index.
* The type of the key can be explicitly declared appending :l for long,
* :d for double, :s for string to the key name. If the type is not
* declared explicitly, the native type is assumed.
* @param err : 0 if OK, integer value on error
* @return the newly created index
*/
grib_index* grib_index_new_from_file(grib_context* c,
char* filename,const char* keys,int *err);
/**
* Create a new index based on a set of keys.
*
* @param c : context (NULL for default context)
* @param keys : comma separated list of keys for the index.
* The type of the key can be explicitly declared appending :l for long,
* :d for double, :s for string to the key name. If the type is not
* declared explicitly, the native type is assumed.
* @param err : 0 if OK, integer value on error
* @return the newly created index
*/
grib_index* grib_index_new(grib_context* c, const char* keys,int *err);
/**
* Indexes the file given in argument in the index given in argument.
*
* @param index : index
* @param filename : name of the file of messages to be indexed
* @return 0 if OK, integer value on error
*/
int grib_index_add_file(grib_index *index, const char *filename);
int grib_index_write(grib_index *index, const char *filename);
grib_index* grib_index_read(grib_context* c,const char* filename,int *err);
/**
* Get the number of distinct values of the key in argument contained in the index. The key must belong to the index.
*
* @param index : an index created from a file.
* The index must have been created with the key in argument.
* @param key : key for which the number of values is computed
* @param size : number of distinct values of the key in the index
* @return 0 if OK, integer value on error
*/
int grib_index_get_size(grib_index* index,const char* key,size_t* size);
/**
* 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.
*
* @param index : an index created from a file.
* The index must have been created with the key in argument.
* @param key : key for which the values are returned
* @param values : array of values. The array must be allocated before entering this function and its size must be enough to contain all the values.
* @param size : size of the values array
* @return 0 if OK, integer value on error
*/
int grib_index_get_long(grib_index* index,const char* key,
long* values,size_t *size);
/**
* 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.
*
* @param index : an index created from a file.
* The index must have been created with the key in argument.
* @param key : key for which the values are returned
* @param values : array of values. The array must be allocated before entering this function and its size must be enough to contain all the values.
* @param size : size of the values array
* @return 0 if OK, integer value on error
*/
int grib_index_get_double(grib_index* index,const char* key,
double* values,size_t *size);
/**
* 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.
*
* @param index : an index created from a file.
* The index must have been created with the key in argument.
* @param key : key for which the values are returned
* @param values : array of values. The array must be allocated before entering this function and its size must be enough to contain all the values.
* @param size : size of the values array
* @return 0 if OK, integer value on error
*/
int grib_index_get_string(grib_index* index,const char* key,
char** values,size_t *size);
/**
* 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.
*
* @param index : an index created from a file.
* The index must have been created with the key in argument.
* @param key : key to be selected
* @param value : value of the key to select
* @return 0 if OK, integer value on error
*/
int grib_index_select_long(grib_index* index,const char* key,long value);
/**
* 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.
*
* @param index : an index created from a file.
* The index must have been created with the key in argument.
* @param key : key to be selected
* @param value : value of the key to select
* @return 0 if OK, integer value on error
*/
int grib_index_select_double(grib_index* index,const char* key,double value);
/**
* 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.
*
* @param index : an index created from a file.
* The index must have been created with the key in argument.
* @param key : key to be selected
* @param value : value of the key to select
* @return 0 if OK, integer value on error
*/
int grib_index_select_string(grib_index* index,const char* key,char* value);
/**
* 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.
*
* @param index : an index created from a file.
* @param err : 0 if OK, integer value on error. GRIB_END_OF_INDEX when no more handles are contained in the index.
* @return grib handle.
*/
grib_handle* grib_handle_new_from_index(grib_index* index,int *err);
/**
* Delete the index.
*
* @param index : index to be deleted.
*/
void grib_index_delete(grib_index* index);
/*! @} */
/*! \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.
*
* @param c : the context from which the handle will be created (NULL for default context)
* @param f : the file resource
* @param n : the number of messages in the file
* @return 0 if OK, integer value on error
*/
int grib_count_in_file(grib_context* c, FILE* f,int* n);
/**
* 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.
*
* @param c : the context from which the handle will be created (NULL for default context)
* @param f : the file resource
* @param error : error code set if the returned handle is NULL and the end of file is not reached
* @return the new handle, NULL if the resource is invalid or a problem is encountered
*/
grib_handle* grib_handle_new_from_file(grib_context* c, FILE* f, int* error);
/**
* Write a coded message in a file.
*
* @param h : grib_handle to be written
* @param file : name of the file
* @param mode : mode
* @return 0 if OK, integer value on error
*/
int grib_write_message(grib_handle* h,const char* file,const char* mode);
typedef struct grib_string_list grib_string_list;
struct grib_string_list {
char* value;
grib_string_list* next;
};
grib_handle* grib_util_sections_copy(grib_handle* hfrom,grib_handle* hto,int what,int *err);
grib_string_list* grib_util_get_param_id(const char* mars_param);
grib_string_list* grib_util_get_mars_param(const char* param_id);
/**
* 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.
*
* @param c : the context from which the handle will be created (NULL for default context)
* @param data : the actual message
* @param data_len : the length of the message in number of bytes
* @return the new handle, NULL if the message is invalid or a problem is encountered
*/
grib_handle* grib_handle_new_from_message(grib_context* c, void* data, size_t data_len);
/**
* 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.
*
* @param c : the context from which the handle will be created (NULL for default context)
* @param data : the actual message
* @param data_len : the length of the message in number of bytes
* @param error : error code
* @return the new handle, NULL if the message is invalid or a problem is encountered
*/
grib_handle* grib_handle_new_from_multi_message(grib_context* c,void** data,
size_t *data_len,int* error);
/**
* Create a handle from a user message. The message is copied and will be freed with the handle
*
* @param c : the context from which the handle will be created (NULL for default context)
* @param data : the actual message
* @param data_len : the length of the message in number of bytes
* @return the new handle, NULL if the message is invalid or a problem is encountered
*/
grib_handle* grib_handle_new_from_message_copy(grib_context* c, const void* data, size_t data_len);
/**
* Create a handle from a read_only template resource.
* The message is copied at the creation of the handle
* This function is deprecated: please use grib_handle_new_from_samples
*
* @param c : the context from which the handle will be created (NULL for default context)
* @param res_name : the resource name
* @return the new handle, NULL if the resource is invalid or a problem is encountered
*/
DEPRECATED grib_handle* grib_handle_new_from_template (grib_context* c, const char* res_name) ;
/**
* Create a handle from a message contained in a samples directory.
* The message is copied at the creation of the handle
*
* @param c : the context from which the handle will be created (NULL for default context)
* @param res_name : the resource name
* @return the new handle, NULL if the resource is invalid or a problem is encountered
*/
grib_handle* grib_handle_new_from_samples (grib_context* c, const char* res_name) ;
/**
* Clone an existing handle using the context of the original handle,
* The message is copied and reparsed
*
* @param h : The handle to be cloned
* @return the new handle, NULL if the message is invalid or a problem is encountered
*/
grib_handle* grib_handle_clone (grib_handle* h) ;
/**
* 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
*/
int grib_handle_delete (grib_handle* h);
/**
* Create an empty multi field handle.
* Remember always to delete the multi handle when it is not needed anymore to avoid
* memory leaks.
*
* @param c : the context from which the handle will be created (NULL for default context)
*/
grib_multi_handle* grib_multi_handle_new (grib_context* c);
/**
* 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.
*
* @param h : The handle from which the sections are copied.
* @param start_section : section number. Starting from this section all the sections to the end of the message will be copied.
* @param mh : The multi field handle on which the sections are appended.
* @return 0 if OK, integer value on error
*/
int grib_multi_handle_append(grib_handle* h,int start_section,grib_multi_handle* mh);
/**
* Delete multi field handle.
*
* @param mh : The multi field handle to be deleted.
* @return 0 if OK, integer value on error
*/
int grib_multi_handle_delete(grib_multi_handle* mh);
/**
* Write a multi field handle in a file.
* Remember always to delete the multi handle when it is not needed anymore to avoid
* memory leaks.
*
* @param mh : The multi field handle to be written.
* @param f : File on which the file handle is written.
* @return 0 if OK, integer value on error
*/
int grib_multi_handle_write(grib_multi_handle* mh,FILE* f);
/*! @} */
/*! \defgroup handling_coded_messages Handling coded messages */
/*! @{ */
/**
* getting the message attached to a handle
*
* @param h : the grib handle to which the buffer should be gathered
* @param message : the pointer to be set to the handle's data
* @param message_length : On exit, the message size in number of bytes
* @return 0 if OK, integer value on error
*/
int grib_get_message(grib_handle* h ,const void** message, size_t *message_length);
/**
* getting a copy of the message attached to a handle
*
* @param h : the grib handle to which the buffer should be returned
* @param message : the pointer to the data buffer to be filled
* @param message_length : On entry, the size in number of bytes of the allocated empty message.
* On exit, the actual message length in number of bytes
* @return 0 if OK, integer value on error
*/
int grib_get_message_copy(grib_handle* h , void* message,size_t *message_length);
/*! @} */
/*! \defgroup iterators Iterating on latitude/longitude/values */
/*! @{ */
/*!
* \brief Create a new iterator from a handle, using current geometry and values.
*
* \param h : the handle from which the iterator will be created
* \param flags : flags for future use.
* \param error : error code
* \return the new iterator, NULL if no iterator can be created
*/
grib_iterator* grib_iterator_new (grib_handle* h, unsigned long flags,int* error);
/**
* 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".
*
* @param h : handle from which geography and data values are taken
* @param lats : returned array of latitudes
* @param lons : returned array of longitudes
* @param values : returned array of data values
* @return 0 if OK, integer value on error
*/
int grib_get_data(grib_handle *h, double *lats, double *lons, double *values, size_t *size);
/**
* Get the next value from an iterator.
*
* @param i : the iterator
* @param lat : on output latitude in degree
* @param lon : on output longitude in degree
* @param value : on output value of the point
* @return positive value if successful, 0 if no more data are available
*/
int grib_iterator_next (grib_iterator *i, double* lat,double* lon,double* value);
/**
* Get the previous value from an iterator.
*
* @param i : the iterator
* @param lat : on output latitude in degree
* @param lon : on output longitude in degree
* @param value : on output value of the point*
* @return positive value if successful, 0 if no more data are available
*/
int grib_iterator_previous (grib_iterator *i, double* lat,double* lon,double* value);
/**
* Test procedure for values in an iterator.
*
* @param i : the iterator
* @return boolean, 1 if the iterator still nave next values, 0 otherwise
*/
int grib_iterator_has_next (grib_iterator *i);
/**
* Test procedure for values in an iterator.
*
* @param i : the iterator
* @return 0 if OK, integer value on error
*/
int grib_iterator_reset (grib_iterator *i);
/**
* Frees an iterator from memory
*
* @param i : the iterator
* @return 0 if OK, integer value on error
*/
int grib_iterator_delete (grib_iterator *i);
/*!
* \brief Create a new nearest from a handle, using current geometry .
*
* \param h : the handle from which the iterator will be created
* \param error : error code
* \return the new nearest, NULL if no nearest can be created
*/
grib_nearest* grib_nearest_new (grib_handle* h, int* error);
/**
* 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.
*
* @param nearest : nearest structure
* @param h : handle from which geography and data values are taken
* @param inlat : latitude of the point to search for
* @param inlon : longitude of the point to search for
* @param flags : GRIB_NEAREST_SAME_POINT, GRIB_NEAREST_SAME_GRID
* @param outlats : returned array of latitudes of the nearest points
* @param outlons : returned array of longitudes of the nearest points
* @param values : returned array of data values of the nearest points
* @param distances : returned array of distances from the nearest points
* @param indexes : returned array of indexes of the nearest points
* @param len : size of the arrays
* @return 0 if OK, integer value on error
*/
int grib_nearest_find(grib_nearest *nearest,grib_handle* h,double inlat,double inlon,
unsigned long flags,double* outlats,double* outlons,
double* values,double* distances,int* indexes,size_t *len);
/**
* Frees an nearest from memory
*
* @param nearest : the nearest
* @return 0 if OK, integer value on error
*/
int grib_nearest_delete (grib_nearest *nearest);
/**
* 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.
*
* @param h : handle from which geography and data values are taken
* @param is_lsm : lsm flag (1-> nearest land, 0-> nearest)
* @param inlats : latitudes of the points to search for
* @param inlons : longitudes of the points to search for
* @param npoints : number of points (size of the inlats,inlons,outlats,outlons,values,distances,indexes arrays)
* @param outlats : returned array of latitudes of the nearest points
* @param outlons : returned array of longitudes of the nearest points
* @param values : returned array of data values of the nearest points
* @param distances : returned array of distances from the nearest points
* @param indexes : returned array of indexes of the nearest points
* @return 0 if OK, integer value on error
*/
int grib_nearest_find_multiple(grib_handle* h,int is_lsm,
double* inlats,double* inlons,long npoints,
double* outlats,double* outlons,
double* values,double* distances, int* indexes);
/* @} */
/*! \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
*
* @param h : the handle to get the offset from
* @param key : the key to be searched
* @param offset : the address of a size_t where the offset will be set
* @return 0 if OK, integer value on error
*/
int grib_get_offset(grib_handle* h, const char* key, size_t* offset);
/**
* Get the number of coded value from a key, if several keys of the same name are present, the total sum is returned
*
* @param h : the handle to get the offset from
* @param key : the key to be searched
* @param size : the address of a size_t where the size will be set
* @return 0 if OK, integer value on error
*/
int grib_get_size(grib_handle* h, const char* key,size_t *size);
/**
* Get the length of the string representation of the key, if several keys of the same name are present, the maximum length is returned
*
* @param h : the handle to get the offset from
* @param key : the key to be searched
* @param length : the address of a size_t where the length will be set
* @return 0 if OK, integer value on error
*/
int grib_get_length(grib_handle* h, const char* key,size_t *length);
/**
* 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
*
* @param h : the handle to get the data from
* @param key : the key to be searched
* @param value : the address of a long where the data will be retrieved
* @return 0 if OK, integer value on error
*/
int grib_get_long (grib_handle* h, const char* key, long* value);
/**
* 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
*
* @param h : the handle to get the data from
* @param key : the key to be searched
* @param value : the address of a double where the data will be retrieved
* @return 0 if OK, integer value on error
*/
int grib_get_double (grib_handle* h, const char* key, double* value);
/**
* Get as double the i-th element of the "key" array
*
* @param h : the handle to get the data from
* @param key : the key to be searched
* @param i : zero based index
* @param value : the address of a double where the data will be retrieved
* @return 0 if OK, integer value on error
*/
int grib_get_double_element(grib_handle* h, const char* key, int i, double* value);
/**
* Get as double array the elements of the "key" array whose indexes are listed in the input array i
*
* @param h : the handle to get the data from
* @param key : the key to be searched
* @param i : zero based array of indexes
* @param size : size of the i and value arrays
* @param value : the address of a double where the data will be retrieved
* @return 0 if OK, integer value on error
*/
int grib_get_double_elements(grib_handle* h, const char* key, int* i, long size,double* value);
/**
* 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
*
* @param h : the handle to get the data from
* @param key : the key to be searched
* @param mesg : the address of a string where the data will be retrieved
* @param length : the address of a size_t that contains allocated length of the string on input, and that contains the actual length of the string on output
* @return 0 if OK, integer value on error
*/
int grib_get_string (grib_handle* h, const char* key, char* mesg, size_t *length);
/**
* 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
*
* @param h : the handle to get the data from
* @param key : the key to be searched
* @param bytes : the address of a byte array where the data will be retrieved
* @param length : the address of a size_t that contains allocated length of the byte array on input, and that contains the actual length of the byte array on output
* @return 0 if OK, integer value on error
*/
int grib_get_bytes (grib_handle* h, const char* key, unsigned char* bytes, size_t *length);
/**
* 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
*
* @param h : the handle to get the data from
* @param key : the key to be searched
* @param vals : the address of a double array where the data will be retrieved
* @param length : the address of a size_t that contains allocated length of the double array on input, and that contains the actual length of the double array on output
* @return 0 if OK, integer value on error
*/
int grib_get_double_array (grib_handle* h, const char* key, double* vals, size_t *length);
/**
* 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
*
* @param h : the handle to get the data from
* @param key : the key to be searched
* @param vals : the address of a long array where the data will be retrieved
* @param length : the address of a size_t that contains allocated length of the long array on input, and that contains the actual length of the long array on output
* @return 0 if OK, integer value on error
*/
int grib_get_long_array (grib_handle* h, const char* key, long* vals, size_t *length);
/* setting data */
/**
* Copy the keys belonging to a given namespace from a source handle to a destination handle
*
*
* @param dest : destination handle
* @param name : namespace
* @param src : source handle
* @return 0 if OK, integer value on error
*/
int grib_copy_namespace(grib_handle* dest, const char* name, grib_handle* src);
/**
* 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
*
* @param h : the handle to set the data to
* @param key : the key to be searched
* @param val : a long where the data will be read
* @return 0 if OK, integer value on error
*/
int grib_set_long (grib_handle* h, const char* key , long val);
/**
* 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
*
* @param h : the handle to set the data to
* @param key : the key to be searched
* @param val : a double where the data will be read
* @return 0 if OK, integer value on error
*/
int grib_set_double (grib_handle* h, const char* key , double val);
/**
* 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
*
* @param h : the handle to set the data to
* @param key : the key to be searched
* @param mesg : the address of a string where the data will be read
* @param length : the address of a size_t that contains the length of the string on input, and that contains the actual packed length of the string on output
* @return 0 if OK, integer value on error
*/
int grib_set_string (grib_handle* h, const char* key , const char* mesg, size_t *length);
/**
* 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
*
* @param h : the handle to set the data to
* @param key : the key to be searched
* @param bytes : the address of a byte array where the data will be read
* @param length : the address of a size_t that contains the length of the byte array on input, and that contains the actual packed length of the byte array on output
* @return 0 if OK, integer value on error
*/
int grib_set_bytes (grib_handle* h, const char* key, const unsigned char* bytes, size_t *length);
/**
* 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
*
* @param h : the handle to set the data to
* @param key : the key to be searched
* @param vals : the address of a double array where the data will be read
* @param length : a size_t that contains the length of the byte array on input
* @return 0 if OK, integer value on error
*/
int grib_set_double_array (grib_handle* h, const char* key , const double* vals , size_t length);
/**
* Same as grib_set_double_array but allows setting of READ-ONLY keys like codedValues.
* Use with great caution!!
*/
int grib_set_force_double_array(grib_handle* h, const char* key, const double* vals, size_t length);
/**
* 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
*
* @param h : the handle to set the data to
* @param key : the key to be searched
* @param vals : the address of a long array where the data will be read
* @param length : a size_t that contains the length of the long array on input
* @return 0 if OK, integer value on error
*/
int grib_set_long_array (grib_handle* h, const char* key , const long* vals , size_t length);
/*! @} */
/**
* Print all keys, with the context print procedure and dump mode to a resource
*
* @param h : the handle to be printed
* @param out : output file handle
* @param mode : available dump modes are: debug wmo c_code
* @param option_flags : all the GRIB_DUMP_FLAG_x flags can be used
* @param arg : used to provide a format to output data (experimental)
*/
void grib_dump_content(grib_handle* h,FILE* out,const char* mode, unsigned long option_flags,void* arg);
/**
* Print all keys from the parsed definition files available in a context
*
* @param f : the File used to print the keys on
* @param c : the context that contains the cached definition files to be printed
*/
void grib_dump_action_tree(grib_context* c, FILE* f) ;
/*! \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
*
* @param c : the context where the memory freeing will apply
* @param data : pointer to the data to be freed
* must match @see grib_malloc_proc
*/
typedef void (*grib_free_proc) (const grib_context* c, void* data);
/**
* 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
*/
typedef void* (*grib_malloc_proc) (const grib_context* c, size_t length);
/**
* 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
*/
typedef void* (*grib_realloc_proc) (const grib_context* c, void* data, size_t length);
/**
* Grib loc proc, format of a procedure referenced in the context that is used to log internal messages
*
* @param c : the context where the logging will apply
* @param level : the log level, as defined in log modes
* @param mesg : the message to be logged
*/
typedef void (*grib_log_proc) (const grib_context* c, int level, const char* mesg);
/**
* Grib print proc, format of a procedure referenced in the context that is used to print external messages
*
* @param c : the context where the logging will apply
* @param descriptor : the structure to be printed on, must match the implementation
* @param mesg : the message to be printed
*/
typedef void (*grib_print_proc) (const grib_context* c, void* descriptor, const char* mesg);
/**
* Grib data read proc, format of a procedure referenced in the context that is used to read from a stream in a resource
*
* @param c : the context where the read will apply
* @param *ptr : the resource
* @param size : size to read
* @param *stream : the stream
* @return size read
*/
typedef size_t (*grib_data_read_proc) (const grib_context* c,void *ptr, size_t size, void *stream);
/**
* Grib data read write, format of a procedure referenced in the context that is used to write to a stream from a resource
*
* @param c : the context where the write will apply
* @param *ptr : the resource
* @param size : size to read
* @param *stream : the stream
* @return size written
*/
typedef size_t (*grib_data_write_proc)(const grib_context* c,const void *ptr, size_t size, void *stream);
/**
* Grib data tell, format of a procedure referenced in the context that is used to tell the current position in a stream
*
* @param c : the context where the tell will apply
* @param *stream : the stream
* @return the position in the stream
*/
typedef off_t (*grib_data_tell_proc) (const grib_context* c, void *stream);
/**
* Grib data seek, format of a procedure referenced in the context that is used to seek the current position in a stream
*
* @param c : the context where the tell will apply
* @param offset : the offset to seek to
* @param whence : If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END,
the offset is relative to the start of the file,
the current position indicator, or end-of-file, respectively.
* @param *stream : the stream
* @return 0 if OK, integer value on error
*/
typedef off_t (*grib_data_seek_proc) (const grib_context* c, off_t offset, int whence, void *stream);
/**
* Grib data eof, format of a procedure referenced in the context that is used to test end of file
*
* @param c : the context where the tell will apply
* @param *stream : the stream
* @return the position in the stream
*/
typedef int (*grib_data_eof_proc) (const grib_context* c, void *stream);
/**
* Get the static default context
*
* @return the default context, NULL it the context is not available
*/
grib_context* grib_context_get_default(void);
/**
* Create and allocate a new context from a parent context.
*
* @param c : the context to be cloned, NULL for default context
* @return the new and empty context, NULL if error
*/
grib_context* grib_context_new (grib_context* c);
/**
* Frees the cached definition files of the context
*
* @param c : the context to be deleted
*/
void grib_context_delete (grib_context* c);
/**
* Set the GTS header mode on.
* The GTS headers will be preserved.
*
* @param c : the context
*/
void grib_gts_header_on(grib_context* c) ;
/**
* Set the GTS header mode off.
* The GTS headers will be deleted.
*
* @param c : the context
*/
void grib_gts_header_off(grib_context* c);
/**
* Set the GRIBEX mode on.
* Grib files will be compatible with GRIBEX.
*
* @param c : the context
*/
void grib_gribex_mode_on(grib_context* c);
/**
* Get the GRIBEX mode.
*
* @param c : the context
*/
int grib_get_gribex_mode ( grib_context* c);
/**
* Set the GRIBEX mode off.
* GRIB files won't be always compatible with GRIBEX.
*
* @param c : the context
*/
void grib_gribex_mode_off(grib_context* c);
/**
* Sets memory procedures of the context
*
* @param c : the context to be modified
* @param griballoc : the memory allocation procedure to be set @see grib_malloc_proc
* @param gribfree : the memory freeing procedure to be set @see grib_free_proc
*/
void grib_context_set_memory_proc(grib_context* c, grib_malloc_proc griballoc,
grib_free_proc gribfree,
grib_realloc_proc gribrealloc);
/**
* Sets memory procedures of the context for persistent data
*
* @param c : the context to be modified
* @param griballoc : the memory allocation procedure to be set @see grib_malloc_proc
* @param gribfree : the memory freeing procedure to be set @see grib_free_proc
*/
void grib_context_set_persistent_memory_proc(grib_context* c, grib_malloc_proc griballoc,
grib_free_proc gribfree);
/**
* Sets memory procedures of the context for large buffers
*
* @param c : the context to be modified
* @param griballoc : the memory allocation procedure to be set @see grib_malloc_proc
* @param gribfree : the memory freeing procedure to be set @see grib_free_proc
*/
void grib_context_set_buffer_memory_proc(grib_context* c, grib_malloc_proc griballoc,
grib_free_proc gribfree,
grib_realloc_proc gribrealloc);
/**
* Sets the context printing procedure used for user interaction
*
* @param c : the context to be modified
* @param printp : the printing procedure to be set @see grib_print_proc
*/
void grib_context_set_print_proc(grib_context* c, grib_print_proc printp);
/**
* Sets the context logging procedure used for system (warning, errors, infos ...) messages
*
* @param c : the context to be modified
* @param logp : the logging procedure to be set @see grib_log_proc
*/
void grib_context_set_logging_proc(grib_context* c, grib_log_proc logp);
/**
* Turn on support for multiple fields in single grib messages
*
* @param c : the context to be modified
*/
void grib_multi_support_on(grib_context* c);
/**
* Turn off support for multiple fields in single grib messages
*
* @param c : the context to be modified
*/
void grib_multi_support_off(grib_context* c);
/**
* Reset file handle in multiple field support mode
*
* @param c : the context to be modified
* @param f : the file pointer
*/
void grib_multi_support_reset_file(grib_context* c, FILE* f);
char* grib_samples_path(const grib_context *c);
/*! @} */
/**
* Get the API version
*
* @return API version
*/
long grib_get_api_version(void);
/**
* Get the Git version control SHA1 identifier
*
* @return character string with SHA1 identifier
*/
const char* grib_get_git_sha1(void);
/**
* Prints the API version
*
*
*/
void grib_print_api_version(FILE* out);
/*! \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.
*/
/*! @{ */
/*! Create a new iterator from a valid and initialised handle.
* @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
*/
grib_keys_iterator* grib_keys_iterator_new(grib_handle* h,unsigned long filter_flags, const char* name_space);
/*! 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
*/
int grib_keys_iterator_next(grib_keys_iterator *kiter);
/*! get the key name from the iterator
* @param kiter : valid grib_keys_iterator
* @return key name
*/
const char* grib_keys_iterator_get_name(grib_keys_iterator *kiter);
/*! Delete the iterator.
* @param kiter : valid grib_keys_iterator
* @return 0 if OK, integer value on error
*/
int grib_keys_iterator_delete( grib_keys_iterator* kiter);
/*! Rewind the iterator.
* @param kiter : valid grib_keys_iterator
* @return 0 if OK, integer value on error
*/
int grib_keys_iterator_rewind(grib_keys_iterator* kiter);
int grib_keys_iterator_set_flags(grib_keys_iterator *kiter,unsigned long flags);
int grib_keys_iterator_get_long(grib_keys_iterator *kiter, long *v, size_t *len);
int grib_keys_iterator_get_double(grib_keys_iterator *kiter, double *v, size_t *len);
int grib_keys_iterator_get_string(grib_keys_iterator *kiter, char *v, size_t *len);
int grib_keys_iterator_get_bytes(grib_keys_iterator *kiter, unsigned char *v, size_t *len);
/* @} */
void grib_update_sections_lengths(grib_handle* h);
/**
* Convert an error code into a string
* @param code : the error code
* @return the error message
*/
const char* grib_get_error_message(int code);
const char* grib_get_type_name(int type);
int grib_get_native_type(grib_handle* h, const char* name,int* type);
void grib_check(const char* call,const char* file,int line,int e,const char* msg);
#define GRIB_CHECK(a,msg) grib_check(#a,__FILE__,__LINE__,a,msg)
#define GRIB_CHECK_NOLINE(a,msg) grib_check(#a,0,0,a,msg)
int grib_set_values(grib_handle* h,grib_values* grib_values , size_t arg_count);
grib_handle* grib_handle_new_from_partial_message_copy(grib_context* c, const void* data, size_t size);
grib_handle* grib_handle_new_from_partial_message(grib_context* c,void* data, size_t buflen);
int grib_is_missing(grib_handle* h, const char* key, int* err);
int grib_is_defined(grib_handle* h, const char* key);
int grib_set_missing(grib_handle* h, const char* key);
/* The truncation is the Gaussian number (or order) */
int grib_get_gaussian_latitudes(long truncation,double* latitudes);
int grib_julian_to_datetime(double jd, long *year, long *month, long *day, long *hour, long *minute, long *second);
int grib_datetime_to_julian(long year, long month, long day, long hour, long minute, long second, double *jd);
long grib_julian_to_date(long jdate);
long grib_date_to_julian(long ddate);
void grib_get_reduced_row(long pl,double lon_first,double lon_last,long* npoints,long* ilon_first, long* ilon_last);
/* read products */
int wmo_read_any_from_file(FILE *f, void *buffer, size_t *len);
int wmo_read_grib_from_file(FILE* f,void* buffer,size_t* len);
int wmo_read_bufr_from_file(FILE* f,void* buffer,size_t* len);
int wmo_read_gts_from_file(FILE* f,void* buffer,size_t* len);
int wmo_read_any_from_stream(void *stream_data, long (*stream_proc )(void *, void *buffer, long len ), void *buffer, size_t *len);
void *wmo_read_any_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err);
void *wmo_read_gts_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err);
void *wmo_read_bufr_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err);
grib_handle* eccode_gts_new_from_file ( grib_context* c, FILE* f,int headers_only,int *error );
grib_handle* eccode_bufr_new_from_file ( grib_context* c, FILE* f,int headers_only,int *error );
grib_handle* eccode_grib_new_from_file ( grib_context* c, FILE* f,int headers_only,int *error );
int grib_get_message_offset ( grib_handle* h,off_t* offset);
int grib_get_message_size ( grib_handle* h,size_t* size);
struct grib_points {
grib_context* context;
double* latitudes;
double* longitudes;
size_t* indexes;
size_t* group_start;
size_t* group_len;
size_t n_groups;
size_t n;
size_t size;
};
grib_box* grib_box_new(grib_handle* h,int* error);
grib_points* grib_box_get_points(grib_box *box,double north, double west,double south,double east, int *err);
int grib_points_get_values(grib_handle* h, grib_points* points, double* val);
/* --------------------------------------- */
#define GRIB_UTIL_GRID_SPEC_REGULAR_LL 1
#define GRIB_UTIL_GRID_SPEC_ROTATED_LL 2
#define GRIB_UTIL_GRID_SPEC_REGULAR_GG 3
#define GRIB_UTIL_GRID_SPEC_ROTATED_GG 4
#define GRIB_UTIL_GRID_SPEC_REDUCED_GG 5
#define GRIB_UTIL_GRID_SPEC_SH 6
#define GRIB_UTIL_GRID_SPEC_REDUCED_LL 7
#define GRIB_UTIL_GRID_SPEC_POLAR_STEREOGRAPHIC 8
#define GRIB_UTIL_GRID_SPEC_REDUCED_ROTATED_GG 9
typedef struct grib_util_grid_spec {
int grid_type;
/* Grid */
long Ni;
long Nj;
double iDirectionIncrementInDegrees;
double jDirectionIncrementInDegrees;
double longitudeOfFirstGridPointInDegrees;
double longitudeOfLastGridPointInDegrees;
double latitudeOfFirstGridPointInDegrees;
double latitudeOfLastGridPointInDegrees;
/* Rotation */
long uvRelativeToGrid;
double latitudeOfSouthernPoleInDegrees;
double longitudeOfSouthernPoleInDegrees;
/* Scanning mode */
long iScansNegatively;
long jScansPositively;
/* Gaussian number */
long N;
/* bitmap */
long bitmapPresent;
double missingValue;
/* pl list for reduced */
const long *pl;
long pl_size;
/* Spherical harmonics */
long truncation;
/* polar stereographic */
double orientationOfTheGridInDegrees;
long DyInMetres;
long DxInMetres;
} grib_util_grid_spec;
#define GRIB_UTIL_PACKING_TYPE_SAME_AS_INPUT 0
#define GRIB_UTIL_PACKING_TYPE_SPECTRAL_COMPLEX 1
#define GRIB_UTIL_PACKING_TYPE_SPECTRAL_SIMPLE 2
#define GRIB_UTIL_PACKING_TYPE_JPEG 3
#define GRIB_UTIL_PACKING_TYPE_GRID_COMPLEX 4
#define GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE 5
#define GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX 6
#define GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER 7
#define GRIB_UTIL_PACKING_SAME_AS_INPUT 0
#define GRIB_UTIL_PACKING_USE_PROVIDED 1
#define GRIB_UTIL_ACCURACY_SAME_BITS_PER_VALUES_AS_INPUT 0
#define GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES 1
#define GRIB_UTIL_ACCURACY_SAME_DECIMAL_SCALE_FACTOR_AS_INPUT 2
#define GRIB_UTIL_ACCURACY_USE_PROVIDED_DECIMAL_SCALE_FACTOR 3
typedef struct grib_util_packing_spec {
/* Packing options */
long packing_type;
long packing;
long boustrophedonic;
long editionNumber; /* =0 for default value */
/* Accuracy */
long accuracy;
long bitsPerValue;
long decimalScaleFactor;
long computeLaplacianOperator;
int truncateLaplacian;
double laplacianOperator;
/* local definition */
long deleteLocalDefinition; /* default(=0) local definition is taken from the input field */
/* Extra values when packing */
grib_values extra_settings[80];
long extra_settings_count;
} grib_util_packing_spec;
grib_handle *grib_util_set_spec(grib_handle *h,
const grib_util_grid_spec *grid_spec,
const grib_util_packing_spec *packing_spec, /* NULL for defaults (same as input) */
int flags,
const double *data_values,
size_t data_values_count,
int *err);
/* --------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif
/* This part is automatically generated by ./errors.pl, do not edit */
#ifndef grib_errors_H
#define grib_errors_H
/*! \defgroup errors Error codes
Error codes returned by the grib_api functions.
*/
/*! @{*/
/** No error */
#define GRIB_SUCCESS 0
/** End of resource reached */
#define GRIB_END_OF_FILE -1
/** Internal error */
#define GRIB_INTERNAL_ERROR -2
/** Passed buffer is too small */
#define GRIB_BUFFER_TOO_SMALL -3
/** Function not yet implemented */
#define GRIB_NOT_IMPLEMENTED -4
/** Missing 7777 at end of message */
#define GRIB_7777_NOT_FOUND -5
/** Passed array is too small */
#define GRIB_ARRAY_TOO_SMALL -6
/** File not found */
#define GRIB_FILE_NOT_FOUND -7
/** Code not found in code table */
#define GRIB_CODE_NOT_FOUND_IN_TABLE -8
/** Array size mismatch */
#define GRIB_WRONG_ARRAY_SIZE -9
/** Key/value not found */
#define GRIB_NOT_FOUND -10
/** Input output problem */
#define GRIB_IO_PROBLEM -11
/** Message invalid */
#define GRIB_INVALID_MESSAGE -12
/** Decoding invalid */
#define GRIB_DECODING_ERROR -13
/** Encoding invalid */
#define GRIB_ENCODING_ERROR -14
/** Code cannot unpack because of string too small */
#define GRIB_NO_MORE_IN_SET -15
/** Problem with calculation of geographic attributes */
#define GRIB_GEOCALCULUS_PROBLEM -16
/** Out of memory */
#define GRIB_OUT_OF_MEMORY -17
/** Value is read only */
#define GRIB_READ_ONLY -18
/** Invalid argument */
#define GRIB_INVALID_ARGUMENT -19
/** Null handle */
#define GRIB_NULL_HANDLE -20
/** Invalid section number */
#define GRIB_INVALID_SECTION_NUMBER -21
/** Value cannot be missing */
#define GRIB_VALUE_CANNOT_BE_MISSING -22
/** Wrong message length */
#define GRIB_WRONG_LENGTH -23
/** Invalid key type */
#define GRIB_INVALID_TYPE -24
/** Unable to set step */
#define GRIB_WRONG_STEP -25
/** Wrong units for step (step must be integer) */
#define GRIB_WRONG_STEP_UNIT -26
/** Invalid file id */
#define GRIB_INVALID_FILE -27
/** Invalid grib id */
#define GRIB_INVALID_GRIB -28
/** Invalid index id */
#define GRIB_INVALID_INDEX -29
/** Invalid iterator id */
#define GRIB_INVALID_ITERATOR -30
/** Invalid keys iterator id */
#define GRIB_INVALID_KEYS_ITERATOR -31
/** Invalid nearest id */
#define GRIB_INVALID_NEAREST -32
/** Invalid order by */
#define GRIB_INVALID_ORDERBY -33
/** Missing a key from the fieldset */
#define GRIB_MISSING_KEY -34
/** The point is out of the grid area */
#define GRIB_OUT_OF_AREA -35
/** Concept no match */
#define GRIB_CONCEPT_NO_MATCH -36
/** Definitions files not found */
#define GRIB_NO_DEFINITIONS -37
/** Wrong type while packing */
#define GRIB_WRONG_TYPE -38
/** End of resource */
#define GRIB_END -39
/** Unable to code a field without values */
#define GRIB_NO_VALUES -40
/** Grid description is wrong or inconsistent */
#define GRIB_WRONG_GRID -41
/** End of index reached */
#define GRIB_END_OF_INDEX -42
/** Null index */
#define GRIB_NULL_INDEX -43
/** End of resource reached when reading message */
#define GRIB_PREMATURE_END_OF_FILE -44
/** An internal array is too small */
#define GRIB_INTERNAL_ARRAY_TOO_SMALL -45
/** Message is too large for the current architecture */
#define GRIB_MESSAGE_TOO_LARGE -46
/** Constant field */
#define GRIB_CONSTANT_FIELD -47
/** Switch unable to find a matching case */
#define GRIB_SWITCH_NO_MATCH -48
/** Underflow */
#define GRIB_UNDERFLOW -49
/** Message malformed */
#define GRIB_MESSAGE_MALFORMED -50
/** Index is corrupted */
#define GRIB_CORRUPTED_INDEX -51
/** Invalid number of bits per value */
#define GRIB_INVALID_BPV -52
/** Edition of two messages is different */
#define GRIB_DIFFERENT_EDITION -53
/** Value is different */
#define GRIB_VALUE_DIFFERENT -54
/** Invalid key value */
#define GRIB_INVALID_KEY_VALUE -55
/*! @}*/
#endif
|