CYCLUS
|
The Position class is a basic class that stores the geographic location of each agent in latitude and longitude and follows the ISO 6709 standard.
Allows string expression of Position objects as specified in ANNEX H of ISO 6709 found here: 'https://www.iso.org/standard/39242.html' or a quick simplified version found here 'https://en.wikipedia.org/wiki/ISO_6709'
Brief Description of ISO 6709:
The class is adapted from 'https://github.com/jaime-olivares/coordinate' under the MIT License.
Copyright (c) 2015 Jaime Olivares
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software") , to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Longitude and Latitude is stored as seconds of degrees. This was also adapted from 'https://github.com/jaime-olivares/coordinate'. This, according to the jaime-olivares, allows the coordinate elements such as degrees, minutes, and seconds to "remain on the integral portion of values, with the exception of decimal of seconds, avoiding loss of precision." This is calculated by multiplying decimal degrees by 3600. example: 05.2169 -> 18780.84
Definition at line 59 of file position.h.
#include <position.h>
Public Types | |
enum | StringFormat { DEGREES = 1 , DEGREES_MINUTES , DEGREES_MINUTES_SECONDS } |
Public Member Functions | |
double | Distance (Position target) const |
double | latitude () const |
void | latitude (double lat) |
double | longitude () const |
void | longitude (double lon) |
Position () | |
Position (double decimal_lat, double decimal_lon) | |
void | set_position (double lat, double lon) |
std::string | ToString (Position::StringFormat format=StringFormat::DEGREES) const |
~Position () | |
Enumerator | |
---|---|
DEGREES | |
DEGREES_MINUTES | |
DEGREES_MINUTES_SECONDS |
Definition at line 61 of file position.h.
cyclus::toolkit::Position::Position | ( | ) |
The default constructor for Position.
This will creat an object with lat=0, and long=0.
Definition at line 10 of file position.cc.
Position constructor with latitude and longditude as degrees as a double point precision floating point.
deciaml_lat | latitude expressed in degrees as a double. |
decimal_lon | longditude expressed in degrees as a double. |
Definition at line 12 of file position.cc.
cyclus::toolkit::Position::~Position | ( | ) |
The default destructor for Position.
Definition at line 19 of file position.cc.
Returns the distance (in km) between this Position object and the target Position object.
target | the Position object some distnace away from the current one |
Definition at line 66 of file position.cc.
double cyclus::toolkit::Position::latitude | ( | ) | const |
Returns the current latitude.
Definition at line 21 of file position.cc.
Sets a new latitude.
lat | latitude expressed in decimal degrees. |
Definition at line 29 of file position.cc.
double cyclus::toolkit::Position::longitude | ( | ) | const |
Returns the current longitude.
Definition at line 25 of file position.cc.
Sets a new longitude.
lon | longitude expressed in decimal degrees. |
Definition at line 34 of file position.cc.
Sets a new latitude and longitude.
lat | latitude, and lon longitude expressed in decimal degrees. |
Definition at line 39 of file position.cc.
std::string cyclus::toolkit::Position::ToString | ( | Position::StringFormat | format = StringFormat::DEGREES | ) | const |
Converts Position location into a string expression that follows ISO 6709 Annex H.
Function can be passed without any parameters for degrees format.
return_format_ | @parblock_ The format of output. Options are 'Position::StringFormat::DEGREES', 'Position::StringFormat::DEGREES_ MINUTES_', 'Position::StringFormat::DEGREES_ MINUTES_ _ SECONDS': |
Position::StringFormat::DEGREES :return in degrees format Position::StringFormat::DEGREES_MINUTES :return in degrees and minutes format Position::StringFormat::DEGREES_MINUTES_SECONDS:return in degrees minutes seconds format
Definition at line 84 of file position.cc.