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 "observable/evtvar.h"
28
29#include "model/route.h"
30#include "model/route_point.h"
31#include "model/track.h"
32
33#include "pugixml.hpp"
34#include "bbox.h"
35
36// Bitfield definition controlling the GPX nodes output for point objects
37#define OUT_TYPE 1 << 1 // Output point type
38#define OUT_TIME 1 << 2 // Output time as ISO string
39#define OUT_NAME 1 << 3 // Output point name if defined
40#define OUT_NAME_FORCE 1 << 4 // Output point name, even if empty
41#define OUT_DESC 1 << 5 // Output description if defined
42#define OUT_DESC_FORCE 1 << 6 // Output description, even if empty
43#define OUT_SYM_FORCE 1 << 7 // Output symbol name, using "empty" if undefined
44#define OUT_GUID 1 << 8 // Output GUID if defined
45#define OUT_VIZ 1 << 9 // Output point viz, if non-zero(true)
46#define OUT_VIZ_NAME 1 << 10 // Output point name viz, if non-zero(true)
47#define OUT_SHARED 1 << 11 // Output point shared state, if non-zero(true)
48#define OUT_HYPERLINKS 1 << 13 // Output point Hyperlinks, if present
49#define OUT_ACTION_ADD 1 << 14 // opencpn:action node support
50#define OUT_ACTION_DEL 1 << 15
51#define OUT_ACTION_UPD 1 << 16
52#define OUT_EXTENSION 1 << 17
53#define OUT_ARRIVAL_RADIUS 1 << 18
54#define OUT_WAYPOINT_RANGE_RINGS 1 << 19
55#define OUT_WAYPOINT_SCALE 1 << 20
56#define OUT_TIDE_STATION 1 << 21
57#define OUT_RTE_PROPERTIES 1 << 22
58
59#define OPT_TRACKPT OUT_TIME
60#define OPT_WPT \
61 (OUT_TYPE) + (OUT_TIME) + (OUT_NAME) + (OUT_DESC) + (OUT_SYM_FORCE) + \
62 (OUT_GUID) + (OUT_VIZ) + (OUT_VIZ_NAME) + (OUT_SHARED) + \
63 (OUT_HYPERLINKS) + (OUT_ARRIVAL_RADIUS) + (OUT_WAYPOINT_RANGE_RINGS) + \
64 (OUT_WAYPOINT_SCALE) + (OUT_TIDE_STATION)
65#define OPT_ROUTEPT OPT_WPT + (OUT_RTE_PROPERTIES)
66
67// Bitfield definitions controlling the GPX nodes output for Route.Track
68// objects
69#define RT_OUT_ACTION_ADD 1 << 1 // opencpn:action node support
70#define RT_OUT_ACTION_DEL 1 << 2
71#define RT_OUT_ACTION_UPD 1 << 3
72#define RT_OUT_NO_RTPTS 1 << 4
73
74class NavObjectCollection1; // forward
75
76class Route; // circular
77class Track; // circular
78class TrackPoint; // circular
79
80using RouteList = std::vector<Route *>; // circular
81
82bool WptIsInRouteList(RoutePoint *pr);
83RoutePoint *WaypointExistsByNamePosition(const wxString &name, double lat,
84 double lon);
85RoutePoint *WaypointExistsByGUID(const wxString &guid);
86Route *RouteExists(const wxString &guid);
87Route *RouteExists(Route *pTentRoute);
88Track *TrackExists(const wxString &guid);
89
90Route *FindRouteContainingWaypoint(RoutePoint *pWP);
91
92Route *GPXLoadRoute1(pugi::xml_node &wpt_node, bool b_fullviz, bool b_layer,
93 bool b_layerviz, int layer_id, bool b_change,
94 bool load_points = true);
95
96RoutePoint *GPXLoadWaypoint1(pugi::xml_node &wpt_node, wxString symbol_name,
97 wxString GUID, bool b_fullviz, bool b_layer,
98 bool b_layerviz, int layer_id,
99 bool b_nameviz = true);
100
101bool InsertRouteA(Route *pTentRoute, NavObjectCollection1 *navobj);
102bool InsertTrack(Track *pTentTrack, bool bApplyChanges = false);
103bool InsertWpt(RoutePoint *pWp, bool overwrite);
104
105Track *GPXLoadTrack1(pugi::xml_node &trk_node, bool b_fullviz, bool b_layer,
106 bool b_layerviz, int layer_id);
107
109public:
111 virtual ~NavObjectCollection1();
112
113 bool CreateNavObjGPXPoints(void);
114 bool CreateNavObjGPXRoutes(void);
115 bool CreateNavObjGPXTracks(void);
116
117 void AddGPXRoutesList(RouteList *pRoutes);
118 void AddGPXTracksList(std::vector<Track *> *pTracks);
119 bool AddGPXPointsList(RoutePointList *pRoutePoints);
120 bool AddGPXRoute(Route *pRoute);
121 bool AddGPXTrack(Track *pTrk);
122 bool AddGPXWaypoint(RoutePoint *pWP);
123
124 bool CreateAllGPXObjects();
125 bool LoadAllGPXObjects(bool b_full_viz, int &wpt_duplicates,
126 bool b_compute_bbox = false);
127 int LoadAllGPXObjectsAsLayer(int layer_id, bool b_layerviz,
128 wxCheckBoxState b_namesviz);
129 bool LoadAllGPXTrackObjects();
130 bool LoadAllGPXRouteObjects();
131 bool LoadAllGPXPointObjects();
132
133 bool SaveFile(const wxString filename);
134
135 void SetRootGPXNode(void);
136 bool IsOpenCPN();
137 LLBBox &GetBBox() { return BBox; };
138
139 LLBBox BBox;
140};
141
142#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
Route abstraction.
Waypoint or mark abstraction.
Recorded track abstraction.