Skip to content

Commit

Permalink
Correct for changes to GribRecordSet.h.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasbats committed Feb 13, 2019
1 parent 48a3af3 commit 34052b9
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 20 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ SET(SRC_ShipDriver
src/AisMaker.h
src/AisMaker.cpp
src/GribRecord.cpp
src/GribRecordSet.h
src/GribRecord.h
src/tinyxml.h
src/tinyxml.cpp
src/tinyxmlerror.cpp
Expand All @@ -57,7 +59,11 @@ IF(WIN32)
SET(SRC_JSON
src/wxJSON/jsonval.cpp
src/wxJSON/jsonreader.cpp
src/wxJSON/jsonwriter.cpp)
src/wxJSON/jsonwriter.cpp
src/wx/json_defs.h
src/wx/jsonval.h
src/wx/jsonreader.h
src/wx/jsonwriter.h)
ENDIF(WIN32)


Expand Down
65 changes: 49 additions & 16 deletions src/GribRecordSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,57 @@

#include "GribRecord.h"

// These are indexes into the array
enum { Idx_WIND_VX, Idx_WIND_VX850, Idx_WIND_VX700, Idx_WIND_VX500, Idx_WIND_VX300,
Idx_WIND_VY, Idx_WIND_VY850, Idx_WIND_VY700, Idx_WIND_VY500, Idx_WIND_VY300,
Idx_WIND_GUST, Idx_PRESSURE, Idx_HTSIGW, Idx_WVDIR, Idx_WVPER,
Idx_SEACURRENT_VX, Idx_SEACURRENT_VY, Idx_PRECIP_TOT, Idx_CLOUD_TOT,
Idx_AIR_TEMP, Idx_AIR_TEMP850, Idx_AIR_TEMP700, Idx_AIR_TEMP500, Idx_AIR_TEMP300,
Idx_SEA_TEMP, Idx_CAPE,
Idx_HUMID_RE, Idx_HUMID_RE850, Idx_HUMID_RE700, Idx_HUMID_RE500, Idx_HUMID_RE300,
Idx_GEOP_HGT,Idx_GEOP_HGT850, Idx_GEOP_HGT700, Idx_GEOP_HGT500, Idx_GEOP_HGT300,
Idx_COUNT };
// These are indexes into the array
enum {
Idx_WIND_VX, Idx_WIND_VX850, Idx_WIND_VX700, Idx_WIND_VX500, Idx_WIND_VX300,
Idx_WIND_VY, Idx_WIND_VY850, Idx_WIND_VY700, Idx_WIND_VY500, Idx_WIND_VY300,
Idx_WIND_GUST, Idx_PRESSURE, Idx_HTSIGW, Idx_WVDIR, Idx_WVPER,
Idx_SEACURRENT_VX, Idx_SEACURRENT_VY, Idx_PRECIP_TOT, Idx_CLOUD_TOT,
Idx_AIR_TEMP, Idx_AIR_TEMP850, Idx_AIR_TEMP700, Idx_AIR_TEMP500, Idx_AIR_TEMP300,
Idx_SEA_TEMP, Idx_CAPE,
Idx_HUMID_RE, Idx_HUMID_RE850, Idx_HUMID_RE700, Idx_HUMID_RE500, Idx_HUMID_RE300,
Idx_GEOP_HGT, Idx_GEOP_HGT850, Idx_GEOP_HGT700, Idx_GEOP_HGT500, Idx_GEOP_HGT300,
Idx_COUNT
};

class GribRecordSet {
public:
GribRecordSet() {
for(int i=0; i<Idx_COUNT; i++)
m_GribRecordPtrArray[i] = NULL;
}
GribRecordSet(unsigned int id) : m_Reference_Time(-1), m_ID(id) {
for (int i = 0; i < Idx_COUNT; i++) {
m_GribRecordPtrArray[i] = 0;
m_GribRecordUnref[i] = false;
}
}

virtual ~GribRecordSet()
{
RemoveGribRecords();
}

/* copy and paste by plugins, keep functions in header */
void SetUnRefGribRecord(int i, GribRecord *pGR) {
assert(i >= 0 && i < Idx_COUNT);
if (m_GribRecordUnref[i] == true) {
delete m_GribRecordPtrArray[i];
}
m_GribRecordPtrArray[i] = pGR;
m_GribRecordUnref[i] = true;
}

void RemoveGribRecords() {
for (int i = 0; i < Idx_COUNT; i++) {
if (m_GribRecordUnref[i] == true) {
delete m_GribRecordPtrArray[i];
}
}
}

time_t m_Reference_Time;
unsigned int m_ID;

time_t m_Reference_Time;
GribRecord *m_GribRecordPtrArray[Idx_COUNT];
GribRecord *m_GribRecordPtrArray[Idx_COUNT];
private:
// grib records files are stored and owned by reader mapGribRecords
// interpolated grib are not, keep track of them
bool m_GribRecordUnref[Idx_COUNT];
};
10 changes: 9 additions & 1 deletion src/ShipDriver_pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int ShipDriver_pi::Init(void)
WANTS_NMEA_SENTENCES|
WANTS_AIS_SENTENCES|
WANTS_PREFERENCES|
WANTS_PLUGIN_MESSAGING |
WANTS_PLUGIN_MESSAGING|
WANTS_CONFIG
);
}
Expand Down Expand Up @@ -452,6 +452,7 @@ void ShipDriver_pi::SetPluginMessage(wxString &message_id, wxString &message_bod
}

wxString sptr = v[_T("TimelineSetPtr")].AsString();

wxCharBuffer bptr = sptr.To8BitData();
const char* ptr = bptr.data();

Expand Down Expand Up @@ -482,6 +483,13 @@ bool ShipDriver_pi::GribWind(GribRecordSet *grib, double lat, double lon,
return false;

VWG *= 3.6 / 1.852; // knots

#if 0
// test
VWG = 0.;
WG = 0.;
#endif

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ShipDriver_pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
#define GRIB_MIN_MINOR 1


#define PLUGIN_VERSION_MAJOR 0
#define PLUGIN_VERSION_MINOR 6
#define PLUGIN_VERSION_MAJOR 2
#define PLUGIN_VERSION_MINOR 0

#define MY_API_VERSION_MAJOR 1
#define MY_API_VERSION_MINOR 6
Expand Down

0 comments on commit 34052b9

Please sign in to comment.