OpenCPN Partial API docs
Loading...
Searching...
No Matches
nav_object_database.h
1/***************************************************************************
2 * Copyright (C) 2010 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
18#ifndef NAVOBJECTCOLLECTION_H_
19#define NAVOBJECTCOLLECTION_H_
20
21#include <memory>
22#include <vector>
23
24#include <wx/checkbox.h>
25#include <wx/string.h>
26
27#include "model/route.h"
28#include "model/route_point.h"
29#include "model/track.h"
30
31#include "pugixml.hpp"
32#include "bbox.h"
33#include "observable_evtvar.h"
34
35// Bitfield definition controlling the GPX nodes output for point objects
36#define OUT_TYPE 1 << 1 // Output point type
37#define OUT_TIME 1 << 2 // Output time as ISO string
38#define OUT_NAME 1 << 3 // Output point name if defined
39#define OUT_NAME_FORCE 1 << 4 // Output point name, even if empty
40#define OUT_DESC 1 << 5 // Output description if defined
41#define OUT_DESC_FORCE 1 << 6 // Output description, even if empty
42#define OUT_SYM_FORCE 1 << 7 // Output symbol name, using "empty" if undefined
43#define OUT_GUID 1 << 8 // Output GUID if defined
44#define OUT_VIZ 1 << 9 // Output point viz, if non-zero(true)
45#define OUT_VIZ_NAME 1 << 10 // Output point name viz, if non-zero(true)
46#define OUT_SHARED 1 << 11 // Output point shared state, if non-zero(true)
47#define OUT_HYPERLINKS 1 << 13 // Output point Hyperlinks, if present
48#define OUT_ACTION_ADD 1 << 14 // opencpn:action node support
49#define OUT_ACTION_DEL 1 << 15
50#define OUT_ACTION_UPD 1 << 16
51#define OUT_EXTENSION 1 << 17
52#define OUT_ARRIVAL_RADIUS 1 << 18
53#define OUT_WAYPOINT_RANGE_RINGS 1 << 19
54#define OUT_WAYPOINT_SCALE 1 << 20
55#define OUT_TIDE_STATION 1 << 21
56#define OUT_RTE_PROPERTIES 1 << 22
57
58#define OPT_TRACKPT OUT_TIME
59#define OPT_WPT \
60 (OUT_TYPE) + (OUT_TIME) + (OUT_NAME) + (OUT_DESC) + (OUT_SYM_FORCE) + \
61 (OUT_GUID) + (OUT_VIZ) + (OUT_VIZ_NAME) + (OUT_SHARED) + \
62 (OUT_HYPERLINKS) + (OUT_ARRIVAL_RADIUS) + (OUT_WAYPOINT_RANGE_RINGS) + \
63 (OUT_WAYPOINT_SCALE) + (OUT_TIDE_STATION)
64#define OPT_ROUTEPT OPT_WPT + (OUT_RTE_PROPERTIES)
65
66// Bitfield definitions controlling the GPX nodes output for Route.Track
67// objects
68#define RT_OUT_ACTION_ADD 1 << 1 // opencpn:action node support
69#define RT_OUT_ACTION_DEL 1 << 2
70#define RT_OUT_ACTION_UPD 1 << 3
71#define RT_OUT_NO_RTPTS 1 << 4
72
73class NavObjectCollection1; // forward
74
75class Route; // circular
76class Track; // circular
77class TrackPoint; // circular
78
79using RouteList = std::vector<Route *>; // circular
80
81bool WptIsInRouteList(RoutePoint *pr);
82RoutePoint *WaypointExists(const wxString &name, double lat, double lon);
83RoutePoint *WaypointExists(const wxString &guid);
84Route *RouteExists(const wxString &guid);
85Route *RouteExists(Route *pTentRoute);
86Track *TrackExists(const wxString &guid);
87
88Route *FindRouteContainingWaypoint(RoutePoint *pWP);
89
90Route *GPXLoadRoute1(pugi::xml_node &wpt_node, bool b_fullviz, bool b_layer,
91 bool b_layerviz, int layer_id, bool b_change,
92 bool load_points = true);
93
94RoutePoint *GPXLoadWaypoint1(pugi::xml_node &wpt_node, wxString symbol_name,
95 wxString GUID, bool b_fullviz, bool b_layer,
96 bool b_layerviz, int layer_id,
97 bool b_nameviz = true);
98
99bool InsertRouteA(Route *pTentRoute, NavObjectCollection1 *navobj);
100bool InsertTrack(Track *pTentTrack, bool bApplyChanges = false);
101bool InsertWpt(RoutePoint *pWp, bool overwrite);
102
103Track *GPXLoadTrack1(pugi::xml_node &trk_node, bool b_fullviz, bool b_layer,
104 bool b_layerviz, int layer_id);
105
107public:
109 virtual ~NavObjectCollection1();
110
111 bool CreateNavObjGPXPoints(void);
112 bool CreateNavObjGPXRoutes(void);
113 bool CreateNavObjGPXTracks(void);
114
115 void AddGPXRoutesList(RouteList *pRoutes);
116 void AddGPXTracksList(std::vector<Track *> *pTracks);
117 bool AddGPXPointsList(RoutePointList *pRoutePoints);
118 bool AddGPXRoute(Route *pRoute);
119 bool AddGPXTrack(Track *pTrk);
120 bool AddGPXWaypoint(RoutePoint *pWP);
121
122 bool CreateAllGPXObjects();
123 bool LoadAllGPXObjects(bool b_full_viz, int &wpt_duplicates,
124 bool b_compute_bbox = false);
125 int LoadAllGPXObjectsAsLayer(int layer_id, bool b_layerviz,
126 wxCheckBoxState b_namesviz);
127 bool LoadAllGPXTrackObjects();
128 bool LoadAllGPXRouteObjects();
129 bool LoadAllGPXPointObjects();
130
131 bool SaveFile(const wxString filename);
132
133 void SetRootGPXNode(void);
134 bool IsOpenCPN();
135 LLBBox &GetBBox() { return BBox; };
136
137 LLBBox BBox;
138};
139
140#endif // NAVOBJECTCOLLECTION_H_
Represents a waypoint or mark within the navigation system.
Definition route_point.h:71
Represents a navigational route in the navigation system.
Definition route.h:99
Represents a single point in a track.
Definition track.h:59
Represents a track, which is a series of connected track points.
Definition track.h:117
A common variable shared between producer and consumer which supports Listen() and Notify().
Route abstraction.
Waypoint or mark abstraction.
Recorded track abstraction.