World Ocean Simulation System (WOSS) library
location-definitions.h
Go to the documentation of this file.
1/* WOSS - World Ocean Simulation System -
2 *
3 * Copyright (C) 2009 2025 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - WOSS@guerra-tlc.com
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation;
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22
33#ifndef LOCATION_DEFINITIONS_H
34#define LOCATION_DEFINITIONS_H
35
36
37#include <cmath>
38#include <ostream>
39#include <memory>
41
42
43namespace woss {
44
45 static constexpr inline double LOCATION_COMPARISON_DISTANCE = (0.0);
46
52 class Location {
53
54 public:
55
61 Location( const CoordZ& coordz = CoordZ(), double dist = LOCATION_COMPARISON_DISTANCE );
62
70 Location( double latitude, double longitude, double depth = 0, double dist = LOCATION_COMPARISON_DISTANCE );
71
72 Location( const Location& copy) = default;
73
74 Location( Location&& tmp) = default;
75
76 virtual ~Location() = default;
77
78 Location& operator=(const Location& copy) = default;
79
80 Location& operator=(Location&& tmp) = default;
81
90 virtual std::unique_ptr<Location> create( double latitude, double longitude, double depth = 0, double dist = LOCATION_COMPARISON_DISTANCE ) const {
91 return std::make_unique<Location>(latitude, longitude, depth, dist); }
92
99 virtual std::unique_ptr<Location> create( const CoordZ& coordz = CoordZ(), double dist = LOCATION_COMPARISON_DISTANCE ) const {
100 return std::make_unique<Location>(coordz,dist); }
101
106 virtual std::unique_ptr<Location> clone() const { return std::make_unique<Location>(*this); }
107
112 virtual bool isValid() const { return curr_coordz.isValid(); }
113
119 virtual bool isEquivalentTo( const woss::CoordZ& coordz );
120
125 virtual void setLocation( const CoordZ& coordz );
126
131 virtual void setLatitude( double lat );
132
137 virtual void setLongitude( double lon );
138
143 virtual void setDepth( double depth );
144
150 virtual void setVerticalOrientation( double angle );
151
157 virtual void setHorizontalOrientation( double angle );
158
163 virtual CoordZ getLocation();
164
169 virtual double getLatitude();
170
175 virtual double getLongitude();
176
181 virtual double getDepth();
182
187 virtual double getX();
188
193 virtual double getY();
194
199 virtual double getZ();
200
206 virtual double getVerticalOrientation();
207
213 virtual double getHorizontalOrientation();
214
219 virtual double getBearing();
220
227 friend std::ostream& operator<<( std::ostream& os, const Location& instance ) {
228 os << "Location, latitude = " << instance.curr_coordz.getLatitude() << "; longitude = " << instance.curr_coordz.getLongitude()
229 << "; depth = " << instance.curr_coordz.getDepth();
230 return os;
231 }
232
233 protected:
234
239
244
250
256
260 double bearing;
261
262 };
263
264}
265
266#endif /* LOCATION_DEFINITIONS_H */
3D-Coordinates (lat, long, depth) class definitions and functions library
Definition coordinates-definitions.h:384
constexpr bool isValid() const
Definition coordinates-definitions.h:616
constexpr double getDepth() const
Definition coordinates-definitions.h:498
constexpr double getLongitude() const
Definition coordinates-definitions.h:167
constexpr double getLatitude() const
Definition coordinates-definitions.h:161
Class that stores the coordinates of moving entity.
Definition location-definitions.h:52
double bearing
Definition location-definitions.h:260
virtual void setVerticalOrientation(double angle)
Definition location-definitions.cpp:83
virtual void setLocation(const CoordZ &coordz)
Definition location-definitions.cpp:63
virtual std::unique_ptr< Location > clone() const
Definition location-definitions.h:106
virtual double getLongitude()
Definition location-definitions.cpp:104
double comparison_distance
Definition location-definitions.h:238
virtual double getY()
Definition location-definitions.cpp:122
virtual double getVerticalOrientation()
Definition location-definitions.cpp:134
virtual double getLatitude()
Definition location-definitions.cpp:98
virtual void setLatitude(double lat)
Definition location-definitions.cpp:68
virtual void setHorizontalOrientation(double angle)
Definition location-definitions.cpp:88
virtual double getX()
Definition location-definitions.cpp:116
virtual double getZ()
Definition location-definitions.cpp:128
virtual ~Location()=default
virtual bool isValid() const
Definition location-definitions.h:112
virtual void setLongitude(double lon)
Definition location-definitions.cpp:73
Location(Location &&tmp)=default
virtual std::unique_ptr< Location > create(const CoordZ &coordz=CoordZ(), double dist=LOCATION_COMPARISON_DISTANCE) const
Definition location-definitions.h:99
virtual double getHorizontalOrientation()
Definition location-definitions.cpp:139
virtual CoordZ getLocation()
Definition location-definitions.cpp:93
virtual double getBearing()
Definition location-definitions.cpp:144
double vertical_orientation
Definition location-definitions.h:249
friend std::ostream & operator<<(std::ostream &os, const Location &instance)
Definition location-definitions.h:227
virtual double getDepth()
Definition location-definitions.cpp:110
Location & operator=(const Location &copy)=default
virtual bool isEquivalentTo(const woss::CoordZ &coordz)
Definition location-definitions.cpp:56
double horizontal_orientation
Definition location-definitions.h:255
virtual void setDepth(double depth)
Definition location-definitions.cpp:78
Location & operator=(Location &&tmp)=default
virtual std::unique_ptr< Location > create(double latitude, double longitude, double depth=0, double dist=LOCATION_COMPARISON_DISTANCE) const
Definition location-definitions.h:90
CoordZ curr_coordz
Definition location-definitions.h:243
Location(const Location &copy)=default
Provides the interface for the woss::Coord and woss::CoordZ classes.
Definition ac-toolbox-arr-asc-reader.h:44