28 #ifndef SHAPEFILE_BASEMAP_H
29 #define SHAPEFILE_BASEMAP_H
36 #include "ShapefileReader.hpp"
37 #include "poly_math.h"
40 #if (defined(OCPN_GHC_FILESYSTEM) || (defined(__clang_major__) && (__clang_major__ < 15)))
42 #include <ghc/filesystem.hpp>
43 namespace fs = ghc::filesystem;
47 namespace fs = std::filesystem;
60 bool operator<(
const LatLonKey &k)
const {
61 if (this->lat < k.lat) {
62 return this->lon < k.lon;
64 return this->lat < k.lat;
67 bool operator==(
const LatLonKey &other)
const {
68 return (lat == other.lat && lon == other.lon);
74 std::size_t operator()(
const LatLonKey &k)
const {
75 return 360 * k.lat + k.lon;
94 typedef std::vector<wxRealPoint> contour;
95 typedef std::vector<contour> contour_list;
101 ShapeBaseChart(
const std::string &filename,
const size_t &min_scale,
102 const wxColor &color = *wxBLACK)
107 _min_scale(min_scale),
111 _is_usable = fs::exists(filename);
115 this->_filename = t._filename;
116 this->_is_usable = t._is_usable;
117 this->_is_tiled = t._is_tiled;
118 this->_min_scale = t._min_scale;
119 this->_reader =
nullptr;
120 this->_color = t._color;
121 this->_dmod = t._dmod;
122 this->_loading = t._loading;
129 bool IsUsable() {
return _is_usable && !_loading; }
130 size_t MinScale() {
return _min_scale; }
131 void RenderViewOnDC(
ocpnDC &dc,
ViewPort &vp) { DrawPolygonFilled(dc, vp); }
132 static const std::string ConstructPath(
const std::string &dir,
133 const std::string &quality_suffix) {
134 return std::string(dir + fs::path::preferred_separator +
"basemap_" +
135 quality_suffix +
".shp");
138 bool CrossesLand(
double &lat1,
double &lon1,
double &lat2,
double &lon2);
141 std::future<bool> _loaded;
147 const shp::Feature &feature);
149 const shp::Feature &feature);
151 void AddPointToTessList(shp::Point &point,
ViewPort &vp, GLUtesselator *tobj,
bool idl);
153 std::string _filename;
154 shp::ShapefileReader *_reader;
155 std::unordered_map<LatLonKey, std::vector<size_t>> _tiles;
158 bool LineLineIntersect(
const std::pair<double, double> &A,
159 const std::pair<double, double> &B,
160 const std::pair<double, double> &C,
161 const std::pair<double, double> &D);
163 bool PolygonLineIntersect(
const shp::Feature &feature,
164 const std::pair<double, double> &A,
165 const std::pair<double, double> &B);
173 static wxPoint2DDouble GetDoublePixFromLL(
ViewPort &vp,
double lat,
179 bool IsUsable() {
return _basemap_map.size() > 0 && LowestQualityBaseMap().IsUsable(); }
181 bool CrossesLand(
double lat1,
double lon1,
double lat2,
double lon2) {
183 return HighestQualityBaseMap().CrossesLand(lat1, lon1, lat2, lon2);
191 void LoadBasemaps(
const std::string &dir);
192 void DrawPolygonFilled(
ocpnDC &pnt,
ViewPort &vp, wxColor
const &color);
194 wxColor
const &color,
bool idl);
200 std::map<Quality, ShapeBaseChart> _basemap_map;
latitude/longitude key for 1 degree cells
Set of basemaps at different resolutions.