Update map to allow multiple markers

This commit is contained in:
heurist1 2023-02-28 19:09:05 +00:00
parent ef151e243b
commit 00b75eacda
2 changed files with 158 additions and 29 deletions

View file

@ -37,6 +37,24 @@ enum GeoMapMode {
PROMPT
};
struct GeoMarker {
public:
float lat {0};
float lon {0};
uint16_t angle {0};
std::string tag {""};
GeoMarker & operator=(GeoMarker & rhs){
lat = rhs.lat;
lon = rhs.lon;
angle = rhs.angle;
tag = rhs.tag;
return *this;
}
};
class GeoPos : public View {
public:
enum alt_unit {
@ -112,6 +130,12 @@ private:
};
};
enum MapMarkerStored {
MARKER_NOT_STORED,
MARKER_STORED,
MARKER_LIST_FULL
};
class GeoMap : public Widget {
public:
std::function<void(float, float)> on_move { };
@ -133,20 +157,35 @@ public:
angle_ = new_angle;
}
static const int NumMarkerListElements = 30;
void clear_markers();
MapMarkerStored store_marker(GeoMarker & marker);
private:
void draw_bearing(const Point origin, const uint16_t angle, uint32_t size, const Color color);
void draw_marker(Painter& painter, const ui::Point itemPoint, const uint16_t itemAngle, const std::string itemTag,
const Color color = Color::red(), const Color fontColor = Color::white(), const Color backColor = Color::black() );
GeoMapMode mode_ { };
File map_file { };
uint16_t map_width { }, map_height { };
int32_t map_center_x { }, map_center_y { };
float lon_ratio { }, lat_ratio { };
double map_bottom { };
double map_world_lon { };
double map_offset { };
int32_t x_pos { }, y_pos { };
int32_t prev_x_pos { 0xFFFF }, prev_y_pos { 0xFFFF };
float lat_ { };
float lon_ { };
uint16_t angle_ { };
std::string tag_ { };
int markerListLen {0};
GeoMarker markerList[NumMarkerListElements];
bool markerListUpdated {false};
};
class GeoMapView : public View {
@ -181,6 +220,12 @@ public:
std::string title() const override { return "Map view"; };
void clear_markers();
MapMarkerStored store_marker(GeoMarker & marker);
void update_tag(const std::string tag);
private:
NavigationView& nav_;