20#ifndef _CHARTMBTILES_H_
21#define _CHARTMBTILES_H_
27#include "model/georef.h"
28#include "OCPNRegion.h"
29#include "ocpn_pixel.h"
31#include "tile_descr.h"
32#include "tile_thread.h"
33#include "tile_cache.h"
40enum class MbTilesType : std::int8_t {
46enum class MbTilesScheme : std::int8_t {
82 virtual bool UpdateThumbData(
double lat,
double lon);
86 int GetNativeScale() {
return m_Chart_Scale; }
100 virtual InitReturn Init(
const wxString& name, ChartInitFlag init_flags);
102 bool RenderRegionViewOnDC(wxMemoryDC& dc,
const ViewPort& VPoint,
105 virtual bool RenderRegionViewOnGL(
const wxGLContext& glc,
108 const LLRegion& region);
110 virtual double GetNearestPreferredScalePPM(
double target_scale_ppm);
112 virtual void GetValidCanvasRegion(
const ViewPort& v_point,
114 virtual LLRegion GetValidRegion();
116 virtual bool GetChartExtent(
Extent* pext);
118 void SetColorScheme(ColorScheme cs,
bool bApplyImmediate);
120 double GetPPM() {
return m_ppm_avg; }
121 double GetZoomFactor() {
return m_zoom_scale_factor; }
122 MbTilesType GetTileType() {
return m_tile_type; }
126 bool RenderViewOnDC(wxMemoryDC& dc,
const ViewPort& VPoint);
127 InitReturn PreInit(
const wxString& name, ChartInitFlag init_flags,
129 InitReturn PostInit(
void);
132 void PrepareTilesForZoom(
int zoomFactor,
bool bset_geom);
143 void FlushTiles(
void);
144 bool RenderTile(SharedTilePtr tile,
int zoom_level,
const ViewPort& vpoint);
155 MbTilesType m_tile_type;
161 std::unique_ptr<TileCache> m_tile_cache;
162 LLRegion m_min_zoom_region;
163 wxBitmapType m_image_type;
164 int m_last_clean_zoom;
166 double m_zoom_scale_factor;
168 MbTilesScheme m_scheme;
170 std::shared_ptr<SQLite::Database> m_db;
172 std::string m_format;
174 uint32_t m_tile_count;
175 std::unique_ptr<MbtTilesThread> m_worker_thread;
176 std::thread m_thread;
193 void InitFromTiles(
const wxString& name);
194 wxPoint2DDouble GetDoublePixFromLL(
ViewPort& vp,
double lat,
double lon);
Base class for all chart types.
Represents an MBTiles format chart.
void StopThread()
Stop and delete the worker thread.
virtual ThumbData * GetThumbData(int tnx, int tny, float lat, float lon)
Get the Chart thumbnail data structure, creating the thumbnail bitmap as required.
double GetNormalScaleMin(double canvas_scale_factor, bool b_allow_overzoom)
Report recommended minimum scale values for which use of this chart is valid.
bool StartThread()
Create and start the worker thread.
double GetNormalScaleMax(double canvas_scale_factor, int canvas_width)
Report recommended maximum scale values for which use of this chart is valid.
bool GetTileTexture(SharedTilePtr tile)
Loads a tile into OpenGL's texture memory for rendering.
Wrapper class for OpenGL shader programs.
A wrapper class for wxRegion with additional functionality.
Represents the view port for chart display in OpenCPN.