A library for working with phylogenetic and population genetic data.
v0.27.0
utils/tools/geodesy/functions.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_UTILS_TOOLS_GEODESY_FUNCTIONS_H_
2 #define GENESIS_UTILS_TOOLS_GEODESY_FUNCTIONS_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2018 Lucas Czech and HITS gGmbH
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 as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
35 
36 #include <iosfwd>
37 #include <string>
38 
39 namespace genesis {
40 namespace utils {
41 
42 // =================================================================================================
43 // World Constants
44 // =================================================================================================
45 
49 constexpr double EARTH_MEAN_RADIUS = 6371.0;
50 
51 // =================================================================================================
52 // Coordinate Conversion
53 // =================================================================================================
54 
68 std::string sanitize_geo_coordinate( std::string const& coordinate, bool two_components = true );
69 
76 GeoCoordinate convert_geo_coordinate( std::string const& latitude, std::string const& longitude );
77 
111 GeoCoordinate convert_geo_coordinate( std::string const& coordinate );
112 
113 // =================================================================================================
114 // Distance
115 // =================================================================================================
116 
124 double geo_distance( GeoCoordinate const& c1, GeoCoordinate const& c2 );
125 
126 // =================================================================================================
127 // Printing
128 // =================================================================================================
129 
130 std::ostream& operator<< ( std::ostream& os, GeoCoordinate const& coord );
131 
132 } // namespace utils
133 } // namespace genesis
134 
135 #endif // include guard
genesis::utils::operator<<
std::ostream & operator<<(std::ostream &os, const Matrix< signed char > &matrix)
Template specialization for signed char, in order to print nicely.
Definition: utils/containers/matrix/operators.cpp:89
genesis::utils::GeoCoordinate
Geographical coordinates in degrees.
Definition: geo_coordinate.hpp:46
genesis::utils::sanitize_geo_coordinate
std::string sanitize_geo_coordinate(std::string const &coordinates, bool two_components)
Replace non-ascii symbols used in geographic coordinates by their ascii equivalents.
Definition: utils/tools/geodesy/functions.cpp:198
geo_coordinate.hpp
genesis::utils::EARTH_MEAN_RADIUS
constexpr double EARTH_MEAN_RADIUS
Earth is not flat!
Definition: utils/tools/geodesy/functions.hpp:49
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::utils::convert_geo_coordinate
GeoCoordinate convert_geo_coordinate(std::string const &latitude, std::string const &longitude)
Parse strings of geographic coordinates.
Definition: utils/tools/geodesy/functions.cpp:250
genesis::utils::geo_distance
double geo_distance(GeoCoordinate const &c1, GeoCoordinate const &c2)
Calculate the distance (in km) between two points on Earth.
Definition: utils/tools/geodesy/functions.cpp:317