|
RCube
Rcube Rest Server calculates sail routes based on Grib files and sailing boat polar files
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <stdbool.h>#include <time.h>#include <math.h>#include <sys/stat.h>#include <locale.h>#include "glibwrapper.h"#include "r3types.h"#include "r3util.h"#include "inline.h"#include "readgriball.h"
Go to the source code of this file.
Macros | |
| #define | EPSILON 0.001 |
compilation: gcc -c grib.c pkg-config --cflags glib-2.0 | |
Functions | |
| double | zoneTimeDiff (const Zone *zone1, const Zone *zone0) |
| return difference in hours between two zones (current zone and Wind zone) | |
| float * | buildUVGWarray (const Zone *zone, const char *initialOfNames, const FlowP *gribData, size_t *outNValues) |
| return array of outNvalues floats n = nTimeStamp * nbLat * nbLon * nShortNames values = [u1, v0, g0, w0, u1, v1, g1, w1, ...] g, w are optionnal | |
| void | printGrib (const Zone *zone, const FlowP *gribData) |
| print Grib u v ... for all lat lon time information | |
| static bool | checkGrib (const Zone *zone, int iFlow, CheckGrib *check) |
| static bool | geoIntersectGrib (const Zone *zone1, const Zone *zone2) |
| true if (wind) zone and currentZone intersect in geography | |
| static bool | timeIntersectGrib (const Zone *zone1, const Zone *zone2) |
| true if (wind) zone and zone 2 intersect in time | |
| static bool | timeStepRegularGrib (const Zone *zone) |
| check if time steps are regular | |
| bool | uvPresentGrib (const Zone *zone) |
| true if u and v (or uCurr, vCurr) are in zone | |
| bool | isPresentGrib (const Zone *zone, const char *name) |
| true if shortname in zone | |
| static int | consistentGrib (const Zone *zone, int iFlow, double epsilon, int *nLatSuspects, int *nLonSuspects) |
| check lat, lon are consistent with indice return number of values | |
| bool | checkGribInfoToStr (int type, Zone *zone, char *buffer, size_t maxLen) |
| check Grib information and write (add) report in the buffer return false if something wrong | |
| bool | checkGribToStr (bool hasCurrentGrib, char *buffer, size_t maxLen) |
| check Grib information and write report in the buffer return false if something wrong | |
| static void | findTimeAround (double t, int *iTInf, int *iTSup, const Zone *zone) |
| find iTinf and iTsup in order t : zone.timeStamp [iTInf] <= t <= zone.timeStamp [iTSup] | |
| static double | arrondiMin (double v, double step) |
| ex arrondiMin (46.4, 0.25) = 46.25 | |
| static double | arrondiMax (double v, double step) |
| ex arrondiMax (46.4, 0.25) = 46.50 | |
| static void | find4PointsAround (double lat, double lon, double *latMin, double *latMax, double *lonMin, double *lonMax, Zone *zone) |
| provide 4 wind points around point lat, lon | |
| static long | indLat (double lat, const Zone *zone) |
| return indice of lat in gribData wind or current | |
| static long | indLon (double lon, const Zone *zone) |
| return indice of lon in gribData wind or current | |
| static bool | findFlow (double lat, double lon, double t, double *rU, double *rV, double *rG, double *rW, Zone *zone, const FlowP *gribData) |
| interpolation to get u, v, g (gust), w (waves) at point (lat, lon) and time t | |
| void | findWindGrib (double lat, double lon, double t, double *u, double *v, double *gust, double *w, double *twd, double *tws) |
| use findflow to get wind and waves | |
| void | findCurrentGrib (double lat, double lon, double t, double *uCurr, double *vCurr, double *tcd, double *tcs) |
| use findflow to get current | |
| char * | gribToStr (const Zone *zone, char *str, size_t maxLen) |
| write Grib information in string | |
| char * | gribToStrJson (const char *fileName, char *out, size_t maxLen) |
| write grib meta information in string | |
| #define EPSILON 0.001 |
|
inlinestatic |
ex arrondiMax (46.4, 0.25) = 46.50
Definition at line 373 of file r3grib.c.
Referenced by find4PointsAround().

|
inlinestatic |
ex arrondiMin (46.4, 0.25) = 46.25
Definition at line 368 of file r3grib.c.
Referenced by find4PointsAround().

| float * buildUVGWarray | ( | const Zone * | zone, |
| const char * | initialOfNames, | ||
| const FlowP * | gribData, | ||
| size_t * | outNValues | ||
| ) |
return array of outNvalues floats n = nTimeStamp * nbLat * nbLon * nShortNames values = [u1, v0, g0, w0, u1, v1, g1, w1, ...] g, w are optionnal
Definition at line 33 of file r3grib.c.
References FlowP::g, Zone::nbLat, Zone::nbLon, Zone::nTimeStamp, FlowP::u, FlowP::v, FlowP::w, and zone.
Referenced by launchAction().

Definition at line 93 of file r3grib.c.
References CheckGrib::gMissing, CheckGrib::gStrange, FlowP::lat, Zone::latMax, Zone::latMin, FlowP::lon, Zone::lonLeft, Zone::lonRight, MISSING, Zone::nbLat, Zone::nbLon, Zone::nTimeStamp, CheckGrib::outZone, tGribData, CheckGrib::uMissing, CheckGrib::uStrange, CheckGrib::vMissing, CheckGrib::vStrange, CheckGrib::wMissing, CheckGrib::wStrange, and zone.
Referenced by checkGribInfoToStr().

| bool checkGribInfoToStr | ( | int | type, |
| Zone * | zone, | ||
| char * | buffer, | ||
| size_t | maxLen | ||
| ) |
check Grib information and write (add) report in the buffer return false if something wrong
Definition at line 207 of file r3grib.c.
References Zone::allTimeStepOK, checkGrib(), consistentGrib(), EPSILON, g_strlcat, CheckGrib::gMissing, CheckGrib::gStrange, Zone::latMax, Zone::latMin, Zone::latStep, Zone::lonLeft, Zone::lonRight, Zone::lonStep, MAX_SIZE_LINE, Zone::nbLat, Zone::nbLon, Zone::nDataDate, Zone::nDataTime, Zone::nTimeStamp, Zone::numberOfValues, CheckGrib::outZone, Zone::stepUnits, timeStepRegularGrib(), CheckGrib::uMissing, CheckGrib::uStrange, uvPresentGrib(), CheckGrib::vMissing, CheckGrib::vStrange, Zone::wellDefined, WIND, CheckGrib::wMissing, CheckGrib::wStrange, and zone.
Referenced by checkGribToStr().


| bool checkGribToStr | ( | bool | hasCurrentGrib, |
| char * | buffer, | ||
| size_t | maxLen | ||
| ) |
check Grib information and write report in the buffer return false if something wrong
Definition at line 316 of file r3grib.c.
References checkGribInfoToStr(), CURRENT, currentZone, g_strlcat, geoIntersectGrib(), MAX_SIZE_LINE, Zone::nbLat, timeIntersectGrib(), WIND, and zone.
Referenced by launchAction(), and optionManage().


|
static |
check lat, lon are consistent with indice return number of values
Definition at line 178 of file r3grib.c.
References Zone::anteMeridian, Zone::latMin, Zone::latStep, lonCanonize(), Zone::lonLeft, Zone::lonStep, Zone::nbLat, Zone::nbLon, Zone::nTimeStamp, tGribData, and zone.
Referenced by checkGribInfoToStr().


|
inlinestatic |
provide 4 wind points around point lat, lon
Definition at line 378 of file r3grib.c.
References arrondiMax(), arrondiMin(), Zone::latMax, Zone::latMin, Zone::latStep, Zone::lonLeft, Zone::lonRight, Zone::lonStep, and zone.
Referenced by findFlow().


| void findCurrentGrib | ( | double | lat, |
| double | lon, | ||
| double | t, | ||
| double * | uCurr, | ||
| double * | vCurr, | ||
| double * | tcd, | ||
| double * | tcs | ||
| ) |
use findflow to get current
Definition at line 507 of file r3grib.c.
References Par::constCurrentD, Par::constCurrentS, CURRENT, currentZone, DEG_TO_RAD, findFlow(), fTwd(), fTws(), KN_TO_MS, Zone::nTimeStamp, par, tGribData, and Zone::timeStamp.
Referenced by buildNextIsochrone().


|
static |
interpolation to get u, v, g (gust), w (waves) at point (lat, lon) and time t
Definition at line 410 of file r3grib.c.
References Par::constWindTws, find4PointsAround(), findTimeAround(), FlowP::g, indLat(), indLon(), interpolate(), isInZone(), FlowP::lat, FlowP::lon, Zone::nbLat, Zone::nbLon, par, Zone::timeStamp, FlowP::u, FlowP::v, FlowP::w, Zone::wellDefined, and zone.
Referenced by findCurrentGrib(), and findWindGrib().


|
inlinestatic |
find iTinf and iTsup in order t : zone.timeStamp [iTInf] <= t <= zone.timeStamp [iTSup]
Definition at line 344 of file r3grib.c.
References Zone::nTimeStamp, Zone::timeStamp, and zone.
Referenced by findFlow().

| void findWindGrib | ( | double | lat, |
| double | lon, | ||
| double | t, | ||
| double * | u, | ||
| double * | v, | ||
| double * | gust, | ||
| double * | w, | ||
| double * | twd, | ||
| double * | tws | ||
| ) |
use findflow to get wind and waves
Definition at line 488 of file r3grib.c.
References Par::constWave, Par::constWindTwd, Par::constWindTws, DEG_TO_RAD, findFlow(), fTwd(), fTws(), KN_TO_MS, par, tGribData, WIND, and zone.
Referenced by buildNextIsochrone(), goalP(), infoCoordToJson(), simpleGoalP(), and statRoute().


true if (wind) zone and currentZone intersect in geography
Definition at line 120 of file r3grib.c.
References Zone::latMax, Zone::latMin, Zone::lonLeft, and Zone::lonRight.
Referenced by checkGribToStr().

| char * gribToStr | ( | const Zone * | zone, |
| char * | str, | ||
| size_t | maxLen | ||
| ) |
write Grib information in string
Definition at line 530 of file r3grib.c.
References Zone::centreId, Zone::dataDate, Zone::dataTime, Par::dispDms, Zone::editionNumber, g_strlcat, g_strlcpy, Zone::latMax, Zone::latMin, Zone::latStep, latToStr(), Zone::lonLeft, Zone::lonRight, Zone::lonStep, lonToStr(), MAX_SIZE_LINE, MAX_SIZE_NAME, meteoTab, name, Zone::nbLat, Zone::nbLon, Zone::nDataDate, Zone::nDataTime, newDate(), Zone::nMessage, Zone::nShortName, Zone::nTimeStamp, Zone::numberOfValues, par, Zone::shortName, Zone::stepUnits, Zone::timeStamp, Zone::wellDefined, and zone.
Referenced by optionManage().


| char * gribToStrJson | ( | const char * | fileName, |
| char * | out, | ||
| size_t | maxLen | ||
| ) |
write grib meta information in string
Definition at line 586 of file r3grib.c.
References buildRootName(), Zone::centreId, Zone::dataDate, Zone::dataTime, Zone::editionNumber, g_path_get_basename(), g_strlcat, g_strlcpy, gribDateTimeToEpoch(), Zone::latMax, Zone::latMin, Zone::latStep, Zone::lonLeft, Zone::lonRight, Zone::lonStep, MAX_SIZE_FILE_NAME, MAX_SIZE_LINE, MAX_SIZE_NAME, MAX_SIZE_TEXT, meteoTab, N_METEO_ADMIN, name, Zone::nbLat, Zone::nbLon, Zone::nDataDate, Zone::nDataTime, newDate(), Zone::nShortName, Zone::nTimeStamp, Zone::numberOfValues, readGribLists(), readGribParameters(), Zone::shortName, and Zone::timeStamp.
Referenced by launchAction().


|
inlinestatic |
return indice of lat in gribData wind or current
Definition at line 399 of file r3grib.c.
References Zone::latMin, Zone::latStep, and zone.
Referenced by findFlow().

|
inlinestatic |
return indice of lon in gribData wind or current
Definition at line 404 of file r3grib.c.
References Zone::lonLeft, Zone::lonStep, and zone.
Referenced by findFlow().

| bool isPresentGrib | ( | const Zone * | zone, |
| const char * | name | ||
| ) |
true if shortname in zone
Definition at line 169 of file r3grib.c.
References name, Zone::nShortName, Zone::shortName, and zone.
Referenced by buildInitialOfShortNameList().

print Grib u v ... for all lat lon time information
Definition at line 69 of file r3grib.c.
References Zone::nbLat, Zone::nbLon, Zone::nTimeStamp, Zone::timeStamp, and zone.
Referenced by optionManage().

true if (wind) zone and zone 2 intersect in time
Definition at line 129 of file r3grib.c.
References Zone::dataDate, Zone::dataTime, and gribDateTimeToEpoch().
Referenced by checkGribToStr().


|
static |
check if time steps are regular
Definition at line 139 of file r3grib.c.
References Zone::intervalBegin, Zone::intervalEnd, Zone::intervalLimit, Zone::nTimeStamp, Zone::timeStamp, and zone.
Referenced by checkGribInfoToStr().

| bool uvPresentGrib | ( | const Zone * | zone | ) |
true if u and v (or uCurr, vCurr) are in zone
Definition at line 155 of file r3grib.c.
References Zone::nShortName, Zone::shortName, and zone.
Referenced by buildInitialOfShortNameList(), and checkGribInfoToStr().

return difference in hours between two zones (current zone and Wind zone)
Definition at line 19 of file r3grib.c.
References Zone::dataDate, Zone::dataTime, gribDateTimeToEpoch(), and Zone::wellDefined.
Referenced by initRouting().

