Ticket #9066: Mats-Taraldsvik-MultiPoint-WKB-linestring-test-fixed.patch
File Mats-Taraldsvik-MultiPoint-WKB-linestring-test-fixed.patch, 12.0 KB (added by , 9 years ago) |
---|
-
boost/geometry/algorithms/equals.hpp
33 33 // For trivial checks 34 34 #include <boost/geometry/algorithms/area.hpp> 35 35 #include <boost/geometry/algorithms/length.hpp> 36 #include <boost/geometry/algorithms/num_points.hpp> 36 37 #include <boost/geometry/util/math.hpp> 37 38 #include <boost/geometry/util/select_coordinate_type.hpp> 38 39 #include <boost/geometry/util/select_most_precise.hpp> … … 50 51 namespace detail { namespace equals 51 52 { 52 53 54 struct num_points_check 55 { 56 template <typename Geometry1, typename Geometry2> 57 static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2) 58 { 59 return geometry::math::equals( 60 geometry::num_points(geometry1), 61 geometry::num_points(geometry2)); 62 } 63 }; 53 64 54 65 template 55 66 < -
boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp
68 68 { 69 69 point = 1, 70 70 linestring = 2, 71 polygon = 3 72 71 polygon = 3, 72 73 73 // TODO: Not implemented 74 //multipoint = 4,74 multipoint = 4, 75 75 //multilinestring = 5, 76 76 //multipolygon = 6, 77 77 //collection = 7 -
boost/geometry/extensions/gis/io/wkb/detail/parser.hpp
110 110 if (value_parser<boost::uint32_t>::parse(it, end, value, order)) 111 111 { 112 112 // TODO: Refine the test when multi* geometries are supported 113 113 114 114 boost::uint32_t id = value & 0xff; 115 if (geometry_type::polygon >= id) 115 116 if (geometry_type::multipoint >= id) 116 117 { 117 118 type = geometry_type::enum_t(id); 118 119 return true; … … 235 236 template <typename Iterator> 236 237 static bool parse(Iterator& it, Iterator end, L& linestring, byte_order_type::enum_t order) 237 238 { 238 typedef typename point_type<L>::type point_type;239 240 239 geometry_type::enum_t type; 241 240 if (!geometry_type_parser::parse(it, end, type, order)) 242 241 { -
boost/geometry/extensions/multi/gis/io/wkb/detail/parser.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. 4 5 // Use, modification and distribution is subject to the Boost Software License, 6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 9 #ifndef BOOST_GEOMETRY_MULTI_IO_WKB_DETAIL_PARSER_HPP 10 #define BOOST_GEOMETRY_MULTI_IO_WKB_DETAIL_PARSER_HPP 11 12 #include <cassert> 13 #include <cstddef> 14 #include <iterator> 15 #include <limits> 16 17 #include <boost/geometry/extensions/gis/io/wkb/detail/endian.hpp> 18 #include <boost/geometry/extensions/gis/io/wkb/detail/parser.hpp> 19 #include <boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp> 20 21 #include <boost/geometry/multi/core/point_type.hpp> 22 23 namespace boost { namespace geometry 24 { 25 26 #ifndef DOXYGEN_NO_DETAIL 27 namespace detail { namespace wkb 28 { 29 30 template <typename MultiPoint> 31 struct multipoint_parser 32 { 33 template <typename Iterator> 34 static bool parse(Iterator& it, Iterator end, MultiPoint& multipoint, byte_order_type::enum_t order) 35 { 36 typedef typename point_type<MultiPoint>::type point_type; 37 38 geometry_type::enum_t type; 39 if (!geometry_type_parser::parse(it, end, type, order)) 40 { 41 return false; 42 } 43 44 if (geometry_type::multipoint != type) 45 { 46 return false; 47 } 48 49 boost::uint32_t num_points(0); 50 if (!value_parser<boost::uint32_t>::parse(it, end, num_points, order)) 51 { 52 return false; 53 } 54 55 point_type point_buffer; 56 std::back_insert_iterator<MultiPoint> output(std::back_inserter(multipoint)); 57 58 typedef typename std::iterator_traits<Iterator>::difference_type size_type; 59 assert(num_points <= boost::uint32_t( (std::numeric_limits<size_type>::max)() ) ); 60 61 size_type points_parsed = 0; 62 while (points_parsed < num_points && it != end) 63 { 64 detail::wkb::byte_order_type::enum_t point_byte_order; 65 if (!detail::wkb::byte_order_parser::parse(it, end, point_byte_order)) 66 { 67 return false; 68 } 69 70 point_parser<point_type>::parse(it, end, point_buffer, point_byte_order); 71 72 output = point_buffer; 73 74 ++output; 75 ++points_parsed; 76 } 77 return true; 78 } 79 }; 80 81 }} // namespace detail::wkb 82 #endif // DOXYGEN_NO_IMPL 83 84 }} // namespace boost::geometry 85 86 87 #endif // BOOST_GEOMETRY_MULTI_IO_WKB_DETAIL_PARSER_HPP -
boost/geometry/extensions/multi/gis/io/wkb/read_wkb.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. 4 5 // Use, modification and distribution is subject to the Boost Software License, 6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 9 #ifndef BOOST_GEOMETRY_MULTI_IO_WKB_READ_WKB_HPP 10 #define BOOST_GEOMETRY_MULTI_IO_WKB_READ_WKB_HPP 11 12 #include <iterator> 13 14 #include <boost/geometry/extensions/multi/gis/io/wkb/detail/parser.hpp> 15 #include <boost/geometry/extensions/gis/io/wkb/read_wkb.hpp> 16 17 namespace boost { namespace geometry 18 { 19 20 #ifndef DOXYGEN_NO_DISPATCH 21 namespace dispatch 22 { 23 24 template <typename Geometry> 25 struct read_wkb<multi_point_tag, Geometry> 26 { 27 template <typename Iterator> 28 static inline bool parse(Iterator& it, Iterator end, Geometry& geometry, 29 detail::wkb::byte_order_type::enum_t order) 30 { 31 return detail::wkb::multipoint_parser<Geometry>::parse(it, end, geometry, order); 32 } 33 }; 34 35 } // namespace dispatch 36 #endif // DOXYGEN_NO_DISPATCH 37 38 }} // namespace boost::geometry 39 40 #endif // BOOST_GEOMETRY_MULTI_IO_WKB_READ_WKB_HPP -
boost/geometry/multi/algorithms/equals.hpp
20 20 #include <boost/geometry/multi/geometries/concepts/check.hpp> 21 21 22 22 #include <boost/geometry/algorithms/equals.hpp> 23 #include <boost/geometry/multi/algorithms/num_points.hpp> 23 24 24 25 25 26 namespace boost { namespace geometry … … 29 30 namespace dispatch 30 31 { 31 32 33 template <typename MultiPoint1, typename MultiPoint2, bool Reverse> 34 struct equals 35 < 36 MultiPoint1, MultiPoint2, 37 multi_point_tag, multi_point_tag, 38 2, 39 Reverse 40 > 41 : detail::equals::equals_by_collection<detail::equals::num_points_check> 42 {}; 32 43 33 44 template <typename MultiPolygon1, typename MultiPolygon2, bool Reverse> 34 45 struct equals -
libs/geometry/extensions/test/gis/Jamfile.v2
10 10 11 11 build-project latlong ; 12 12 build-project projections ; 13 build-project io ; 13 14 -
libs/geometry/extensions/test/gis/io/Jamfile.v2
1 # Boost.Geometry (aka GGL, Generic Geometry Library) 2 # 3 # Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. 4 # Copyright (c) 2008-2013 Bruno Lalande, Paris, France. 5 # Copyright (c) 2009-2013 Mateusz Loskot, London, UK. 6 # 7 # Use, modification and distribution is subject to the Boost Software License, 8 # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 9 # http://www.boost.org/LICENSE_1_0.txt) 10 11 build-project wkb ; 12 -
libs/geometry/extensions/test/gis/io/wkb/Jamfile.v2
1 # Boost.Geometry (aka GGL, Generic Geometry Library) 2 # 3 # Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. 4 # Copyright (c) 2008-2013 Bruno Lalande, Paris, France. 5 # Copyright (c) 2009-2013 Mateusz Loskot, London, UK. 6 # 7 # Use, modification and distribution is subject to the Boost Software License, 8 # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 9 # http://www.boost.org/LICENSE_1_0.txt) 10 11 test-suite boost-geometry-io-wkb 12 : 13 [ run read_wkb.cpp ] 14 ; 15 -
libs/geometry/extensions/test/gis/io/wkb/read_wkb.cpp
17 17 #include <boost/cstdint.hpp> 18 18 19 19 #include <boost/geometry/algorithms/equals.hpp> 20 #include <boost/geometry/strategies/strategies.hpp> 20 21 #include <boost/geometry/geometries/geometries.hpp> 21 22 #include <boost/geometry/io/wkt/read.hpp> 22 23 #include <boost/geometry/extensions/gis/io/wkb/read_wkb.hpp> 23 24 #include <boost/geometry/extensions/gis/io/wkb/utility.hpp> 24 25 26 #include <boost/geometry/multi/algorithms/equals.hpp> 27 #include <boost/geometry/multi/geometries/multi_geometries.hpp> 28 #include <boost/geometry/multi/io/wkt/read.hpp> 29 30 #include <boost/geometry/extensions/multi/gis/io/wkb/read_wkb.hpp> 31 25 32 namespace bg = boost::geometry; 26 33 27 34 namespace { // anonymous … … 53 60 //template <typename P, bool Result> 54 61 //void test_polygon_wkt(std::string const& wkt) 55 62 //{ 56 // 57 // 63 // typedef bg::model::linestring<P> linestring_type; 64 // typedef bg::model::polygon<linestring_type> polygon_type; 58 65 // 59 // 60 // 66 // polygon_type poly; 67 // bg::read_wkb(wkb, poly); 61 68 //} 62 69 63 70 } // namespace anonymous … … 103 110 test_geometry_equals<point_type, false>( 104 111 "01010000E0E61000005839B4C876BEF33F83C0CAA145B616400000000000002E400000000000C05340", 105 112 "POINT (1.234 5.678)"); 113 114 // 115 // LineString 116 // 117 118 test_geometry_equals<linestring_type, true>( 119 "0102000000030000005839B4C876BEF33F83C0CAA145B616404F401361C333224062A1D634EF3824409CC420B072482A40EB73B515FB2B3040", 120 "LINESTRING (1.234 5.678, 9.1011 10.1112, 13.1415 16.1718)"); 106 121 122 // 123 // MultiPoint 124 // 125 126 typedef bg::model::multi_point<point_type> multipoint_type; 127 128 test_geometry_equals<multipoint_type, true>( 129 "0104000000020000000101000000000000000000F03F0000000000000040010100000000000000000008400000000000001040", 130 "MULTIPOINT (1 2, 3 4)"); 131 132 test_geometry_equals<multipoint_type, true>( 133 "01040000000200000001010000005839B4C876BEF33F83C0CAA145B61640010100000062A1D634EF3824409CC420B072482A40", 134 "MULTIPOINT (1.234 5.678, 10.1112 13.1415)"); 135 107 136 return 0; 108 137 }