CYCLUS
Loading...
Searching...
No Matches
cyclus::toolkit::Position Class Reference

Detailed Description

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:

  1. Latitude comes before Longitude
  2. North latitude is positive
  3. East longitude is positive
  4. Fraction of degrees (decimal values) is prefered in digital data exchange.

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 ()
 

Member Enumeration Documentation

◆ StringFormat

Enumerator
DEGREES 
DEGREES_MINUTES 
DEGREES_MINUTES_SECONDS 

Definition at line 61 of file position.h.

Constructor & Destructor Documentation

◆ Position() [1/2]

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() [2/2]

cyclus::toolkit::Position::Position ( double decimal_lat,
double decimal_lon )

Position constructor with latitude and longditude as degrees as a double point precision floating point.

Parameters
deciaml_latlatitude expressed in degrees as a double.
decimal_lonlongditude expressed in degrees as a double.

Definition at line 12 of file position.cc.

◆ ~Position()

cyclus::toolkit::Position::~Position ( )

The default destructor for Position.

Definition at line 19 of file position.cc.

Member Function Documentation

◆ Distance()

double cyclus::toolkit::Position::Distance ( Position target) const

Returns the distance (in km) between this Position object and the target Position object.

Parameters
targetthe Position object some distnace away from the current one
Returns
distance between this and target in kilometers

Definition at line 66 of file position.cc.

◆ latitude() [1/2]

double cyclus::toolkit::Position::latitude ( ) const

Returns the current latitude.

Returns
decimal representation of latitude.

Definition at line 21 of file position.cc.

◆ latitude() [2/2]

void cyclus::toolkit::Position::latitude ( double lat)

Sets a new latitude.

Parameters
latlatitude expressed in decimal degrees.

Definition at line 29 of file position.cc.

◆ longitude() [1/2]

double cyclus::toolkit::Position::longitude ( ) const

Returns the current longitude.

Returns
decimal representation of longitude.

Definition at line 25 of file position.cc.

◆ longitude() [2/2]

void cyclus::toolkit::Position::longitude ( double lon)

Sets a new longitude.

Parameters
lonlongitude expressed in decimal degrees.

Definition at line 34 of file position.cc.

◆ set_position()

void cyclus::toolkit::Position::set_position ( double lat,
double lon )

Sets a new latitude and longitude.

Parameters
latlatitude, and lon longitude expressed in decimal degrees.

Definition at line 39 of file position.cc.

◆ ToString()

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.

Parameters
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

Returns
String representation of the Position object that complies with ISO6709 Annex H

Definition at line 84 of file position.cc.


The documentation for this class was generated from the following files: