26 #ifndef __CHARTDBS_H__
27 #define __CHARTDBS_H__
33 #include "model/ocpn_types.h"
37 class wxGenericProgressDialog;
44 wxString magic_number;
51 static const int DB_VERSION_PREVIOUS = 17;
52 static const int DB_VERSION_CURRENT = 18;
55 class ChartGroupArray;
77 int nNoCovrPlyEntries;
99 int nNoCovrPlyEntries;
154 float **pAuxPlyTable;
162 : nTableEntries(tableEntries), nDirEntries(dirEntries) {}
164 void Read(wxInputStream &is);
165 void Write(wxOutputStream &os);
167 int GetDirEntries()
const {
return nDirEntries; }
168 int GetTableEntries()
const {
return nTableEntries; }
169 char *GetDBVersionString() {
return dbVersion; }
191 void SetValid(
bool valid) { bValid = valid; }
192 time_t GetFileTime()
const {
return file_date; }
193 time_t GetChartEditionDate()
const {
return edition_date; }
195 int GetnPlyEntries()
const {
return nPlyEntries; }
196 float *GetpPlyTable()
const {
return pPlyTable; }
198 int GetnAuxPlyEntries()
const {
return nAuxPlyEntries; }
199 float *GetpAuxPlyTableEntry(
int index)
const {
return pAuxPlyTable[index]; }
200 int GetAuxCntTableEntry(
int index)
const {
return pAuxCntTable[index]; }
202 int GetnNoCovrPlyEntries()
const {
return nNoCovrPlyEntries; }
203 float *GetpNoCovrPlyTableEntry(
int index)
const {
204 return pNoCovrPlyTable[index];
206 int GetNoCovrCntTableEntry(
int index)
const {
return pNoCovrCntTable[index]; }
208 const LLBBox &GetBBox()
const {
return m_bbox; }
210 char *GetpFullPath()
const {
return pFullPath; }
211 float GetLonMax()
const {
return LonMax; }
212 float GetLonMin()
const {
return LonMin; }
213 float GetLatMax()
const {
return LatMax; }
214 float GetLatMin()
const {
return LatMin; }
215 int GetScale()
const {
return Scale; }
216 int GetChartType()
const {
return ChartType; }
217 int GetChartFamily()
const {
return ChartFamily; }
218 int GetChartProjectionType()
const {
return ProjectionType; }
219 float GetChartSkew()
const {
return Skew; }
221 bool GetbValid() {
return bValid; }
222 void SetEntryOffset(
int n) { EntryOffset = n; }
223 const wxString *GetpFileName(
void)
const {
return m_pfilename; }
224 wxString *GetpsFullPath(
void)
const {
return m_psFullPath; }
225 wxString GetFullSystemPath()
const {
return m_fullSystemPath; }
227 const std::vector<int> &GetGroupArray(
void)
const {
return m_GroupArray; }
228 void ClearGroupArray(
void) { m_GroupArray.clear(); }
229 void AddIntToGroupArray(
int val) { m_GroupArray.push_back(val); }
230 void SetAvailable(
bool avail) { m_bavail = avail; }
232 std::vector<float> GetReducedPlyPoints();
233 std::vector<float> GetReducedAuxPlyPoints(
int iTable);
235 LLRegion quilt_candidate_region;
237 void SetScale(
int scale);
238 bool Scale_eq(
int b)
const {
return abs(Scale - b) <= rounding; }
239 bool Scale_ge(
int b)
const {
return Scale_eq(b) || Scale > b; }
240 bool Scale_gt(
int b)
const {
return Scale > b && !Scale_eq(b); }
258 float **pAuxPlyTable;
263 int nNoCovrPlyEntries;
264 int *pNoCovrCntTable;
265 float **pNoCovrPlyTable;
267 std::vector<int> m_GroupArray;
268 wxString *m_pfilename;
269 wxString *m_psFullPath;
270 wxString m_fullSystemPath;
275 std::vector<float> m_reducedPlyPoints;
277 std::vector<std::vector<float>> m_reducedAuxPlyPointsVector;
280 enum { BUILTIN_DESCRIPTOR = 0, PLUGIN_DESCRIPTOR };
288 : m_class_name(classn), m_search_mask(mask), m_descriptor_type(type){};
290 wxString m_class_name;
291 wxString m_search_mask;
292 int m_descriptor_type;
306 bool Create(ArrayOfCDI &dir_array, wxGenericProgressDialog *pprog);
307 bool Update(ArrayOfCDI &dir_array,
bool bForce,
308 wxGenericProgressDialog *pprog);
310 bool Read(
const wxString &filePath);
311 bool Write(
const wxString &filePath);
313 bool AddSingleChart(wxString &fullpath,
bool b_force_full_search =
true);
314 bool RemoveSingleChart(wxString &ChartFullPath);
316 const wxString &GetDBFileName()
const {
return m_DBFileName; }
317 ArrayOfCDI &GetChartDirArray() {
return m_dir_array; }
318 wxArrayString &GetChartDirArrayString() {
return m_chartDirs; }
319 void SetChartDirArray(ArrayOfCDI array) { m_dir_array = array; }
320 bool CompareChartDirArray(ArrayOfCDI &test_array);
321 wxString GetMagicNumberCached(wxString dir);
323 void UpdateChartClassDescriptorArray(
void);
325 int GetChartTableEntries()
const {
return active_chartTable.size(); }
328 inline ChartTable &GetChartTable() {
return active_chartTable; }
330 bool IsValid()
const {
return bValid; }
331 int DisableChart(wxString &PathToDisable);
332 bool GetCentroidOfLargestScaleChart(
double *clat,
double *clon,
333 ChartFamilyEnum family);
334 int GetDBChartType(
int dbIndex);
335 int GetDBChartFamily(
int dbIndex);
336 float GetDBChartSkew(
int dbIndex);
337 int GetDBChartProj(
int dbIndex);
338 int GetDBChartScale(
int dbIndex);
340 bool GetDBBoundingBox(
int dbindex, LLBBox &box);
341 const LLBBox &GetDBBoundingBox(
int dbIndex);
343 int GetnAuxPlyEntries(
int dbIndex);
344 int GetDBPlyPoint(
int dbIndex,
int plyindex,
float *lat,
float *lon);
345 int GetDBAuxPlyPoint(
int dbIndex,
int plyindex,
int iAuxPly,
float *lat,
347 int GetVersion() {
return m_dbversion; }
348 wxString GetFullChartInfo(
ChartBase *pc,
int dbIndex,
int *char_width,
350 int FinddbIndex(wxString PathToFind);
351 wxString GetDBChartFileName(
int dbIndex);
352 void ApplyGroupArray(ChartGroupArray *pGroupArray);
353 bool IsChartAvailable(
int dbIndex);
354 ChartTable active_chartTable;
355 std::map<wxString, int> active_chartTable_pathindex;
357 std::vector<float> GetReducedPlyPoints(
int dbIndex);
358 std::vector<float> GetReducedAuxPlyPoints(
int dbIndex,
int iTable);
360 bool IsBusy() {
return m_b_busy; }
363 virtual ChartBase *GetChart(
const wxChar *theFilePath,
365 int AddChartDirectory(
const wxString &theDir,
bool bshow_prog);
366 void SetValid(
bool valid) { bValid = valid; }
371 std::vector<ChartClassDescriptor> m_ChartClassDescriptorArray;
372 ArrayOfCDI m_dir_array;
376 bool IsChartDirUsed(
const wxString &theDir);
378 int SearchDirAndAddCharts(wxString &dir_name_base,
380 wxGenericProgressDialog *pprog);
383 wxGenericProgressDialog *pprog,
384 wxString &dir_magic,
bool bForce);
385 bool DetectDirChange(
const wxString &dir_path,
const wxString &prog_label,
386 const wxString &magic, wxString &new_magic,
387 wxGenericProgressDialog *pprog);
390 wxGenericProgressDialog *pprog,
int isearch,
391 bool bthis_dir_in_dB);
393 bool Check_CM93_Structure(wxString dir_name);
396 wxArrayString m_chartDirs;
400 m_ChartTableEntryDummy;
401 wxString m_DBFileName;
417 WX_DEFINE_ARRAY_PTR(
ChartGroup *, ChartGroupArray);
424 wxString m_element_name;
425 wxArrayString m_missing_name_array;
430 wxString m_group_name;
431 std::vector<ChartGroupElement> m_element_array;