|
RCube
Rcube Rest Server calculates sail routes based on Grib files and sailing boat polar files
|

Go to the source code of this file.
Functions | |
| char * | epochToStr (time_t t, bool seconds, char *str, size_t len) |
| functions defined in r3util.c | |
| struct tm | gribDateToTm (long intDate, double nHours) |
| return tm struct equivalent to date hours found in grib (UTC time) struct tm gribDateToTm (long intDate, double nHours) { struct tm tm0 = {0}; tm0.tm_year = (intDate / 10000) - 1900; tm0.tm_mon = ((intDate % 10000) / 100) - 1; tm0.tm_mday = intDate % 100; tm0.tm_isdst = -1; const int totalMinutes = (int)(nHours * 60); tm0.tm_min += totalMinutes; // adjust tm0 struct (manage day, mon year overflow) mktime (&tm0); return tm0; } | |
| bool | isDayLight (struct tm *tm0, double t, double lat, double lon) |
| char * | fSailName (int val, char *str, size_t maxLen) |
| return the name of the sail | |
| char * | newFileNameSuffix (const char *fileName, const char *suffix, char *newFileName, size_t maxLen) |
| replace former suffix (after last dot) by suffix example : "pol/bibi.toto.csv" with suffix "sailpol" will give: "pol/bibi.toto.sailpol" | |
| double | offsetLocalUTC (void) |
| return offset Local UTC in seconds | |
| char * | formatThousandSep (char *buffer, size_t maxLen, int value) |
| char * | buildRootName (const char *fileName, char *rootName, size_t maxLen) |
| Build root name if not already a root name. | |
| bool | isNumber (const char *name) |
| true if name contains a number | |
| double | getCoord (const char *str, double min, double max) |
| translate str in double for latitude longitude | |
| char * | latToStr (double lat, int type, char *str, size_t maxLen) |
| convert lat to str according to type | |
| char * | lonToStr (double lon, int type, char *str, size_t maxLen) |
| convert lon to str according to type | |
| char * | durationToStr (double duration, char *res, size_t maxLen) |
| convert hours in string with days, hours, minutes | |
| time_t | gribDateTimeToEpoch (long date, long time) |
| convert long date/time from GRIB to time_t (UTC, via timegm) | |
| double | getDepartureTimeInHour (struct tm *startUtc) |
| calculate difference in hours between departure time in UTC and time 0 | |
| char * | gribDateTimeToStr (long date, long time, char *str, size_t len) |
| return str representing grib date | |
| char * | newDate (long intDate, double myTime, char *res, size_t maxLen) |
| return date and time using ISO notation after adding myTime (hours) to the Date | |
| char * | newDateWeekDay (long intDate, double myTime, char *res, size_t maxLen) |
| return date and time using week day after adding myTime (hours) to the Date | |
| char * | newDateWeekDayVerbose (long intDate, double myTime, char *res, size_t maxLen) |
| return date and time using week day after adding myTime (hours) to the Date | |
| bool | readParam (const char *fileName, bool initDisp) |
| read parameter file and build par struct | |
| bool | writeParam (const char *fileName, bool header, bool password, bool yaml) |
| write parameter file from struct par header or not, password or not yaml style or not | |
| bool | readIsSea (const char *fileName) |
| read issea file and fill table tIsSea | |
| void | updateIsSeaWithForbiddenAreas (void) |
| complement according to forbidden areas | |
| bool | hasSlash (const char *name) |
| true if name terminates with slash | |
| bool | mostRecentFile (const char *directory, const char *pattern0, const char *pattern1, char *name, size_t maxLen) |
| select most recent file in "directory" that contains "pattern0" and "pattern1" in name return true if found with name of selected file | |
| double | fPenalty (int shipIndex, int type, double tws, double energy, double *cStamina) |
| double | fPointLoss (int shipIndex, int type, double tws, bool fullPack) |
| for virtual Regatta. | |
| double | fTimeToRecupOnePoint (double tws) |
| for virtual Regatta. | |
| char * | paramToStrJson (Par *par, char *buffer, size_t maxLen) |
| Return JSON formatted subset of parameters into 'out'. | |
| int | nearestPort (double lat, double lon, const char *fileName, char *str, size_t maxLen) |
| return id and name of nearest port found in file fileName from lat, lon. | |
| double | monotonic (void) |
| return seconds with decimals | |
| char * | readTextFile (const char *fileName, char *errMessage, size_t maxLen) |
| read all text file in buffer. | |
| bool | readMarkCSVToJson (const char *fileName, char *out, size_t maxLen) |
| read CSV file marks (Virtual Regatta) if check then polarCheck | |
| void | normalizeSpaces (char *s) |
| replace multiple spaces by just one | |
Variables | |
| Zone | zone |
| Zone description. | |
| Zone | currentZone |
| WayPointList | wayPoints |
| list of wayPoint | |
| MyPolygon | forbidZones [MAX_N_FORBID_ZONE] |
| forbid zones | |
| struct MeteoElmt | meteoTab [N_METEO_ADMIN] |
| Meteo service. | |
| const size_t | sailNameSize |
| sail attributes | |
| const char * | sailName [] |
| const char * | colorStr [] |
| PolMat | polMat |
| polar description | |
| PolMat | sailPolMat |
| polar matrix for sails | |
| PolMat | wavePolMat |
| polar matrix for waves | |
| Par | par |
| parameters desciption | |
| char * | tIsSea |
| table describing if sea or earth | |
| CompetitorsList | competitors |
| for competitors | |
|
extern |
Build root name if not already a root name.
Combines the working directory with the file name if it is not absolute. Stores the result in rootName and ensures it does not exceed maxLen.
| fileName | The name of the file (absolute or relative). |
| rootName | The buffer to store the resulting root name. |
| maxLen | The maximum length of the buffer rootName. |
rootName, or NULL on error.abolute path POSIX : begin with '/'
Definition at line 230 of file r3util.c.
References hasSlash(), par, WORKING_DIR, and Par::workingDir.
Referenced by checkParamAndUpdate(), gribToStrJson(), launchAction(), polToStrJson(), readParam(), updateCurrentGrib(), and updateWindGrib().


|
extern |
convert hours in string with days, hours, minutes
Definition at line 429 of file r3util.c.
Referenced by routeToStr().

|
extern |
functions defined in r3util.c
functions defined in r3util.c
Definition at line 247 of file r3util.c.
Referenced by optionManage().

|
extern |
|
extern |
|
extern |
|
extern |
return the name of the sail
Definition at line 68 of file r3util.c.
References g_strlcpy, PolMat::name, PolMat::nSail, polMat, and PolMat::tSail.
Referenced by routeToJson(), and routeToStr().

|
extern |
for virtual Regatta.
return type in second to get back one energy point
Definition at line 1014 of file r3util.c.
Referenced by statRoute().


|
extern |
translate str in double for latitude longitude
Definition at line 179 of file r3util.c.
References CLAMP.
Referenced by forbidZoneAdd(), readMarkCSVToJson(), and readParam().

|
extern |
calculate difference in hours between departure time in UTC and time 0
Definition at line 420 of file r3util.c.
References Zone::dataDate, Zone::dataTime, gribDateTimeToEpoch(), and zone.

|
extern |
convert long date/time from GRIB to time_t (UTC, via timegm)
Definition at line 408 of file r3util.c.
Referenced by checkParamAndUpdate(), getDepartureTimeInHour(), gribToStrJson(), infoCoordToJson(), optionManage(), timeIntersectGrib(), and zoneTimeDiff().

|
extern |
return str representing grib date
Definition at line 276 of file r3util.c.
Referenced by initContext(), and optionManage().

|
extern |
return tm struct equivalent to date hours found in grib (UTC time) struct tm gribDateToTm (long intDate, double nHours) { struct tm tm0 = {0}; tm0.tm_year = (intDate / 10000) - 1900; tm0.tm_mon = ((intDate % 10000) / 100) - 1; tm0.tm_mday = intDate % 100; tm0.tm_isdst = -1;
const int totalMinutes = (int)(nHours * 60); tm0.tm_min += totalMinutes; // adjust tm0 struct (manage day, mon year overflow) mktime (&tm0);
return tm0; }
Definition at line 299 of file r3util.c.
Referenced by newDate(), newDateWeekDay(), and newDateWeekDayVerbose().

|
extern |
true if name terminates with slash
Definition at line 130 of file r3util.c.
References name.
Referenced by buildRootName(), checkParamAndUpdate(), initContext(), launchAction(), and mostRecentFile().

|
extern |
|
extern |
true if name contains a number
Definition at line 174 of file r3util.c.
References name.
Referenced by strtodNew().

|
extern |
convert lat to str according to type
Definition at line 440 of file r3util.c.
References BASIC, DD, DM, DMS, and g_strlcpy.
Referenced by gribToStr(), isoDescToStr(), logReport(), routeToStr(), and writeParam().

|
extern |
convert lon to str according to type
Definition at line 462 of file r3util.c.
References BASIC, DD, DM, DMS, and g_strlcpy.
Referenced by gribToStr(), isoDescToStr(), logReport(), routeToStr(), and writeParam().

|
extern |
return seconds with decimals
Definition at line 1099 of file r3util.c.
Referenced by handleClient(), main(), and optionManage().

|
extern |
select most recent file in "directory" that contains "pattern0" and "pattern1" in name return true if found with name of selected file
Definition at line 138 of file r3util.c.
References hasSlash(), MAX_SIZE_DIR_NAME, MAX_SIZE_FILE_NAME, and name.
Referenced by checkParamAndUpdate(), initContext(), and launchAction().


|
extern |
return id and name of nearest port found in file fileName from lat, lon.
return empty string if not found
Definition at line 1063 of file r3util.c.
References g_strlcpy, g_strstrip(), MAX_SIZE_LINE, MAX_SIZE_NAME, and orthoDist().
Referenced by nearestPortToStrJson().


|
extern |
return date and time using ISO notation after adding myTime (hours) to the Date
Definition at line 386 of file r3util.c.
References gribDateToTm().
Referenced by allCompetitors(), exportRouteToGpx(), gribToStr(), gribToStrJson(), logReport(), optionManage(), and routeToStr().


|
extern |
return date and time using week day after adding myTime (hours) to the Date
Definition at line 394 of file r3util.c.
References gribDateToTm().

|
extern |
return date and time using week day after adding myTime (hours) to the Date
Definition at line 401 of file r3util.c.
References gribDateToTm().

|
extern |
replace former suffix (after last dot) by suffix example : "pol/bibi.toto.csv" with suffix "sailpol" will give: "pol/bibi.toto.sailpol"
Definition at line 78 of file r3util.c.
References g_strlcpy.
Referenced by readPolar().

|
extern |
replace multiple spaces by just one
Definition at line 1196 of file r3util.c.
Referenced by launchAction().

|
extern |
return offset Local UTC in seconds
Definition at line 263 of file r3util.c.
Referenced by optionManage().

|
extern |
Return JSON formatted subset of parameters into 'out'.
Returns out on success, NULL on error or truncation.
Definition at line 1023 of file r3util.c.
References Par::currentGribFileName, g_path_get_basename(), Par::gribFileName, Par::isSeaFileName, Zone::latMax, Zone::latMin, Zone::lonLeft, Zone::lonRight, par, Par::polarFileName, Par::wavePolFileName, Par::workingDir, and zone.
Referenced by launchAction().


|
extern |
read issea file and fill table tIsSea
Definition at line 484 of file r3util.c.
References SIZE_T_IS_SEA, and tIsSea.
Referenced by initContext().

|
extern |
read CSV file marks (Virtual Regatta) if check then polarCheck
Definition at line 1144 of file r3util.c.
References g_strfreev(), g_strsplit(), g_strstrip(), getCoord(), MAX_LAT, MAX_LON, MAX_SIZE_TEXT, MAX_SIZE_TEXT_FILE, MIN_LAT, MIN_LON, and name.
Referenced by launchAction().


|
extern |
read parameter file and build par struct
Definition at line 573 of file r3util.c.
References Par::aisDisp, Par::allwaysSea, Par::authent, buildRootName(), CLAMP, Par::cliHelpFileName, Par::closestDisp, Par::cogStep, Competitor::colorIndex, competitors, Par::constCurrentD, Par::constCurrentS, Par::constWave, Par::constWindTwd, Par::constWindTws, Par::curlSys, Par::currentDisp, Par::currentGribFileName, Par::dashboardUTC, Par::dashboardVR, Par::dayEfficiency, Par::description, Par::dispDms, Par::dumpIFileName, Par::dumpRFileName, Pp::father, Par::feedbackFileName, Par::focalDisp, forbidZoneAdd(), g_strstrip(), getCoord(), Par::googleApiKey, Par::gribFileName, Par::gribResolution, Par::gribTimeMax, Par::gribTimeStep, Par::gridDisp, Par::helpFileName, Pp::id, Par::imapMailBox, Par::imapScript, Par::imapServer, Par::imapToSeen, Par::imapUserName, Par::indicatorDisp, Par::infoDisp, Par::isSeaFileName, Par::jFactor, Par::kFactor, Pp::lat, WayPoint::lat, Competitor::lat, Par::logFileName, Pp::lon, WayPoint::lon, Competitor::lon, Par::mailPw, Par::marksFileName, MAX_LAT, MAX_LON, MAX_N_COMPETITORS, MAX_N_FORBID_ZONE, MAX_N_SECTORS, MAX_N_SHP_FILES, MAX_N_WAY_POINT, MAX_SIZE_LINE, MAX_SIZE_NAME, MAX_SIZE_TEXT, Par::maxPoiVisible, Par::maxWind, Par::midFileName, MIN, MIN_LAT, MIN_LON, Par::mostRecentGrib, Par::motorSpeed, WayPointList::n, CompetitorsList::n, N_MAX_NMEA_PORTS, Competitor::name, Par::nForbidZone, Par::nightEfficiency, Par::nmea, Par::nNmea, Par::nSectors, Par::nShpFiles, Par::opt, par, Par::parInfoFileName, Par::pDest, Par::pDestName, Par::penalty0, Par::penalty1, Par::penalty2, Par::poiFileName, Par::polarFileName, Par::pOr, Par::pOrName, Par::portFileName, Par::portName, Par::python, Par::rangeCog, CompetitorsList::runIndex, Par::showColors, Par::shpFileName, Par::shpPointsDisp, Par::smtpScript, Par::smtpServer, Par::smtpTo, Par::smtpUserName, Par::special, Par::speed, Par::speedDisp, Par::staminaVR, Par::startTimeInHours, Par::stepIsocDisp, Par::storeMailPw, Par::style, CompetitorsList::t, WayPointList::t, Par::techno, Par::threshold, Par::tidesFileName, WayPointList::totLoxoDist, WayPointList::totOrthoDist, Par::traceFileName, Par::tStep, Par::waveDisp, Par::wavePolFileName, wayPoints, Par::web, Par::webkit, Par::windDisp, Par::windyApiKey, Par::withCurrent, Par::withWaves, Par::workingDir, Par::wpGpxFileName, and Par::xWind.
Referenced by initContext().


|
extern |
read all text file in buffer.
Allocate memory
Definition at line 1106 of file r3util.c.
Referenced by launchAction(), and readPolarJson().

|
extern |
complement according to forbidden areas
Definition at line 534 of file r3util.c.
References isInForbidArea(), Par::nForbidZone, par, SIZE_T_IS_SEA, and tIsSea.
Referenced by initContext().


|
extern |
write parameter file from struct par header or not, password or not yaml style or not
Definition at line 826 of file r3util.c.
References Par::aisDisp, Par::allwaysSea, Par::authent, Par::cliHelpFileName, Par::closestDisp, Par::cogStep, Competitor::colorIndex, competitors, Par::constCurrentD, Par::constCurrentS, Par::constWave, Par::constWindTwd, Par::constWindTws, Par::curlSys, Par::currentDisp, Par::currentGribFileName, Par::dashboardUTC, Par::dashboardVR, Par::dayEfficiency, Par::description, Par::dispDms, Par::dumpIFileName, Par::dumpRFileName, Par::feedbackFileName, Par::focalDisp, forbidZones, fprintfNoNull(), fprintfNoZero(), Par::googleApiKey, Par::gribFileName, Par::gribResolution, Par::gribTimeMax, Par::gribTimeStep, Par::gridDisp, Par::helpFileName, Par::imapMailBox, Par::imapScript, Par::imapServer, Par::imapToSeen, Par::imapUserName, Par::indicatorDisp, Par::infoDisp, Par::isSeaFileName, Par::jFactor, Par::kFactor, Pp::lat, WayPoint::lat, Competitor::lat, latToStr(), Par::logFileName, Pp::lon, WayPoint::lon, Competitor::lon, lonToStr(), Par::mailPw, Par::marksFileName, MAX_SIZE_NAME, Par::maxPoiVisible, Par::maxWind, Par::midFileName, Par::mostRecentGrib, Par::motorSpeed, MyPolygon::n, WayPointList::n, CompetitorsList::n, Competitor::name, Par::nForbidZone, Par::nightEfficiency, Par::nmea, Par::nNmea, Par::nSectors, Par::nShpFiles, Par::opt, par, Par::parInfoFileName, Par::pDest, Par::pDestName, Par::penalty0, Par::penalty1, Par::penalty2, Par::poiFileName, Par::polarFileName, Par::pOr, Par::pOrName, Par::portFileName, Par::portName, Par::python, Par::rangeCog, Par::showColors, Par::shpFileName, Par::shpPointsDisp, Par::smtpScript, Par::smtpServer, Par::smtpTo, Par::smtpUserName, Par::special, Par::speed, Par::speedDisp, Par::staminaVR, Par::startTimeInHours, Par::stepIsocDisp, Par::style, CompetitorsList::t, WayPointList::t, Par::techno, Par::threshold, Par::tidesFileName, Par::traceFileName, Par::tStep, Par::waveDisp, Par::wavePolFileName, wayPoints, Par::web, Par::webkit, Par::windDisp, Par::windyApiKey, Par::withCurrent, Par::withWaves, Par::workingDir, Par::wpGpxFileName, and Par::xWind.
Referenced by launchAction().


|
extern |
for competitors
for competitors
Definition at line 46 of file r3util.c.
Referenced by allCompetitors(), checkParamAndUpdate(), launchAction(), readParam(), routeToJson(), routeToStr(), routing(), routingLaunch(), and writeParam().
|
extern |
Definition at line 65 of file r3util.c.
Referenced by checkGribToStr(), findCurrentGrib(), infoCoordToJson(), initContext(), initRouting(), optionManage(), testToJson(), and updateCurrentGrib().
|
extern |
forbid zones
forbid zones
Definition at line 32 of file r3util.c.
Referenced by forbidToJson(), forbidZoneAdd(), isInForbidArea(), and writeParam().
|
extern |
Meteo service.
Meteo service.
Definition at line 35 of file r3util.c.
Referenced by gribToStr(), and gribToStrJson().
|
extern |
parameters desciption
parameters desciption
Definition at line 58 of file r3util.c.
Referenced by allCompetitors(), bestTimeDeparture(), buildNextIsochrone(), buildRootName(), calcDuration(), checkParamAndUpdate(), exportRouteToGpx(), extractLevel(), findCurrentGrib(), findFlow(), findWindGrib(), forbidToJson(), forwardSectorOptimize(), goal(), goalP(), gribToStr(), handleClient(), infoCoordToJson(), initContext(), initRouting(), isCurrentTriplet(), isInForbidArea(), isoDescToStr(), launchAction(), logReport(), nearestPortToStrJson(), optionManage(), paramToStrJson(), readParam(), routeToJson(), routeToStr(), routing(), routingLaunch(), serveStaticFile(), shortNameFor(), simpleGoal(), simpleGoalP(), statRoute(), updateCurrentGrib(), updateIsSeaWithForbiddenAreas(), updateWindGrib(), and writeParam().
|
extern |
polar description
polar description
Definition at line 49 of file r3util.c.
Referenced by addSail(), buildNextIsochrone(), checkParamAndUpdate(), findListPol(), findSailPol(), fSailName(), goalP(), initContext(), optionManage(), readPolarJson(), and simpleGoalP().
|
extern |
Definition at line 39 of file r3util.c.
Referenced by findSailPol(), and readPolar().
|
extern |
|
extern |
polar matrix for sails
Definition at line 52 of file r3util.c.
Referenced by buildNextIsochrone(), checkParamAndUpdate(), findListPol(), findSailPol(), goalP(), initContext(), optionManage(), readPolar(), readPolarJson(), and simpleGoalP().
|
extern |
table describing if sea or earth
Definition at line 61 of file r3util.c.
Referenced by buildNextIsochrone(), checkParamAndUpdate(), goal(), infoCoordToJson(), main(), optionManage(), readIsSea(), segmentOverSea(), simpleGoal(), and updateIsSeaWithForbiddenAreas().
|
extern |
polar matrix for waves
Definition at line 55 of file r3util.c.
Referenced by buildNextIsochrone(), checkParamAndUpdate(), goalP(), initContext(), optionManage(), and simpleGoalP().
|
extern |
list of wayPoint
Definition at line 43 of file r3util.c.
Referenced by checkParamAndUpdate(), logReport(), readParam(), routingLaunch(), and writeParam().
|
extern |
Zone description.
Zone description.
Definition at line 64 of file r3util.c.
Referenced by allCompetitors(), buildInitialOfShortNameList(), buildNextIsochrone(), buildUVGWarray(), checkGrib(), checkGribInfoToStr(), checkGribToStr(), checkParamAndUpdate(), consistentGrib(), find4PointsAround(), findFlow(), findTimeAround(), findTimeIndex(), findWindGrib(), getDepartureTimeInHour(), goalP(), gribToStr(), idxTij(), indexOf(), indLat(), indLat(), indLat(), indLon(), indLon(), indLonWrap(), infoCoordToJson(), initContext(), initRouting(), isInZone(), isPresentGrib(), launchAction(), logReport(), optionManage(), paramToStrJson(), printGrib(), readGribAll(), readGribLists(), readGribParameters(), routeToJson(), routing(), simpleGoalP(), statRoute(), testToJson(), timeStepRegularGrib(), updateWindGrib(), and uvPresentGrib().