SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
addmenu.h
1#pragma once
2
3#include "common/map/shapefile.h"
4#include "core/config.h"
5#include "core/resources.h"
6#include "handlers/handler.h"
7#include "handlers/vector/shapefile_handler.h"
8#include "logger.h"
9
10namespace satdump
11{
12 namespace handlers
13 {
14 // TODORERWORK this is extremely temporary!!!!!!!!!
15 inline void renderVectorOverlayMenu(handlers::Handler *h)
16 {
17 // TODOREWORK move out?!
18 if (ImGui::BeginMenu("Add Overlay"))
19 {
20 if (ImGui::MenuItem("Shores"))
21 h->addSubHandler(std::make_shared<handlers::ShapefileHandler>(resources::getResourcePath("maps/ne_10m_coastline.shp")), true);
22
23 if (ImGui::MenuItem("Borders"))
24 h->addSubHandler(std::make_shared<ShapefileHandler>(resources::getResourcePath("maps/ne_10m_admin_0_countries.shp")), true);
25
26 if (ImGui::MenuItem("Cities"))
27 h->addSubHandler(std::make_shared<ShapefileHandler>(resources::getResourcePath("maps/ne_10m_populated_places_simple.shp")), true);
28
29 if (ImGui::MenuItem("Lat/Lon Grid"))
30 {
31 auto h2 = std::make_shared<ShapefileHandler>();
32 h2->shapefile_name = "Lat/Lon Grid";
33
34 shapefile::PolyLineRecord r;
35
36 for (float lon = -180; lon < 180; lon += 10)
37 {
38 r.parts_points.push_back(std::vector<shapefile::point_t>());
39 auto &l = r.parts_points[r.parts_points.size() - 1];
40
41 for (float lat = -90; lat < 90; lat += 0.05)
42 l.push_back({lon, lat});
43 }
44
45 for (float lat = -90; lat < 90; lat += 10)
46 {
47 r.parts_points.push_back(std::vector<shapefile::point_t>());
48 auto &l = r.parts_points[r.parts_points.size() - 1];
49
50 for (float lon = -180; lon < 180; lon += 0.05)
51 l.push_back({lon, lat});
52 }
53
54 h2->file = std::make_unique<shapefile::Shapefile>();
55 h2->file->polyline_records.push_back(r);
56
57 h->addSubHandler(h2, true);
58 }
59
60 if (ImGui::MenuItem("QTH"))
61 {
62 auto h2 = std::make_shared<ShapefileHandler>();
63 h2->shapefile_name = "QTH";
64
65 shapefile::PointRecord r;
66 r.record_number = 1;
67 r.point.y = satdump::satdump_cfg.getValueFromSatDumpGeneral<double>("qth_lat");
68 r.point.x = satdump::satdump_cfg.getValueFromSatDumpGeneral<double>("qth_lon");
69
70 h2->file = std::make_unique<shapefile::Shapefile>();
71 h2->file->point_records.push_back(r);
72 h2->dbf_file[0]["name"] = "QTH";
73 h2->has_dbf = true;
74
75 h->addSubHandler(h2, true);
76 }
77
78 ImGui::EndMenu();
79 }
80 }
81 } // namespace handlers
82} // namespace satdump