19 #include "SettingsNames.h" 23 static constexpr
double GRAYLINE_COS = -0.208;
24 static constexpr
double GRAYLINE_POW = 0.75;
26 enum class EphemerisFile : size_t {
34 enum class ProjectionType {
55 bool passRiseOk{}, passSetOk{};
58 double elevation{}, azimuth{}, range{}, rangeRate{};
61 if (passRiseOk && other.passRiseOk)
62 return riseTime < other.riseTime;
64 return setTime < other.setTime;
83 [[nodiscard]] std::tuple<bool, bool, DateTime, DateTime>
getPassData()
const {
return std::make_tuple(passRiseOk, passSetOk, riseTime, setTime); }
96 [[nodiscard]] std::string passTimeString(time_t relative = 0)
const;
107 void updateMetaData(
Observer observer) {
108 auto [elevation, azimuth, range, range_rate] = satellite.
topo(observer);
109 metaData.elevation = elevation;
110 metaData.azimuth = azimuth;
111 metaData.range = range;
112 metaData.rangeRate = range_rate;
139 using Predicate = std::function<bool(Position &, Position &)>;
143 std::copy(begin(), end(), std::back_inserter(segment));
144 mLineParts.emplace_back(segment);
151 auto first = begin();
154 work.emplace_back(*first);
156 while (first != last) {
157 if (p(work.back(), *first)) {
158 work.emplace_back(*first);
161 mLineParts.emplace_back(work);
163 work.emplace_back(*first);
168 mLineParts.emplace_back(work);
175 for (
const auto &segment : mLineParts) {
177 std::for_each(segment.begin()+1, segment.end(), [&p,&p0](
const Position &p1){
194 SignalSerialNumber mSignalSerialNumber{};
195 Rose::IconFileItem mMoonIconSpec{
static_cast<ImageId
>(set::AppImageId::Moon),
Size{0, 0},
"full_moon.png"};
198 static constexpr std::array<double, 3> GrayLineCos = {-0.105, -0.208,
200 static constexpr
double GrayLinePow = .80;
203 static constexpr std::array<set::AppImageId,5> mSatelliteIconArray{
204 set::AppImageId::DotPurple, set::AppImageId::DotYellow,
205 set::AppImageId::DotGreen, set::AppImageId::DotBlue, set::AppImageId::DotRed, };
208 std::stack<set::AppImageId> mSatelliteIconStack{};
210 bool mTerrestrialMode{};
211 bool mSatelliteMode{};
212 bool mCelestialMode{};
213 bool mAnnotationMode{};
215 std::string mSatelliteFavorite{};
217 std::future<bool> mFutureAziProj{};
218 std::future<bool> mFutureSun{};
219 std::atomic_bool mNewSurfaces{};
220 std::atomic_bool mAbortFuture{};
223 std::shared_ptr<WebFileCache> mMapCache{};
224 ImageId mDayMapImage{};
225 ImageId mNightMapImage{};
230 int mSelectedSatellite{};
232 std::array<sdl::Surface,static_cast<std::size_t>(MapDataType::MapCount)> mMapSurface{};
233 std::array<sdl::Surface,static_cast<std::size_t>(MapDataType::MapCount)> mAzSurface{};
235 std::array<sdl::Surface,static_cast<std::size_t>(MapDataType::MapCount)/2> mMercatorTemp;
236 std::array<sdl::Surface,static_cast<std::size_t>(MapDataType::MapCount)/2> mAzimuthalTemp;
238 std::atomic_bool mUpdateEphemeris{
false};
239 std::array<std::filesystem::path, 5> mEphemerisFilePath{};
240 EphemerisFile mEphemerisFile{EphemerisFile::ClearSkyAll};
241 void updateEphemerisFile();
244 std::vector<TrackedSatellite> mSatelliteList{};
245 std::mutex mSatListMutex{};
246 double mMinimumElevation{15.};
249 static std::tuple<bool, bool, double, double, double, DateTime, DateTime>
252 std::array<sdl::Texture,2> mMercator{};
253 std::array<sdl::Texture,2> mAzimuthal{};
258 std::shared_ptr<Slot<std::string>> mSettingsUpdateRx{};
268 std::unique_ptr<AntiAliasedDrawing> mDrawingContext{};
278 bool computeAzimuthalMaps();
288 bool setForegroundBackground();
299 std::array<MapIcon,2> mStationIcons{};
300 std::array<MapIcon,2> mCelestialIcons{};
307 mAntipode = antipode(mQthRad);
308 mStationIcons[0].geo = mQthRad;
309 mStationIcons[1].geo = mAntipode;
310 mStationIcons[0].imageId =
static_cast<ImageId
>(set::AppImageId::RingGreen);
311 mStationIcons[1].imageId =
static_cast<ImageId
>(set::AppImageId::RingRed);
315 void setCelestialIcons();
335 template<
typename InputIterator>
337 ProjectionType projection,
int splitPixel = 0) {
338 while (first != last) {
339 drawMapItem(*first, renderer, mapRect, projection, splitPixel);
352 void initializeComposite()
override;
370 std::shared_ptr<Slot<uint32_t>> mapFileRx{};
371 std::shared_ptr<Slot<int>> secondRx{};
372 std::shared_ptr<Slot<int>> minuteRx{};
380 return GeoPosition{-posRadians.
lat(), (posRadians.
lon() < 0. ? 1. : -1.) * (M_PI - abs(posRadians.
lon()))};
391 double lon = (2. * M_PI * (double)x / (
double)mapSize.
width()) - M_PI;
392 double lat = M_PI_2 - (double)y / (
double)mapSize.
height() * M_PI;
420 mEphemerisFilePath[
static_cast<std::size_t
>(item)] = filePath;
421 if (item == EphemerisFile::ClearSkyMoon) {
424 mMoon.setEphemeris(ephemeris[
"Moon"]);
427 }
else if (mEphemerisFile == item){
429 updateEphemerisFile();
433 using SignalType = std::vector<TrackedSatellite>&;
439 std::shared_ptr<Slot<RadioBehavior::SignalType>> satelliteSelectRx{};
Definition: MapProjection.h:318
Definition: MapProjection.h:294
Invalid image ID.
Definition: Constants.h:172
Encapsulate the day-in-space for orbital mechanics computations.
Definition: Plan13.h:141
std::tuple< double, double, double, double > topo(const Observer &obs)
Convert satellite co-ordinates to an observer frame.
Definition: Plan13.cpp:358
int roundToInt(T value, T multiplier=1.)
Round a floating point value to an integer.
Definition: Math.h:34
std::vector< Position > LineSegment
The type of a line segment.
Definition: MapProjection.h:123
Standard Mercator split a the International Date Line.
double lat
Latitude value.
Definition: MapProjection.h:166
static GeoPosition geoPosition(int x, int y, Size mapSize)
Convert a map coordinate (x,y) into a GeoPosition(lat,lon) in radians.
Definition: MapProjection.h:390
Definition: SatelliteModel.h:79
An encapsulation of the SDL_Texture structure.
Definition: Texture.h:40
static Position mapPosition(GeoPosition map, Size mapSize)
Convert a GeoPosition(lat,lon) in radians to a map Position(x,y) in pixels.
Definition: MapProjection.h:402
Definition: MapProjection.h:99
constexpr int & width()
Reference accessor for width.
Definition: ScreenMetrics.h:61
An abstraction of a geographic position.
Definition: MapProjection.h:165
A position in integer (x, y) co-ordinates.
Definition: Types.h:95
std::function< bool(Position &, Position &)> Predicate
A predicate which returns true if two Positions belong in the same partition.
Definition: MapProjection.h:139
Classes and functions for caching data fetched from the network.
void predict(const DateTime &dateTime)
Predict the satelite position at given DateTime.
Definition: Plan13.cpp:255
Data specifying an observer for computing relative visibility data.
Definition: Plan13.h:254
void setMoonEphemerisFile(EphemerisFile item, const std::filesystem::path &filePath)
Set the Moon ephemeris.
Definition: MapProjection.h:419
A composite of a Position and a Size.
Definition: Types.h:307
void drawMapItems(InputIterator first, InputIterator last, sdl::Renderer &renderer, Rectangle mapRect, ProjectionType projection, int splitPixel=0)
Render a container of icons [first ...
Definition: MapProjection.h:336
double lon
Longitude value.
Definition: MapProjection.h:167
MapDataType
Map type ins order with the Night map after and one greater than the Day map.
Definition: MapProjection.h:44
SatelliteMetaData metaData
Minimal data for display of the satellite status.
Definition: MapProjection.h:100
Written as a workaround for an issue in the SDL2 Library.
Definition: Renderer.h:64
Partition lines across discontinuities introduced by the current map projection.
Definition: MapProjection.h:120
A size in integer dimensions.
Definition: Types.h:230
Satellite orbital mechanics.
Definition: Plan13.h:294
std::vector< LineSegment > LineParts
The type of a partitioned line.
Definition: MapProjection.h:126
static GeoPosition antipode(const GeoPosition posRadians)
Compute an antipode.
Definition: MapProjection.h:379
ToDo: There is an issue that the initial scroll interaction is lost if the click/press lands on a Wid...
Definition: CelestialOverlay.cpp:13
Mercator split so the Station location is centred.
constexpr int & height()
Reference accessor for height.
Definition: ScreenMetrics.h:67
Satellite satellite
The tracked Satellite.
Definition: MapProjection.h:101