Skip to content

Commit

Permalink
Merge pull request #12 from eried/world-map-mercator
Browse files Browse the repository at this point in the history
World map mercator
  • Loading branch information
eried authored May 2, 2020
2 parents 6a22fbf + 07d746f commit 9e50681
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions firmware/application/ui/ui_geomap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ GeoMap::GeoMap(
}

void GeoMap::paint(Painter& painter) {
Coord line;
u_int16_t line;
std::array<ui::Color, 240> map_line_buffer;
const auto r = screen_rect();

Expand All @@ -168,7 +168,7 @@ void GeoMap::paint(Painter& painter) {
display.fill_rectangle({ r.center() - Point(16, 1), { 32, 2 } }, Color::red());
display.fill_rectangle({ r.center() - Point(1, 16), { 2, 32 } }, Color::red());
} else {
draw_bearing({ 120, 32 + 144 }, angle_, 16, Color::red());
draw_bearing({ 120, 32 + 144 }, angle_, 10, Color::red());
painter.draw_string({ 120 - ((int)tag_.length() * 8 / 2), 32 + 144 - 32 }, style(), tag_);
}
}
Expand All @@ -191,10 +191,10 @@ void GeoMap::move(const float lon, const float lat) {

Rect map_rect = screen_rect();

// Map is in Equidistant "Plate Carrée" projection
x_pos = map_center_x - (map_rect.width() / 2) + (lon_ / lon_ratio);
y_pos = map_center_y - (map_rect.height() / 2) + (lat_ / lat_ratio) + 16;
// Using WGS 84/Pseudo-Mercator projection
x_pos = map_width * (lon_+180)/360 - (map_rect.width() / 2);
y_pos = (0.5-lat_/(340.1206913+-4.21807e-5*pow((double)abs(lat_),3.4198394))) * map_height -(map_rect.height() / 1) + 32;

// Cap position
if (x_pos > (map_width - map_rect.width()))
x_pos = map_width - map_rect.width();
Expand Down Expand Up @@ -228,8 +228,8 @@ void GeoMap::draw_bearing(const Point origin, const uint32_t angle, uint32_t siz

for (size_t thickness = 0; thickness < 3; thickness++) {
arrow_a = polar_to_point(angle, size) + origin;
arrow_b = polar_to_point(angle + 180 - 30, size) + origin;
arrow_c = polar_to_point(angle + 180 + 30, size) + origin;
arrow_b = polar_to_point(angle + 180 - 35, size) + origin;
arrow_c = polar_to_point(angle + 180 + 35, size) + origin;

display.draw_line(arrow_a, arrow_b, color);
display.draw_line(arrow_b, arrow_c, color);
Expand Down
Binary file modified sdcard/ADSB/world_map.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9e50681

Please sign in to comment.