diff options
| author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-10-31 14:41:14 +0000 |
|---|---|---|
| committer | <> | 2014-12-12 16:07:56 +0000 |
| commit | ed232fdd34968697a68783b3195b1da4226915b5 (patch) | |
| tree | 7a7053ceb8874b28ec4b868d4c49b500008a102e /libs/geometry/example | |
| parent | 1c3648bf5b7d17fcd4fe9bc95802b16fd9eee304 (diff) | |
| download | boost-tarball-ed232fdd34968697a68783b3195b1da4226915b5.tar.gz | |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_57_0.tar.bz2.boost_1_57_0
Diffstat (limited to 'libs/geometry/example')
| -rw-r--r-- | libs/geometry/example/07_a_graph_route_example.cpp | 16 | ||||
| -rw-r--r-- | libs/geometry/example/07_b_graph_route_example.cpp | 14 |
2 files changed, 11 insertions, 19 deletions
diff --git a/libs/geometry/example/07_a_graph_route_example.cpp b/libs/geometry/example/07_a_graph_route_example.cpp index 7bd4c6774..1b6786771 100644 --- a/libs/geometry/example/07_a_graph_route_example.cpp +++ b/libs/geometry/example/07_a_graph_route_example.cpp @@ -31,12 +31,8 @@ // For output: #include <boost/geometry/io/svg/svg_mapper.hpp> -// Yes, this example currently uses an extension: - // For distance-calculations over the Earth: //#include <boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp> -// Yes, this example currently uses some extensions: - // Read an ASCII file containing WKT's, fill a vector of tuples // The tuples consist of at least <0> a geometry and <1> an identifying string @@ -90,6 +86,9 @@ namespace boost BOOST_INSTALL_PROPERTY(edge, bg_property); } +// To calculate distance, declare and construct a strategy with average earth radius +boost::geometry::strategy::distance::haversine<double> const haversine(6372795.0); + // Define properties for vertex template <typename Point> struct bg_vertex_property @@ -99,8 +98,8 @@ struct bg_vertex_property boost::geometry::assign_zero(location); } bg_vertex_property(Point const& loc) + : location(loc) { - location = loc; } Point location; @@ -111,9 +110,9 @@ template <typename Linestring> struct bg_edge_property { bg_edge_property(Linestring const& line) - : m_line(line) + : m_length(boost::geometry::length(line, haversine)) + , m_line(line) { - m_length = boost::geometry::length(line); } inline operator double() const @@ -305,9 +304,6 @@ int main() std::cout << "distances, all in KM" << std::endl << std::fixed << std::setprecision(0); - // To calculate distance, declare and construct a strategy with average earth radius - boost::geometry::strategy::distance::haversine<double> haversine(6372795.0); - // Main functionality: calculate shortest routes from/to all cities diff --git a/libs/geometry/example/07_b_graph_route_example.cpp b/libs/geometry/example/07_b_graph_route_example.cpp index 5dedbf801..ca39839e7 100644 --- a/libs/geometry/example/07_b_graph_route_example.cpp +++ b/libs/geometry/example/07_b_graph_route_example.cpp @@ -34,8 +34,6 @@ // For output: #include <boost/geometry/io/svg/svg_mapper.hpp> -// Yes, this example currently uses an extension: - // For distance-calculations over the Earth: //#include <boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp> @@ -82,7 +80,8 @@ void read_wkt(std::string const& filename, std::vector<Tuple>& tuples, Box& box) } } - +// To calculate distance, declare and construct a strategy with average earth radius +boost::geometry::strategy::distance::haversine<double> const haversine(6372795.0); // Define properties for vertex template <typename Point> @@ -93,8 +92,8 @@ struct bg_vertex_property boost::geometry::assign_zero(location); } bg_vertex_property(Point const& loc) + : location(loc) { - location = loc; } Point location; @@ -105,9 +104,9 @@ template <typename Linestring> struct bg_edge_property { bg_edge_property(Linestring const& line) - : m_line(line) + : length(boost::geometry::length(line, haversine)) + , m_line(line) { - length = boost::geometry::length(line); } inline Linestring const& line() const @@ -292,9 +291,6 @@ int main() std::cout << "distances, all in KM" << std::endl << std::fixed << std::setprecision(0); - // To calculate distance, declare and construct a strategy with average earth radius - boost::geometry::strategy::distance::haversine<double> haversine(6372795.0); - // Main functionality: calculate shortest routes from/to all cities // For the first one, the complete route is stored as a linestring |
