From 2278e697d02fbcae0a88a655ec9cb4958272b7ea Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 14 Oct 2014 01:34:39 +0200 Subject: [PATCH 01/14] [read_wkt] Don't append duplicated, closing Points in open Rings/Polygons. Note that Points are still appended if there is not enough Points in the input, i.e. the number is < 3 for open Rings. --- include/boost/geometry/io/wkt/read.hpp | 57 ++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index 748eecdbe..62e7febbc 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -4,6 +4,11 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -29,6 +34,7 @@ #include #include #include +#include #include #include @@ -231,18 +237,18 @@ struct container_inserter template struct container_appender { - typedef typename geometry::point_type - < - typename boost::remove_reference::type - >::type point_type; + typedef typename boost::remove_reference::type bare_geometry; + typedef typename geometry::point_type::type point_type; static inline void apply(tokenizer::iterator& it, tokenizer::iterator end, - std::string const& wkt, Geometry out) + std::string const& wkt, Geometry out) { handle_open_parenthesis(it, end, wkt); point_type point; - + point_type first_point; + typename boost::range_size::type pt_index = 0; + // Parse points until closing parenthesis while (it != end && *it != ")") @@ -254,8 +260,43 @@ struct container_appender dimension::value >::apply(it, end, point, wkt); - geometry::append(out, point); - if (it != end && *it == ",") + bool should_append = true; + bool const is_next_expected = it != end && *it == ","; + + if ( closure::value == open ) + { + // sanity check - only Rings, Polygons and MultiPolygons may be open + // this is important for the minimum_ring_size condition + BOOST_STATIC_ASSERT(( closure::value != open + || boost::is_same::type, + areal_tag + >::type, areal_tag>::value + )); + + if ( pt_index == 0 ) + { + first_point = point; + should_append = true; + } + else + { + // NOTE: if there is not enough Points, they're always appended + should_append + = is_next_expected + || pt_index < core_detail::closure::minimum_ring_size::value + || !detail::equals::equals_point_point(point, first_point); + } + ++pt_index; + } + + if ( should_append ) + { + geometry::append(out, point); + } + + if ( is_next_expected ) { ++it; } From 743d4fadd47c31bf54575903d22ecc3ade6fdc5b Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 14 Oct 2014 01:38:48 +0200 Subject: [PATCH 02/14] [test] Update tests to be in line with the change in behavior of read_wkt() for open Rings. --- test/algorithms/is_valid.cpp | 6 +-- test/algorithms/num_points.cpp | 6 +-- test/algorithms/test_within.hpp | 4 -- test/io/wkt/wkt.cpp | 61 ++++++++++++++++++++++++++++--- test/iterators/point_iterator.cpp | 10 +++++ test/multi/io/wkt/multi_wkt.cpp | 34 +++++++++++++++++ 6 files changed, 106 insertions(+), 15 deletions(-) diff --git a/test/algorithms/is_valid.cpp b/test/algorithms/is_valid.cpp index 46c2c6772..2fc8402cb 100644 --- a/test/algorithms/is_valid.cpp +++ b/test/algorithms/is_valid.cpp @@ -280,7 +280,7 @@ void test_open_rings() test::apply(from_wkt("POLYGON((0 0,0 0,0 0))"), false); test::apply(from_wkt("POLYGON((0 0,1 0,1 0))"), false); test::apply(from_wkt("POLYGON((0 0,1 0,0 0))"), false); - test::apply(from_wkt("POLYGON((0 0,1 0,1 1,0 0))"), + test::apply(from_wkt("POLYGON((0 0,1 0,1 1,0 0,0 0))"), AllowDuplicates); test::apply(from_wkt("POLYGON((0 0,1 0,1 0,1 1))"), AllowDuplicates); @@ -426,7 +426,7 @@ void test_open_polygons() test::apply(from_wkt("POLYGON((0 0,0 0,0 0))"), false); test::apply(from_wkt("POLYGON((0 0,1 0,1 0))"), false); test::apply(from_wkt("POLYGON((0 0,1 0,0 0))"), false); - test::apply(from_wkt("POLYGON((0 0,1 0,1 1,0 0))"), AllowDuplicates); + test::apply(from_wkt("POLYGON((0 0,1 0,1 1,0 0,0 0))"), AllowDuplicates); test::apply(from_wkt("POLYGON((0 0,1 0,1 0,1 1))"), AllowDuplicates); test::apply(from_wkt("POLYGON((0 0,1 0,1 0,1 1,0 0))"), AllowDuplicates); @@ -438,7 +438,7 @@ void test_open_polygons() false); test::apply(from_wkt("POLYGON((0 0,10 0,10 10,0 10),(1 1,2 1,1 1))"), false); - test::apply(from_wkt("POLYGON((0 0,10 0,10 10,0 10),(1 1,2 2,2 1,1 1))"), + test::apply(from_wkt("POLYGON((0 0,10 0,10 10,0 10),(1 1,2 2,2 1,1 1,1 1))"), AllowDuplicates); test::apply(from_wkt("POLYGON((0 0,10 0,10 10,0 10),(1 1,2 2,2 2,2 1))"), AllowDuplicates); diff --git a/test/algorithms/num_points.cpp b/test/algorithms/num_points.cpp index d1f58b299..1c266d8af 100644 --- a/test/algorithms/num_points.cpp +++ b/test/algorithms/num_points.cpp @@ -86,11 +86,11 @@ int test_main(int, char* []) // test open geometries test_num_points("POLYGON((0 0,1 1,0 1))", 3u, 4u); - test_num_points("POLYGON((0 0,1 1,0 1,0 0))", 4u, 5u); + test_num_points("POLYGON((0 0,1 1,0 1,0 0))", 3u, 4u); test_num_points("POLYGON((0 0,10 10,0 10))", 3u, 4u); - test_num_points("POLYGON((0 0,10 10,0 10,0 0))", 4u, 5u); + test_num_points("POLYGON((0 0,10 10,0 10,0 0))", 3u, 4u); test_num_points("MULTIPOLYGON(((0 0,0 10,10 10,10 0)),((0 10,1 10,1 9)))", 7u, 9u); - test_num_points("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 9u, 11u); + test_num_points("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 7u, 9u); return 0; } diff --git a/test/algorithms/test_within.hpp b/test/algorithms/test_within.hpp index da402a07c..0fc3b1b01 100644 --- a/test/algorithms/test_within.hpp +++ b/test/algorithms/test_within.hpp @@ -88,10 +88,6 @@ void test_ordered_ring(std::string const& wkt_point, { std::reverse(boost::begin(ring), boost::end(ring)); } - if (! Closed) - { - ring.resize(ring.size() - 1); - } bg::read_wkt(wkt_point, point); diff --git a/test/io/wkt/wkt.cpp b/test/io/wkt/wkt.cpp index 72badd383..40fb04acf 100644 --- a/test/io/wkt/wkt.cpp +++ b/test/io/wkt/wkt.cpp @@ -5,6 +5,11 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -42,8 +47,8 @@ void check_wkt(G const& geometry, std::string const& expected) } template -void test_wkt(std::string const& wkt, std::size_t n, double len = 0, - double ar = 0, double peri = 0) +void test_wkt(std::string const& wkt, std::string const& expected, + std::size_t n, double len = 0, double ar = 0, double peri = 0) { G geometry; @@ -67,8 +72,15 @@ void test_wkt(std::string const& wkt, std::size_t n, double len = 0, BOOST_CHECK_CLOSE(double(bg::perimeter(geometry)), peri, 0.0001); } - check_wkt(geometry, wkt); - check_wkt(boost::variant(geometry), wkt); + check_wkt(geometry, expected); + check_wkt(boost::variant(geometry), expected); +} + +template +void test_wkt(std::string const& wkt, + std::size_t n, double len = 0, double ar = 0, double peri = 0) +{ + test_wkt(wkt, wkt, n, len, ar, peri); } template @@ -135,6 +147,44 @@ void test_wkt_output_iterator(std::string const& wkt) #ifndef GEOMETRY_TEST_MULTI +template +void test_order_closure() +{ + using namespace boost::geometry; + typedef bg::model::point Pt; + typedef bg::model::polygon PCWC; + typedef bg::model::polygon PCWO; + typedef bg::model::polygon PCCWC; + typedef bg::model::polygon PCCWO; + + { + std::string wkt_cwc = "POLYGON((0 0,0 2,2 2,2 0,0 0))"; + std::string wkt_cwo = "POLYGON((0 0,0 2,2 2,2 0))"; + std::string wkt_ccwc = "POLYGON((0 0,2 0,2 2,0 2,0 0))"; + std::string wkt_ccwo = "POLYGON((0 0,2 0,2 2,0 2))"; + + test_wkt(wkt_cwc, 5, 0, 4, 8); + test_wkt(wkt_cwc, 4, 0, 4, 8); + test_wkt(wkt_cwo, wkt_cwc, 4, 0, 4, 8); + test_wkt(wkt_ccwc, 5, 0, 4, 8); + test_wkt(wkt_ccwc, 4, 0, 4, 8); + test_wkt(wkt_ccwo, wkt_ccwc, 4, 0, 4, 8); + } + { + std::string wkt_cwc = "POLYGON((0 0,0 3,3 3,3 0,0 0),(1 1,2 1,2 2,1 2,1 1))"; + std::string wkt_cwo = "POLYGON((0 0,0 3,3 3,3 0),(1 1,2 1,2 2,1 2))"; + std::string wkt_ccwc = "POLYGON((0 0,3 0,3 3,0 3,0 0),(1 1,1 2,2 2,2 1,1 1))"; + std::string wkt_ccwo = "POLYGON((0 0,3 0,3 3,0 3),(1 1,1 2,2 2,2 1,1 1))"; + + test_wkt(wkt_cwc, 10, 0, 8, 16); + test_wkt(wkt_cwc, 8, 0, 8, 16); + test_wkt(wkt_cwo, wkt_cwc, 8, 0, 8, 16); + test_wkt(wkt_ccwc, 10, 0, 8, 16); + test_wkt(wkt_ccwc, 8, 0, 8, 16); + test_wkt(wkt_ccwo, wkt_ccwc, 8, 0, 8, 16); + } +} + template void test_all() { @@ -201,10 +251,11 @@ void test_all() // Deprecated: // test_wkt_output_iterator >("LINESTRING(1 1,2 2,3 3)"); // test_wkt_output_iterator >("POLYGON((1 1,2 2,3 3))"); + + test_order_closure(); } #endif - int test_main(int, char* []) { test_all(); diff --git a/test/iterators/point_iterator.cpp b/test/iterators/point_iterator.cpp index dff15eabe..1277a9351 100644 --- a/test/iterators/point_iterator.cpp +++ b/test/iterators/point_iterator.cpp @@ -217,6 +217,16 @@ struct test_point_iterator_of_geometry bg::points_end(point_range)) ); + if ( !equals::apply(begin, end, + bg::points_begin(point_range), + bg::points_end(point_range) ) ) + { + equals::apply(begin, end, + bg::points_begin(point_range), + bg::points_end(point_range) ); + int a = 10; + } + #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << header << " geometry: " << bg::wkt(geometry) << std::endl; print_point_range(std::cout, begin, end, "point range: "); diff --git a/test/multi/io/wkt/multi_wkt.cpp b/test/multi/io/wkt/multi_wkt.cpp index 317f0578c..35265feee 100644 --- a/test/multi/io/wkt/multi_wkt.cpp +++ b/test/multi/io/wkt/multi_wkt.cpp @@ -5,6 +5,11 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -45,6 +50,33 @@ void test_all(); #define GEOMETRY_TEST_MULTI #include "io/wkt/wkt.cpp" +template +void test_order_closure() +{ + using namespace boost::geometry; + typedef bg::model::point Pt; + typedef bg::model::polygon PCWC; + typedef bg::model::polygon PCWO; + typedef bg::model::polygon PCCWC; + typedef bg::model::polygon PCCWO; + typedef bg::model::multi_polygon MPCWC; + typedef bg::model::multi_polygon MPCWO; + typedef bg::model::multi_polygon MPCCWC; + typedef bg::model::multi_polygon MPCCWO; + + std::string wkt_cwc = "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((0 0,0 -3,-3 -3,-3 0,0 0),(-1 -1,-2 -1,-2 -2,-1 -2,-1 -1)))"; + std::string wkt_cwo = "MULTIPOLYGON(((0 0,0 2,2 2,2 0)),((0 0,0 -3,-3 -3,-3 0),(-1 -1,-2 -1,-2 -2,-1 -2)))"; + std::string wkt_ccwc = "MULTIPOLYGON(((0 0,2 0,2 2,0 2,0 0)),((0 0,-3 0,-3 -3,0 -3,0 0),(-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))"; + std::string wkt_ccwo = "MULTIPOLYGON(((0 0,2 0,2 2,0 2)),((0 0,-3 0,-3 -3,0 -3),(-1 -1,-1 -2,-2 -2,-2 -1)))"; + + test_wkt(wkt_cwc, wkt_cwc, 15, 0, 12, 24); + test_wkt(wkt_cwc, wkt_cwc, 12, 0, 12, 24); + test_wkt(wkt_cwo, wkt_cwc, 12, 0, 12, 24); + test_wkt(wkt_ccwc, wkt_ccwc, 15, 0, 12, 24); + test_wkt(wkt_ccwc, wkt_ccwc, 12, 0, 12, 24); + test_wkt(wkt_ccwo, wkt_ccwc, 12, 0, 12, 24); +} + template void test_all() { @@ -79,6 +111,8 @@ void test_all() test_wrong_wkt >( "MULTIPOINT(16 17), (18 19)", "too much tokens at ',' in 'multipoint(16 17), (18 19)'"); + + test_order_closure(); } /* From 6319a7da6a7ea0b9b839977cc44ea4234209ba00 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 14 Oct 2014 11:32:25 +0200 Subject: [PATCH 03/14] [test] Remove temporary/unneeded code in point_iterator test. --- test/iterators/point_iterator.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/iterators/point_iterator.cpp b/test/iterators/point_iterator.cpp index 1277a9351..dff15eabe 100644 --- a/test/iterators/point_iterator.cpp +++ b/test/iterators/point_iterator.cpp @@ -217,16 +217,6 @@ struct test_point_iterator_of_geometry bg::points_end(point_range)) ); - if ( !equals::apply(begin, end, - bg::points_begin(point_range), - bg::points_end(point_range) ) ) - { - equals::apply(begin, end, - bg::points_begin(point_range), - bg::points_end(point_range) ); - int a = 10; - } - #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << header << " geometry: " << bg::wkt(geometry) << std::endl; print_point_range(std::cout, begin, end, "point range: "); From ce726833f86fffc61b34a2d9a9233c51f9aee6a5 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 15 Oct 2014 01:19:15 +0200 Subject: [PATCH 04/14] [from_wkt] Move the appending logic outside container_appender and dispatch by closure. --- include/boost/geometry/io/wkt/read.hpp | 108 ++++++++++++++++--------- 1 file changed, 70 insertions(+), 38 deletions(-) diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index 62e7febbc..7433ac3b6 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -233,6 +234,70 @@ struct container_inserter }; +template ::type + >::value> +struct stateful_range_appender +{ + typedef typename boost::remove_reference::type bare_geometry; + typedef typename geometry::point_type::type point_type; + + inline void append(Geometry & geom, point_type const& point, bool) + { + geometry::append(geom, point); + } +}; + +template +struct stateful_range_appender +{ + typedef typename boost::remove_reference::type bare_geometry; + typedef typename geometry::point_type::type point_type; + typedef typename boost::range_size::type size_type; + + BOOST_STATIC_ASSERT(( boost::is_same + < + typename tag::type, + ring_tag + >::value )); + + inline stateful_range_appender() + : pt_index(0) + {} + + inline void append(Geometry & geom, point_type const& point, bool is_next_expected) + { + bool should_append = true; + + if ( pt_index == 0 ) + { + first_point = point; + //should_append = true; + } + else + { + // NOTE: if there is not enough Points, they're always appended + should_append + = is_next_expected + || pt_index < core_detail::closure::minimum_ring_size::value + || !detail::equals::equals_point_point(point, first_point); + } + ++pt_index; + + if ( should_append ) + { + geometry::append(geom, point); + } + } + +private: + size_type pt_index; + point_type first_point; +}; + // Geometry is a value-type or reference-type template struct container_appender @@ -245,14 +310,13 @@ struct container_appender { handle_open_parenthesis(it, end, wkt); - point_type point; - point_type first_point; - typename boost::range_size::type pt_index = 0; - - // Parse points until closing parenthesis + stateful_range_appender appender; + // Parse points until closing parenthesis while (it != end && *it != ")") { + point_type point; + parsing_assigner < point_type, @@ -260,41 +324,9 @@ struct container_appender dimension::value >::apply(it, end, point, wkt); - bool should_append = true; bool const is_next_expected = it != end && *it == ","; - - if ( closure::value == open ) - { - // sanity check - only Rings, Polygons and MultiPolygons may be open - // this is important for the minimum_ring_size condition - BOOST_STATIC_ASSERT(( closure::value != open - || boost::is_same::type, - areal_tag - >::type, areal_tag>::value - )); - if ( pt_index == 0 ) - { - first_point = point; - should_append = true; - } - else - { - // NOTE: if there is not enough Points, they're always appended - should_append - = is_next_expected - || pt_index < core_detail::closure::minimum_ring_size::value - || !detail::equals::equals_point_point(point, first_point); - } - ++pt_index; - } - - if ( should_append ) - { - geometry::append(out, point); - } + appender.append(out, point, is_next_expected); if ( is_next_expected ) { From 47d18eda0bcd81b9f9ffb45c59265dd8b43d2732 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 15 Oct 2014 03:05:28 +0200 Subject: [PATCH 05/14] [from_wkt] Add default template parameters to parsing_assigner. --- include/boost/geometry/io/wkt/read.hpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index 7433ac3b6..236111d81 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -105,7 +105,9 @@ namespace detail { namespace wkt typedef boost::tokenizer > tokenizer; -template +template ::value> struct parsing_assigner { static inline void apply(tokenizer::iterator& it, tokenizer::iterator end, @@ -215,12 +217,7 @@ struct container_inserter while (it != end && *it != ")") { - parsing_assigner - < - Point, - 0, - dimension::value - >::apply(it, end, point, wkt); + parsing_assigner::apply(it, end, point, wkt); out = point; ++out; if (it != end && *it == ",") @@ -317,12 +314,7 @@ struct container_appender { point_type point; - parsing_assigner - < - point_type, - 0, - dimension::value - >::apply(it, end, point, wkt); + parsing_assigner::apply(it, end, point, wkt); bool const is_next_expected = it != end && *it == ","; @@ -349,7 +341,7 @@ struct point_parser std::string const& wkt, P& point) { handle_open_parenthesis(it, end, wkt); - parsing_assigner::value>::apply(it, end, point, wkt); + parsing_assigner

::apply(it, end, point, wkt); handle_close_parenthesis(it, end, wkt); } }; @@ -585,7 +577,7 @@ struct noparenthesis_point_parser static inline void apply(tokenizer::iterator& it, tokenizer::iterator end, std::string const& wkt, P& point) { - parsing_assigner::value>::apply(it, end, point, wkt); + parsing_assigner

::apply(it, end, point, wkt); } }; From f98ec5b2c33de05948199378ce7b141f924c7566 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 16 Oct 2014 16:48:42 +0200 Subject: [PATCH 06/14] [read_wkt] Remove unnecessary remove_reference usage. --- include/boost/geometry/io/wkt/read.hpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index 236111d81..033c96a0a 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -232,15 +232,10 @@ struct container_inserter template ::type - >::value> + closure_selector Closure = closure::value> struct stateful_range_appender { - typedef typename boost::remove_reference::type bare_geometry; - typedef typename geometry::point_type::type point_type; + typedef typename geometry::point_type::type point_type; inline void append(Geometry & geom, point_type const& point, bool) { @@ -251,13 +246,15 @@ struct stateful_range_appender template struct stateful_range_appender { - typedef typename boost::remove_reference::type bare_geometry; - typedef typename geometry::point_type::type point_type; - typedef typename boost::range_size::type size_type; + typedef typename geometry::point_type::type point_type; + typedef typename boost::range_size + < + typename util::bare_type::type + >::type size_type; BOOST_STATIC_ASSERT(( boost::is_same < - typename tag::type, + typename tag::type, ring_tag >::value )); @@ -299,8 +296,7 @@ private: template struct container_appender { - typedef typename boost::remove_reference::type bare_geometry; - typedef typename geometry::point_type::type point_type; + typedef typename geometry::point_type::type point_type; static inline void apply(tokenizer::iterator& it, tokenizer::iterator end, std::string const& wkt, Geometry out) From 694aaa9d31007fbde5bdb0670778bb63ed2e8ec0 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 16 Nov 2014 18:26:48 +0100 Subject: [PATCH 07/14] [core] Add sphere and spheroid reference models. Add new tags for reference sphere/spheroid concepts. Add cs::model::sphere<> and cs::model::spheroid<>. Add get_radius(), set_radius() and radius_type<> functions/metafunctions. Add tests. Refactor [extensions] nsphere to use the official functions. --- extensions/test/nsphere/nsphere-circle.cpp | 2 +- include/boost/geometry/core/cs_model.hpp | 204 ++++++++++++++ include/boost/geometry/core/radius.hpp | 250 ++++++++++++++++++ include/boost/geometry/core/tags.hpp | 13 + .../extensions/nsphere/core/radius.hpp | 116 +------- .../extensions/nsphere/geometries/nsphere.hpp | 2 +- include/boost/geometry/geometry.hpp | 8 + test/core/Jamfile.v2 | 1 + test/core/radius.cpp | 63 +++++ 9 files changed, 550 insertions(+), 109 deletions(-) create mode 100644 include/boost/geometry/core/cs_model.hpp create mode 100644 include/boost/geometry/core/radius.hpp create mode 100644 test/core/radius.cpp diff --git a/extensions/test/nsphere/nsphere-circle.cpp b/extensions/test/nsphere/nsphere-circle.cpp index a88bc9b28..f4ae392e2 100644 --- a/extensions/test/nsphere/nsphere-circle.cpp +++ b/extensions/test/nsphere/nsphere-circle.cpp @@ -81,7 +81,7 @@ struct access }; template<> -struct radius_access +struct radius_access { static inline int get(custom_circle const& c) { diff --git a/include/boost/geometry/core/cs_model.hpp b/include/boost/geometry/core/cs_model.hpp new file mode 100644 index 000000000..de639bc33 --- /dev/null +++ b/include/boost/geometry/core/cs_model.hpp @@ -0,0 +1,204 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_CS_MODEL_HPP +#define BOOST_GEOMETRY_CORE_CS_MODEL_HPP + + +#include + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace cs { namespace model +{ + +/*! + \brief Defines spheroid radius values for use in geographical CS calculations + \note See http://en.wikipedia.org/wiki/Figure_of_the_Earth + and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84 + \note +*/ +template +class spheroid +{ +public: + spheroid(RadiusType const& a, RadiusType const& b) + : m_a(a) + , m_b(b) + {} + + spheroid() + : m_a(RadiusType(6378137.0)) + , m_b(RadiusType(6356752.314245)) + {} + + template + RadiusType get_radius() const + { + BOOST_STATIC_ASSERT(I < 3); + + if ( I < 2 ) + return m_a; + else + return m_b; + } + + template + void set_radius(RadiusType const& radius) + { + BOOST_STATIC_ASSERT(I < 3); + + if ( I < 2 ) + m_a = radius; + else + m_b = radius; + } + +private: + RadiusType m_a, m_b; // equatorial radius, polar radius +}; + + +}} // namespace cs::model + +// Traits specializations for spheroid +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +struct tag< cs::model::spheroid > +{ + typedef reference_spheroid_tag type; +}; + +template +struct radius_type< cs::model::spheroid > +{ + typedef RadiusType type; +}; + +template +struct radius_access, Dimension> +{ + typedef cs::model::spheroid spheroid_type; + + static inline RadiusType get(spheroid_type const& s) + { + return s.template get_radius(); + } + + static inline void set(spheroid_type& s, RadiusType const& value) + { + s.template set_radius(value); + } +}; + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +namespace cs { namespace model +{ + +/*! + \brief Defines sphere radius value for use in spherical CS calculations + \note +*/ +template +class sphere +{ +public: + explicit sphere(RadiusType const& r) + : m_r(r) + {} + sphere() + : m_r(RadiusType((2.0 * 6378137.0 + 6356752.314245) / 3.0)) + {} + + template + RadiusType get_radius() const + { + BOOST_STATIC_ASSERT(I < 3); + + return m_r; + } + + template + void set_radius(RadiusType const& radius) + { + BOOST_STATIC_ASSERT(I < 3); + + m_r = radius; + } + +private: + RadiusType m_r; // radius +}; + + +}} // namespace cs::model + +// Traits specializations for sphere +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +struct tag< cs::model::sphere > +{ + typedef reference_sphere_tag type; +}; + +template +struct radius_type< cs::model::sphere > +{ + typedef RadiusType type; +}; + +template +struct radius_access, Dimension> +{ + typedef cs::model::sphere sphere_type; + + static inline RadiusType get(sphere_type const& s) + { + return s.template get_radius(); + } + + static inline void set(sphere_type& s, RadiusType const& value) + { + s.template set_radius(value); + } +}; + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_CS_MODEL_HPP diff --git a/include/boost/geometry/core/radius.hpp b/include/boost/geometry/core/radius.hpp new file mode 100644 index 000000000..0a30a9cda --- /dev/null +++ b/include/boost/geometry/core/radius.hpp @@ -0,0 +1,250 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_CORE_RADIUS_HPP +#define BOOST_GEOMETRY_CORE_RADIUS_HPP + + +#include + +#include + +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + +/*! + \brief Traits class to get/set radius of a circle/sphere/(ellipse) + \details the radius access meta-functions give read/write access to the radius of a circle or a sphere, + or to the major/minor axis or an ellipse, or to one of the 3 equatorial radii of an ellipsoid. + + It should be specialized per geometry, in namespace core_dispatch. Those specializations should + forward the call via traits to the geometry class, which could be specified by the user. + + There is a corresponding generic radius_get and radius_set function + \par Geometries: + - n-sphere (circle,sphere) + - upcoming ellipse + \par Specializations should provide: + - inline static T get(G const& geometry) + - inline static void set(G& geometry, T const& radius) + \ingroup traits +*/ +template +struct radius_access {}; + + +/*! + \brief Traits class indicating the type (double,float,...) of the radius of a circle or a sphere + \par Geometries: + - n-sphere (circle,sphere) + - upcoming ellipse + \par Specializations should provide: + - typedef T type (double,float,int,etc) + \ingroup traits +*/ +template +struct radius_type {}; + +} // namespace traits + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template +struct radius_type +{ + //typedef core_dispatch_specialization_required type; +}; + +/*! + \brief radius access meta-functions, used by concept n-sphere and upcoming ellipse. +*/ +template +struct radius_access +{ + //static inline CoordinateType get(Geometry const& ) {} + //static inline void set(Geometry& g, CoordinateType const& value) {} +}; + +} // namespace core_dispatch +#endif // DOXYGEN_NO_DISPATCH + + +/*! + \brief Metafunction to get the type of radius of a circle / sphere / ellipse / etc. + \ingroup access + \tparam Geometry the type of geometry +*/ +template +struct radius_type +{ + typedef typename core_dispatch::radius_type + < + typename tag::type, + typename util::bare_type::type + >::type type; +}; + +/*! + \brief Function to get radius of a circle / sphere / ellipse / etc. + \return radius The radius for a given axis + \ingroup access + \param geometry the geometry to get the radius from + \tparam I index of the axis +*/ +template +inline typename radius_type::type get_radius(Geometry const& geometry) +{ + return core_dispatch::radius_access + < + typename tag::type, + typename util::bare_type::type, + I, + typename boost::is_pointer::type + >::get(geometry); +} + +/*! + \brief Function to set the radius of a circle / sphere / ellipse / etc. + \ingroup access + \tparam I index of the axis + \param geometry the geometry to change + \param radius the radius to set +*/ +template +inline void set_radius(Geometry& geometry, + typename radius_type::type const& radius) +{ + core_dispatch::radius_access + < + typename tag::type, + typename util::bare_type::type, + I, + typename boost::is_pointer::type + >::set(geometry, radius); +} + + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template +struct radius_access +{ + static inline typename radius_type::type get(Geometry const& geometry) + { + return traits::radius_access::get(geometry); + } + static inline void set(Geometry& geometry, + typename radius_type::type const& value) + { + traits::radius_access::set(geometry, value); + } +}; + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template +struct radius_access +{ + typedef typename geometry::radius_type::type radius_type; + + static inline radius_type get(const Geometry * geometry) + { + return radius_access + < + Tag, + Geometry, + Dimension, + typename boost::is_pointer::type + >::get(*geometry); + } + + static inline void set(Geometry * geometry, radius_type const& value) + { + return radius_access + < + Tag, + Geometry, + Dimension, + typename boost::is_pointer::type + >::set(*geometry, value); + } +}; + + +template +struct radius_type +{ + typedef typename traits::radius_type::type type; +}; + +template +struct radius_access + : detail::radius_access +{ + BOOST_STATIC_ASSERT(Dimension == 0); + //BOOST_STATIC_ASSERT(Dimension < 3); +}; + +template +struct radius_type +{ + typedef typename traits::radius_type::type type; +}; + +template +struct radius_access + : detail::radius_access +{ + BOOST_STATIC_ASSERT(Dimension == 0 || Dimension == 2); + //BOOST_STATIC_ASSERT(Dimension < 3); +}; + +} // namespace core_dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_RADIUS_HPP diff --git a/include/boost/geometry/core/tags.hpp b/include/boost/geometry/core/tags.hpp index 160477b8c..d3cdbd6bd 100644 --- a/include/boost/geometry/core/tags.hpp +++ b/include/boost/geometry/core/tags.hpp @@ -4,6 +4,11 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -37,6 +42,14 @@ struct spherical_equatorial_tag : spherical_tag {}; struct geographic_tag : spherical_tag {}; +// Tags defining coordinate systems reference models + +/// For reference sphere defining parameters of spherical coordinate system +struct reference_sphere_tag {}; + +/// For reference spheroid defining parameters of geographical coordinate system +struct reference_spheroid_tag {}; + // Tags defining tag hierarchy diff --git a/include/boost/geometry/extensions/nsphere/core/radius.hpp b/include/boost/geometry/extensions/nsphere/core/radius.hpp index 2e3e8704a..331b7243a 100644 --- a/include/boost/geometry/extensions/nsphere/core/radius.hpp +++ b/include/boost/geometry/extensions/nsphere/core/radius.hpp @@ -4,6 +4,11 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -19,9 +24,7 @@ #include -#include - -#include +#include #include @@ -29,129 +32,28 @@ namespace boost { namespace geometry { -namespace traits -{ - -/*! - \brief Traits class to get/set radius of a circle/sphere/(ellipse) - \details the radius access meta-functions give read/write access to the radius of a circle or a sphere, - or to the major/minor axis or an ellipse, or to one of the 3 equatorial radii of an ellipsoid. - - It should be specialized per geometry, in namespace core_dispatch. Those specializations should - forward the call via traits to the geometry class, which could be specified by the user. - - There is a corresponding generic radius_get and radius_set function - \par Geometries: - - n-sphere (circle,sphere) - - upcoming ellipse - \par Specializations should provide: - - inline static T get(G const& geometry) - - inline static void set(G& geometry, T const& radius) - \ingroup traits -*/ -template -struct radius_access {}; - - -/*! - \brief Traits class indicating the type (double,float,...) of the radius of a circle or a sphere - \par Geometries: - - n-sphere (circle,sphere) - - upcoming ellipse - \par Specializations should provide: - - typedef T type (double,float,int,etc) - \ingroup traits -*/ -template -struct radius_type {}; - -} // namespace traits - #ifndef DOXYGEN_NO_DISPATCH namespace core_dispatch { -template -struct radius_type -{ - //typedef core_dispatch_specialization_required type; -}; - -/*! - \brief radius access meta-functions, used by concept n-sphere and upcoming ellipse. -*/ -template -struct radius_access -{ - //static inline T get(G const& ) {} - //static inline void set(G& g, T const& value) {} -}; - template struct radius_type { typedef typename traits::radius_type::type type; }; -template -struct radius_access +template +struct radius_access + : detail::radius_access { BOOST_STATIC_ASSERT((D == 0)); - static inline T get(S const& s) - { - return traits::radius_access::get(s); - } - static inline void set(S& s, T const& radius) - { - traits::radius_access::set(s, radius); - } }; } // namespace core_dispatch #endif // DOXYGEN_NO_DISPATCH -template -struct radius_type -{ - typedef typename boost::remove_const::type rconst; - typedef typename core_dispatch::radius_type::type, rconst>::type type; -}; - -/*! - \brief Function to get radius - \return radius of a circle / sphere / ellipse - \ingroup access - \param geometry the geometry to get the radius from - \tparam I index, for circle/sphere always zero, for ellipse major/minor axis, - for ellipsoid one of the 3 equatorial radii -*/ -template -inline typename radius_type::type get_radius(G const& geometry) -{ - typedef typename boost::remove_const::type rconst; - - return core_dispatch::radius_access::type, rconst, - typename radius_type::type, I>::get(geometry); -} - -/*! - \brief Function to set the radius of a circle / sphere / (ellipse) - \ingroup access - \tparam I index, for circle/sphere always zero, for ellipse major/minor axis, - for ellipsoid one of the 3 equatorial radii - \param geometry the geometry to change - \param radius the radius to set -*/ -template -inline void set_radius(G& geometry, typename radius_type::type const& radius) -{ - core_dispatch::radius_access::type, G, - typename radius_type::type, I>::set(geometry, radius); -} - - }} // namespace boost::geometry diff --git a/include/boost/geometry/extensions/nsphere/geometries/nsphere.hpp b/include/boost/geometry/extensions/nsphere/geometries/nsphere.hpp index db4080fc8..4f7cb72b3 100644 --- a/include/boost/geometry/extensions/nsphere/geometries/nsphere.hpp +++ b/include/boost/geometry/extensions/nsphere/geometries/nsphere.hpp @@ -121,7 +121,7 @@ struct access, Dimension> }; template -struct radius_access, RadiusType, 0> +struct radius_access, 0> { typedef model::nsphere nsphere_type; diff --git a/include/boost/geometry/geometry.hpp b/include/boost/geometry/geometry.hpp index 110f0e60f..fae575368 100644 --- a/include/boost/geometry/geometry.hpp +++ b/include/boost/geometry/geometry.hpp @@ -4,6 +4,11 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -34,8 +39,11 @@ #include #include #include +#include #include +// Core models +#include #include #include diff --git a/test/core/Jamfile.v2 b/test/core/Jamfile.v2 index 398d1e025..613174f15 100644 --- a/test/core/Jamfile.v2 +++ b/test/core/Jamfile.v2 @@ -17,6 +17,7 @@ test-suite boost-geometry-core [ run geometry_id.cpp ] [ run point_type.cpp ] [ run radian_access.cpp ] + [ run radius.cpp ] # [ run reverse_dispatch.cpp ] [ run ring.cpp ] [ run tag.cpp ] diff --git a/test/core/radius.cpp b/test/core/radius.cpp new file mode 100644 index 000000000..081f03f32 --- /dev/null +++ b/test/core/radius.cpp @@ -0,0 +1,63 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include + +#include +#include + +#include + +#include + + +template +void test_get_set() +{ + typedef typename bg::radius_type::type radius_type; + + G g; + bg::set_radius(g, radius_type(5)); + + radius_type x = bg::get_radius(g); + + BOOST_CHECK_CLOSE(double(x), 5.0, 0.0001); +} + +template +void test_all() +{ + typedef bg::cs::model::spheroid Sd; + test_get_set<0, Sd>(); + test_get_set<2, Sd>(); + + typedef bg::cs::model::sphere Se; + test_get_set<0, Se>(); +} + + +int test_main(int, char* []) +{ + test_all(); + test_all(); + test_all(); + + return 0; +} From 2b1d7e3767c1f7d83d82b400219d46709d040cca Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 17 Nov 2014 02:27:47 +0100 Subject: [PATCH 08/14] [extensions] Use Spheroid in andoyer and vincenty strategies. Replace RadiusType template parameter of those strategies with Spheroid. Replace member function radius() with model() and typedef radius_type with model_type. Use get_radius(), calculate flattening "manually". Tweek calculations (conversion warnings, common multiplier). Remove detail::ellipsoid<>. --- extensions/test/gis/latlong/andoyer.cpp | 9 +- extensions/test/gis/latlong/vincenty.cpp | 9 +- .../gis/geographic/detail/ellipsoid.hpp | 60 ------------ .../gis/geographic/strategies/andoyer.hpp | 89 +++++++++-------- .../gis/geographic/strategies/vincenty.hpp | 96 ++++++++++--------- 5 files changed, 115 insertions(+), 148 deletions(-) delete mode 100644 include/boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp diff --git a/extensions/test/gis/latlong/andoyer.cpp b/extensions/test/gis/latlong/andoyer.cpp index 80e971bc2..9ce32701e 100644 --- a/extensions/test/gis/latlong/andoyer.cpp +++ b/extensions/test/gis/latlong/andoyer.cpp @@ -5,6 +5,11 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -39,7 +44,9 @@ void test_andoyer(double lon1, double lat1, double lon2, double lat2, double exp typename bg::coordinate_type::type >::type rtype; - typedef bg::strategy::distance::andoyer andoyer_type; + typedef bg::cs::model::spheroid stype; + + typedef bg::strategy::distance::andoyer andoyer_type; BOOST_CONCEPT_ASSERT ( diff --git a/extensions/test/gis/latlong/vincenty.cpp b/extensions/test/gis/latlong/vincenty.cpp index a11dfd640..84ea06e90 100644 --- a/extensions/test/gis/latlong/vincenty.cpp +++ b/extensions/test/gis/latlong/vincenty.cpp @@ -5,6 +5,11 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -39,7 +44,9 @@ void test_vincenty(double lon1, double lat1, double lon2, double lat2, double ex typename bg::coordinate_type::type >::type rtype; - typedef bg::strategy::distance::vincenty vincenty_type; + typedef bg::cs::model::spheroid stype; + + typedef bg::strategy::distance::vincenty vincenty_type; BOOST_CONCEPT_ASSERT( ( diff --git a/include/boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp b/include/boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp deleted file mode 100644 index a2b7b4703..000000000 --- a/include/boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) - -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. - -// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library -// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. - -// Use, modification and distribution is subject to the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_DETAIL_ELLIPSOID_HPP -#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_DETAIL_ELLIPSOID_HPP - - -namespace boost { namespace geometry { namespace detail -{ - - -/*! - \brief Defines ellipsoid values for use in distance calculations - \details They have a constructor with the earth radius - \note Will be moved / merged with projections - \todo Optionally specify earth model, defaulting to WGS84 - - See http://en.wikipedia.org/wiki/Figure_of_the_Earth - - and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84 - \note -*/ -template -class ellipsoid -{ - public : - ellipsoid(T const& a, T const& b) - : m_a(a) - , m_b(b) - , m_f((a - b) / a) - {} - ellipsoid() - : m_a(T(6378137.0)) - , m_b(T(6356752.314245)) - , m_f((m_a - m_b) / m_a) - {} - - T a() const { return m_a; } - T b() const { return m_b; } - T f() const { return m_f; } - - private : - T m_a, m_b, m_f; // equatorial radius, polar radius, flattening -}; - - - - -}}} // namespace boost::geometry::detail - - -#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_DETAIL_ELLIPSOID_HPP diff --git a/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp b/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp index b20a9aa0a..c5ca778e1 100644 --- a/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp +++ b/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp @@ -2,6 +2,11 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -10,14 +15,16 @@ #define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_ANDOYER_HPP -#include -#include #include -#include -#include -#include +#include +#include +#include -#include +#include + +#include +#include +#include namespace boost { namespace geometry @@ -44,7 +51,7 @@ are about the same as Vincenty. In my (Barend's) testcases the results didn't di */ template < - typename RadiusType, + typename Spheroid, typename CalculationType = void > class andoyer @@ -63,14 +70,14 @@ public : > {}; - typedef RadiusType radius_type; + typedef Spheroid model_type; inline andoyer() - : m_ellipsoid() + : m_spheroid() {} - explicit inline andoyer(geometry::detail::ellipsoid const& e) - : m_ellipsoid(e) + explicit inline andoyer(Spheroid const& spheroid) + : m_spheroid(spheroid) {} @@ -85,20 +92,12 @@ public : ); } - inline geometry::detail::ellipsoid ellipsoid() const + inline Spheroid const& model() const { - return m_ellipsoid; + return m_spheroid; } - inline RadiusType radius() const - { - return m_ellipsoid.a(); - } - - private : - geometry::detail::ellipsoid m_ellipsoid; - template inline CT calc(T const& lon1, T const& lat1, @@ -136,15 +135,19 @@ private : return c0; } + CT const radius_a = CT(get_radius<0>(m_spheroid)); + CT const flattening = CT(get_radius<0>(m_spheroid) - get_radius<2>(m_spheroid)) / CT(get_radius<0>(m_spheroid)); + CT const omega = atan(math::sqrt(S / C)); CT const r3 = c3 * math::sqrt(S * C) / omega; // not sure if this is r or greek nu - CT const D = c2 * omega * m_ellipsoid.a(); + CT const D = c2 * omega * radius_a; CT const H1 = (r3 - c1) / (c2 * C); CT const H2 = (r3 + c1) / (c2 * S); - CT const f = m_ellipsoid.f(); - return D * (c1 + f * H1 * sinF2 * cosG2 - f * H2 * cosF2 * sinG2); + return D * (c1 + flattening * (H1 * sinF2 * cosG2 - H2 * cosF2 * sinG2) ); } + + Spheroid m_spheroid; }; @@ -152,41 +155,41 @@ private : namespace services { -template -struct tag > +template +struct tag > { typedef strategy_tag_distance_point_point type; }; -template -struct return_type, P1, P2> - : andoyer::template calculation_type +template +struct return_type, P1, P2> + : andoyer::template calculation_type {}; -template -struct comparable_type > +template +struct comparable_type > { - typedef andoyer type; + typedef andoyer type; }; -template -struct get_comparable > +template +struct get_comparable > { - static inline andoyer apply(andoyer const& input) + static inline andoyer apply(andoyer const& input) { return input; } }; -template -struct result_from_distance, P1, P2> +template +struct result_from_distance, P1, P2> { template - static inline typename return_type, P1, P2>::type - apply(andoyer const& , T const& value) + static inline typename return_type, P1, P2>::type + apply(andoyer const& , T const& value) { return value; } @@ -196,7 +199,13 @@ struct result_from_distance, P1, P2> template struct default_strategy { - typedef strategy::distance::andoyer::type> type; + typedef strategy::distance::andoyer + < + cs::model::spheroid + < + typename select_coordinate_type::type + > + > type; }; diff --git a/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp b/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp index fd8ae64bb..745f09033 100644 --- a/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp +++ b/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp @@ -2,6 +2,11 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -9,19 +14,19 @@ #ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_VINCENTY_HPP #define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_VINCENTY_HPP + #include +#include +#include +#include +#include #include -#include -#include -#include -#include + #include - -#include - - +#include +#include namespace boost { namespace geometry @@ -45,7 +50,7 @@ namespace strategy { namespace distance */ template < - typename RadiusType, + typename Spheroid, typename CalculationType = void > class vincenty @@ -64,13 +69,14 @@ public : > {}; - typedef RadiusType radius_type; + typedef Spheroid model_type; inline vincenty() + : m_spheroid() {} - explicit inline vincenty(geometry::detail::ellipsoid const& e) - : m_ellipsoid(e) + explicit inline vincenty(Spheroid const& spheroid) + : m_spheroid(spheroid) {} template @@ -84,25 +90,17 @@ public : ); } - inline geometry::detail::ellipsoid ellipsoid() const + inline Spheroid const& model() const { - return m_ellipsoid; - } - - inline RadiusType radius() const - { - // For now return the major axis. It is used in distance_cross_track, from point-to-line - return m_ellipsoid.a(); + return m_spheroid; } private : - geometry::detail::ellipsoid m_ellipsoid; - template inline CT calculate(T const& lon1, - T const& lat1, - T const& lon2, - T const& lat2) const + T const& lat1, + T const& lon2, + T const& lat2) const { CT const c2 = 2; CT const pi = geometry::math::pi(); @@ -120,9 +118,13 @@ private : return CT(0); } + CT const radius_a = CT(get_radius<0>(m_spheroid)); + CT const radius_b = CT(get_radius<2>(m_spheroid)); + CT const flattening = CT(get_radius<0>(m_spheroid) - get_radius<2>(m_spheroid)) / CT(get_radius<0>(m_spheroid)); + // U: reduced latitude, defined by tan U = (1-f) tan phi CT const c1 = 1; - CT const one_min_f = c1 - m_ellipsoid.f(); + CT const one_min_f = c1 - flattening; CT const U1 = atan(one_min_f * tan(lat1)); // above (1) CT const U2 = atan(one_min_f * tan(lat2)); // above (1) @@ -150,7 +152,7 @@ private : CT const c6 = 6; CT const c16 = 16; - CT const c_e_12 = 1e-12; + CT const c_e_12 = CT(1e-12); do { @@ -163,15 +165,15 @@ private : cos2_alpha = c1 - math::sqr(sin_alpha); cos2_sigma_m = math::equals(cos2_alpha, 0) ? 0 : cos_sigma - c2 * sin_U1 * sin_U2 / cos2_alpha; // (18) - CT C = m_ellipsoid.f()/c16 * cos2_alpha * (c4 + m_ellipsoid.f() * (c4 - c3 * cos2_alpha)); // (10) + CT C = flattening/c16 * cos2_alpha * (c4 + flattening * (c4 - c3 * cos2_alpha)); // (10) sigma = atan2(sin_sigma, cos_sigma); // (16) - lambda = L + (c1 - C) * m_ellipsoid.f() * sin_alpha * + lambda = L + (c1 - C) * flattening * sin_alpha * (sigma + C * sin_sigma * ( cos2_sigma_m + C * cos_sigma * (-c1 + c2 * math::sqr(cos2_sigma_m)))); // (11) } while (geometry::math::abs(previous_lambda - lambda) > c_e_12 && geometry::math::abs(lambda) < pi); - CT sqr_u = cos2_alpha * (math::sqr(m_ellipsoid.a()) - math::sqr(m_ellipsoid.b())) / math::sqr(m_ellipsoid.b()); // above (1) + CT sqr_u = cos2_alpha * (math::sqr(radius_a) - math::sqr(radius_b)) / math::sqr(radius_b); // above (1) // Oops getting hard here // (again, problem is that ttmath cannot divide by doubles, which is OK) @@ -191,49 +193,51 @@ private : CT delta_sigma = B * sin_sigma * ( cos2_sigma_m + (B/c4) * (cos(sigma)* (-c1 + c2 * cos2_sigma_m) - (B/c6) * cos2_sigma_m * (-c3 + c4 * math::sqr(sin_sigma)) * (-c3 + c4 * cos2_sigma_m))); // (6) - return m_ellipsoid.b() * A * (sigma - delta_sigma); // (19) + return radius_b * A * (sigma - delta_sigma); // (19) } + + Spheroid m_spheroid; }; #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS namespace services { -template -struct tag > +template +struct tag > { typedef strategy_tag_distance_point_point type; }; -template -struct return_type, P1, P2> - : vincenty::template calculation_type +template +struct return_type, P1, P2> + : vincenty::template calculation_type {}; -template -struct comparable_type > +template +struct comparable_type > { - typedef vincenty type; + typedef vincenty type; }; -template -struct get_comparable > +template +struct get_comparable > { - static inline vincenty apply(vincenty const& input) + static inline vincenty apply(vincenty const& input) { return input; } }; -template -struct result_from_distance, P1, P2 > +template +struct result_from_distance, P1, P2 > { template - static inline typename return_type, P1, P2>::type - apply(vincenty const& , T const& value) + static inline typename return_type, P1, P2>::type + apply(vincenty const& , T const& value) { return value; } From 1d4b7d71024c53d89486751989a61d4db35c05d8 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 17 Nov 2014 19:35:23 +0100 Subject: [PATCH 09/14] [core] In spheroid, replace if with ?: operator. --- include/boost/geometry/core/cs_model.hpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/include/boost/geometry/core/cs_model.hpp b/include/boost/geometry/core/cs_model.hpp index de639bc33..7dcc7a880 100644 --- a/include/boost/geometry/core/cs_model.hpp +++ b/include/boost/geometry/core/cs_model.hpp @@ -59,10 +59,7 @@ public: { BOOST_STATIC_ASSERT(I < 3); - if ( I < 2 ) - return m_a; - else - return m_b; + return I < 2 ? m_a : m_b; } template @@ -70,10 +67,7 @@ public: { BOOST_STATIC_ASSERT(I < 3); - if ( I < 2 ) - m_a = radius; - else - m_b = radius; + (I < 2 ? m_a : m_b) = radius; } private: From d36f40b6b346f5e236273ae42b3073b494316346 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 17 Nov 2014 20:03:39 +0100 Subject: [PATCH 10/14] [algorithms][extensions] Add detail flattening() algorithm and use it in andoyer and vincenty strategies. --- .../geometry/algorithms/detail/flattening.hpp | 69 +++++++++++++++++++ .../gis/geographic/strategies/andoyer.hpp | 4 +- .../gis/geographic/strategies/vincenty.hpp | 4 +- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 include/boost/geometry/algorithms/detail/flattening.hpp diff --git a/include/boost/geometry/algorithms/detail/flattening.hpp b/include/boost/geometry/algorithms/detail/flattening.hpp new file mode 100644 index 000000000..f6c3d0ab5 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/flattening.hpp @@ -0,0 +1,69 @@ +// Boost.Geometry + +// Copyright (c) 2014 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_FLATTENING_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_FLATTENING_HPP + +#include +#include +#include + +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DISPATCH +namespace detail_dispatch +{ + +template ::type> +struct flattening + : not_implemented +{}; + +template +struct flattening +{ + static inline ResultType apply(Geometry const& geometry) + { + return ResultType(0); + } +}; + +template +struct flattening +{ + static inline ResultType apply(Geometry const& geometry) + { + return ResultType(get_radius<0>(geometry) - get_radius<2>(geometry)) + / ResultType(get_radius<0>(geometry)); + } +}; + +} // namespace detail_dispatch +#endif // DOXYGEN_NO_DISPATCH + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template +ResultType flattening(Geometry const& geometry) +{ + return detail_dispatch::flattening::apply(geometry); +} + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_FLATTENING_HPP diff --git a/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp b/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp index c5ca778e1..3b203ac25 100644 --- a/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp +++ b/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp @@ -20,6 +20,8 @@ #include #include +#include + #include #include @@ -136,7 +138,7 @@ private : } CT const radius_a = CT(get_radius<0>(m_spheroid)); - CT const flattening = CT(get_radius<0>(m_spheroid) - get_radius<2>(m_spheroid)) / CT(get_radius<0>(m_spheroid)); + CT const flattening = geometry::detail::flattening(m_spheroid); CT const omega = atan(math::sqrt(S / C)); CT const r3 = c3 * math::sqrt(S * C) / omega; // not sure if this is r or greek nu diff --git a/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp b/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp index 745f09033..0f09c3b19 100644 --- a/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp +++ b/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp @@ -22,6 +22,8 @@ #include #include +#include + #include #include @@ -120,7 +122,7 @@ private : CT const radius_a = CT(get_radius<0>(m_spheroid)); CT const radius_b = CT(get_radius<2>(m_spheroid)); - CT const flattening = CT(get_radius<0>(m_spheroid) - get_radius<2>(m_spheroid)) / CT(get_radius<0>(m_spheroid)); + CT const flattening = geometry::detail::flattening(m_spheroid); // U: reduced latitude, defined by tan U = (1-f) tan phi CT const c1 = 1; From 202a9939f150b8359976c933bfdb84a982b7fa81 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 19 Nov 2014 16:21:51 +0100 Subject: [PATCH 11/14] [core] Move spheroid and sphere from cs::model to srs namespace. Change reference_sphere_tag and reference_spheroid_tag to srs_sphere_tag and srs_spheroid_tag respectively. Adapt algorithms, strategies and tests to the new namespace and tags. --- extensions/test/gis/latlong/andoyer.cpp | 3 +- extensions/test/gis/latlong/vincenty.cpp | 3 +- .../geometry/algorithms/detail/flattening.hpp | 4 +- include/boost/geometry/core/radius.hpp | 12 +++--- .../geometry/core/{cs_model.hpp => srs.hpp} | 37 +++++++++---------- include/boost/geometry/core/tags.hpp | 8 ++-- .../gis/geographic/strategies/andoyer.hpp | 4 +- .../gis/geographic/strategies/vincenty.hpp | 1 - include/boost/geometry/geometry.hpp | 4 +- test/core/radius.cpp | 7 ++-- 10 files changed, 39 insertions(+), 44 deletions(-) rename include/boost/geometry/core/{cs_model.hpp => srs.hpp} (83%) diff --git a/extensions/test/gis/latlong/andoyer.cpp b/extensions/test/gis/latlong/andoyer.cpp index 9ce32701e..edce7b9de 100644 --- a/extensions/test/gis/latlong/andoyer.cpp +++ b/extensions/test/gis/latlong/andoyer.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -44,7 +45,7 @@ void test_andoyer(double lon1, double lat1, double lon2, double lat2, double exp typename bg::coordinate_type::type >::type rtype; - typedef bg::cs::model::spheroid stype; + typedef bg::srs::spheroid stype; typedef bg::strategy::distance::andoyer andoyer_type; diff --git a/extensions/test/gis/latlong/vincenty.cpp b/extensions/test/gis/latlong/vincenty.cpp index 84ea06e90..70348dc4d 100644 --- a/extensions/test/gis/latlong/vincenty.cpp +++ b/extensions/test/gis/latlong/vincenty.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -44,7 +45,7 @@ void test_vincenty(double lon1, double lat1, double lon2, double lat2, double ex typename bg::coordinate_type::type >::type rtype; - typedef bg::cs::model::spheroid stype; + typedef bg::srs::spheroid stype; typedef bg::strategy::distance::vincenty vincenty_type; diff --git a/include/boost/geometry/algorithms/detail/flattening.hpp b/include/boost/geometry/algorithms/detail/flattening.hpp index f6c3d0ab5..a679246d9 100644 --- a/include/boost/geometry/algorithms/detail/flattening.hpp +++ b/include/boost/geometry/algorithms/detail/flattening.hpp @@ -30,7 +30,7 @@ struct flattening {}; template -struct flattening +struct flattening { static inline ResultType apply(Geometry const& geometry) { @@ -39,7 +39,7 @@ struct flattening }; template -struct flattening +struct flattening { static inline ResultType apply(Geometry const& geometry) { diff --git a/include/boost/geometry/core/radius.hpp b/include/boost/geometry/core/radius.hpp index 0a30a9cda..8f8247864 100644 --- a/include/boost/geometry/core/radius.hpp +++ b/include/boost/geometry/core/radius.hpp @@ -213,28 +213,28 @@ struct radius_access template -struct radius_type +struct radius_type { typedef typename traits::radius_type::type type; }; template -struct radius_access - : detail::radius_access +struct radius_access + : detail::radius_access { BOOST_STATIC_ASSERT(Dimension == 0); //BOOST_STATIC_ASSERT(Dimension < 3); }; template -struct radius_type +struct radius_type { typedef typename traits::radius_type::type type; }; template -struct radius_access - : detail::radius_access +struct radius_access + : detail::radius_access { BOOST_STATIC_ASSERT(Dimension == 0 || Dimension == 2); //BOOST_STATIC_ASSERT(Dimension < 3); diff --git a/include/boost/geometry/core/cs_model.hpp b/include/boost/geometry/core/srs.hpp similarity index 83% rename from include/boost/geometry/core/cs_model.hpp rename to include/boost/geometry/core/srs.hpp index 7dcc7a880..75f7e2f4e 100644 --- a/include/boost/geometry/core/cs_model.hpp +++ b/include/boost/geometry/core/srs.hpp @@ -16,8 +16,8 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_GEOMETRY_CORE_CS_MODEL_HPP -#define BOOST_GEOMETRY_CORE_CS_MODEL_HPP +#ifndef BOOST_GEOMETRY_CORE_SRS_HPP +#define BOOST_GEOMETRY_CORE_SRS_HPP #include @@ -25,20 +25,20 @@ #include #include +#include #include namespace boost { namespace geometry { -namespace cs { namespace model +namespace srs { /*! \brief Defines spheroid radius values for use in geographical CS calculations \note See http://en.wikipedia.org/wiki/Figure_of_the_Earth and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84 - \note */ template class spheroid @@ -74,8 +74,7 @@ private: RadiusType m_a, m_b; // equatorial radius, polar radius }; - -}} // namespace cs::model +} // namespace srs // Traits specializations for spheroid #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS @@ -83,21 +82,21 @@ namespace traits { template -struct tag< cs::model::spheroid > +struct tag< srs::spheroid > { - typedef reference_spheroid_tag type; + typedef srs_spheroid_tag type; }; template -struct radius_type< cs::model::spheroid > +struct radius_type< srs::spheroid > { typedef RadiusType type; }; template -struct radius_access, Dimension> +struct radius_access, Dimension> { - typedef cs::model::spheroid spheroid_type; + typedef srs::spheroid spheroid_type; static inline RadiusType get(spheroid_type const& s) { @@ -114,12 +113,11 @@ struct radius_access, Dimension> #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS -namespace cs { namespace model +namespace srs { /*! \brief Defines sphere radius value for use in spherical CS calculations - \note */ template class sphere @@ -152,8 +150,7 @@ private: RadiusType m_r; // radius }; - -}} // namespace cs::model +} // namespace srs // Traits specializations for sphere #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS @@ -161,21 +158,21 @@ namespace traits { template -struct tag< cs::model::sphere > +struct tag< srs::sphere > { - typedef reference_sphere_tag type; + typedef srs_sphere_tag type; }; template -struct radius_type< cs::model::sphere > +struct radius_type< srs::sphere > { typedef RadiusType type; }; template -struct radius_access, Dimension> +struct radius_access, Dimension> { - typedef cs::model::sphere sphere_type; + typedef srs::sphere sphere_type; static inline RadiusType get(sphere_type const& s) { diff --git a/include/boost/geometry/core/tags.hpp b/include/boost/geometry/core/tags.hpp index d3cdbd6bd..5d6acb187 100644 --- a/include/boost/geometry/core/tags.hpp +++ b/include/boost/geometry/core/tags.hpp @@ -44,11 +44,11 @@ struct geographic_tag : spherical_tag {}; // Tags defining coordinate systems reference models -/// For reference sphere defining parameters of spherical coordinate system -struct reference_sphere_tag {}; - /// For reference spheroid defining parameters of geographical coordinate system -struct reference_spheroid_tag {}; +struct srs_spheroid_tag {}; + +/// For reference sphere defining parameters of spherical coordinate system +struct srs_sphere_tag : srs_spheroid_tag {}; // Tags defining tag hierarchy diff --git a/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp b/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp index 3b203ac25..d8a19d439 100644 --- a/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp +++ b/include/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp @@ -16,9 +16,9 @@ #include -#include #include #include +#include #include @@ -203,7 +203,7 @@ struct default_strategy::type > diff --git a/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp b/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp index 0f09c3b19..4ac3c5c3e 100644 --- a/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp +++ b/include/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/include/boost/geometry/geometry.hpp b/include/boost/geometry/geometry.hpp index fae575368..cf16ef7d9 100644 --- a/include/boost/geometry/geometry.hpp +++ b/include/boost/geometry/geometry.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -42,9 +43,6 @@ #include #include -// Core models -#include - #include #include diff --git a/test/core/radius.cpp b/test/core/radius.cpp index 081f03f32..11f81a5e7 100644 --- a/test/core/radius.cpp +++ b/test/core/radius.cpp @@ -22,11 +22,10 @@ #include #include +#include #include -#include - template void test_get_set() @@ -44,11 +43,11 @@ void test_get_set() template void test_all() { - typedef bg::cs::model::spheroid Sd; + typedef bg::srs::spheroid Sd; test_get_set<0, Sd>(); test_get_set<2, Sd>(); - typedef bg::cs::model::sphere Se; + typedef bg::srs::sphere Se; test_get_set<0, Se>(); } From 8de33edb168d7774c00d77d32d0e56960f8d2de7 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 19 Nov 2014 17:48:36 +0100 Subject: [PATCH 12/14] [core] Replace radius access 1-character tparams names with meaningful words. --- include/boost/geometry/core/radius.hpp | 8 ++++---- include/boost/geometry/core/srs.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/geometry/core/radius.hpp b/include/boost/geometry/core/radius.hpp index 8f8247864..ee6d5d246 100644 --- a/include/boost/geometry/core/radius.hpp +++ b/include/boost/geometry/core/radius.hpp @@ -49,11 +49,11 @@ namespace traits - n-sphere (circle,sphere) - upcoming ellipse \par Specializations should provide: - - inline static T get(G const& geometry) - - inline static void set(G& geometry, T const& radius) + - inline static T get(Geometry const& geometry) + - inline static void set(Geometry& geometry, T const& radius) \ingroup traits */ -template +template struct radius_access {}; @@ -66,7 +66,7 @@ struct radius_access {}; - typedef T type (double,float,int,etc) \ingroup traits */ -template +template struct radius_type {}; } // namespace traits diff --git a/include/boost/geometry/core/srs.hpp b/include/boost/geometry/core/srs.hpp index 75f7e2f4e..bf1b4e28a 100644 --- a/include/boost/geometry/core/srs.hpp +++ b/include/boost/geometry/core/srs.hpp @@ -192,4 +192,4 @@ struct radius_access, Dimension> }} // namespace boost::geometry -#endif // BOOST_GEOMETRY_CORE_CS_MODEL_HPP +#endif // BOOST_GEOMETRY_CORE_SRS_HPP From c71d80d9503a837161b4aa32a7eceb911d30299a Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 20 Nov 2014 13:03:58 +0100 Subject: [PATCH 13/14] [io] Fix reference to reference issue for older MSVC. --- include/boost/geometry/io/wkt/read.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index 033c96a0a..5fa2e1560 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -237,7 +237,8 @@ struct stateful_range_appender { typedef typename geometry::point_type::type point_type; - inline void append(Geometry & geom, point_type const& point, bool) + // NOTE: Geometry is a reference + inline void append(Geometry geom, point_type const& point, bool) { geometry::append(geom, point); } @@ -262,7 +263,8 @@ struct stateful_range_appender : pt_index(0) {} - inline void append(Geometry & geom, point_type const& point, bool is_next_expected) + // NOTE: Geometry is a reference + inline void append(Geometry geom, point_type const& point, bool is_next_expected) { bool should_append = true; From 6aa5df954fb3fef16adb5b9aa9c8bef9257e75e5 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 20 Nov 2014 22:48:06 +0100 Subject: [PATCH 14/14] [test][index] Replace struct with class keyword in specialization of allocators<> for throwing node. --- index/test/rtree/exceptions/test_throwing_node.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index/test/rtree/exceptions/test_throwing_node.hpp b/index/test/rtree/exceptions/test_throwing_node.hpp index d32c6bcca..4aa0ef750 100644 --- a/index/test/rtree/exceptions/test_throwing_node.hpp +++ b/index/test/rtree/exceptions/test_throwing_node.hpp @@ -174,9 +174,13 @@ struct visitor -struct allocators +class allocators : public Allocator::template rebind< - typename node, node_throwing_static_tag>::type + typename node< + Value, Parameters, Box, + allocators, + node_throwing_static_tag + >::type >::other { typedef typename Allocator::template rebind<