Index: boost/geometry/algorithms/equals.hpp =================================================================== --- boost/geometry/algorithms/equals.hpp (revision 86400) +++ boost/geometry/algorithms/equals.hpp (working copy) @@ -33,6 +33,7 @@ // For trivial checks #include #include +#include #include #include #include @@ -50,6 +51,16 @@ namespace detail { namespace equals { +struct num_points_check +{ + template + static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2) + { + return geometry::math::equals( + geometry::num_points(geometry1), + geometry::num_points(geometry2)); + } +}; template < Index: boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp =================================================================== --- boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp (revision 86400) +++ boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp (working copy) @@ -68,10 +68,10 @@ { point = 1, linestring = 2, - polygon = 3 - + polygon = 3, + // TODO: Not implemented - //multipoint = 4, + multipoint = 4, //multilinestring = 5, //multipolygon = 6, //collection = 7 Index: boost/geometry/extensions/gis/io/wkb/detail/parser.hpp =================================================================== --- boost/geometry/extensions/gis/io/wkb/detail/parser.hpp (revision 86400) +++ boost/geometry/extensions/gis/io/wkb/detail/parser.hpp (working copy) @@ -110,9 +110,10 @@ if (value_parser::parse(it, end, value, order)) { // TODO: Refine the test when multi* geometries are supported - + boost::uint32_t id = value & 0xff; - if (geometry_type::polygon >= id) + + if (geometry_type::multipoint >= id) { type = geometry_type::enum_t(id); return true; @@ -235,8 +236,6 @@ template static bool parse(Iterator& it, Iterator end, L& linestring, byte_order_type::enum_t order) { - typedef typename point_type::type point_type; - geometry_type::enum_t type; if (!geometry_type_parser::parse(it, end, type, order)) { Index: boost/geometry/extensions/multi/gis/io/wkb/detail/parser.hpp =================================================================== --- boost/geometry/extensions/multi/gis/io/wkb/detail/parser.hpp (revision 0) +++ boost/geometry/extensions/multi/gis/io/wkb/detail/parser.hpp (working copy) @@ -0,0 +1,87 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// 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_MULTI_IO_WKB_DETAIL_PARSER_HPP +#define BOOST_GEOMETRY_MULTI_IO_WKB_DETAIL_PARSER_HPP + +#include +#include +#include +#include + +#include +#include +#include + +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace wkb +{ + +template +struct multipoint_parser +{ + template + static bool parse(Iterator& it, Iterator end, MultiPoint& multipoint, byte_order_type::enum_t order) + { + typedef typename point_type::type point_type; + + geometry_type::enum_t type; + if (!geometry_type_parser::parse(it, end, type, order)) + { + return false; + } + + if (geometry_type::multipoint != type) + { + return false; + } + + boost::uint32_t num_points(0); + if (!value_parser::parse(it, end, num_points, order)) + { + return false; + } + + point_type point_buffer; + std::back_insert_iterator output(std::back_inserter(multipoint)); + + typedef typename std::iterator_traits::difference_type size_type; + assert(num_points <= boost::uint32_t( (std::numeric_limits::max)() ) ); + + size_type points_parsed = 0; + while (points_parsed < num_points && it != end) + { + detail::wkb::byte_order_type::enum_t point_byte_order; + if (!detail::wkb::byte_order_parser::parse(it, end, point_byte_order)) + { + return false; + } + + point_parser::parse(it, end, point_buffer, point_byte_order); + + output = point_buffer; + + ++output; + ++points_parsed; + } + return true; + } +}; + +}} // namespace detail::wkb +#endif // DOXYGEN_NO_IMPL + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_MULTI_IO_WKB_DETAIL_PARSER_HPP Index: boost/geometry/extensions/multi/gis/io/wkb/read_wkb.hpp =================================================================== --- boost/geometry/extensions/multi/gis/io/wkb/read_wkb.hpp (revision 0) +++ boost/geometry/extensions/multi/gis/io/wkb/read_wkb.hpp (working copy) @@ -0,0 +1,40 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// 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_MULTI_IO_WKB_READ_WKB_HPP +#define BOOST_GEOMETRY_MULTI_IO_WKB_READ_WKB_HPP + +#include + +#include +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + +template +struct read_wkb +{ + template + static inline bool parse(Iterator& it, Iterator end, Geometry& geometry, + detail::wkb::byte_order_type::enum_t order) + { + return detail::wkb::multipoint_parser::parse(it, end, geometry, order); + } +}; + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_MULTI_IO_WKB_READ_WKB_HPP Index: boost/geometry/multi/algorithms/equals.hpp =================================================================== --- boost/geometry/multi/algorithms/equals.hpp (revision 86400) +++ boost/geometry/multi/algorithms/equals.hpp (working copy) @@ -20,6 +20,7 @@ #include #include +#include namespace boost { namespace geometry @@ -29,6 +30,16 @@ namespace dispatch { +template +struct equals + < + MultiPoint1, MultiPoint2, + multi_point_tag, multi_point_tag, + 2, + Reverse + > + : detail::equals::equals_by_collection +{}; template struct equals Index: libs/geometry/extensions/test/gis/Jamfile.v2 =================================================================== --- libs/geometry/extensions/test/gis/Jamfile.v2 (revision 86400) +++ libs/geometry/extensions/test/gis/Jamfile.v2 (working copy) @@ -10,4 +10,5 @@ build-project latlong ; build-project projections ; +build-project io ; Index: libs/geometry/extensions/test/gis/io/Jamfile.v2 =================================================================== --- libs/geometry/extensions/test/gis/io/Jamfile.v2 (revision 0) +++ libs/geometry/extensions/test/gis/io/Jamfile.v2 (working copy) @@ -0,0 +1,12 @@ +# Boost.Geometry (aka GGL, Generic Geometry Library) +# +# Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2013 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2013 Mateusz Loskot, London, UK. +# +# 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) + +build-project wkb ; + Index: libs/geometry/extensions/test/gis/io/wkb/Jamfile.v2 =================================================================== --- libs/geometry/extensions/test/gis/io/wkb/Jamfile.v2 (revision 0) +++ libs/geometry/extensions/test/gis/io/wkb/Jamfile.v2 (working copy) @@ -0,0 +1,15 @@ +# Boost.Geometry (aka GGL, Generic Geometry Library) +# +# Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2013 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2013 Mateusz Loskot, London, UK. +# +# 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) + +test-suite boost-geometry-io-wkb + : + [ run read_wkb.cpp ] + ; + Index: libs/geometry/extensions/test/gis/io/wkb/read_wkb.cpp =================================================================== --- libs/geometry/extensions/test/gis/io/wkb/read_wkb.cpp (revision 86400) +++ libs/geometry/extensions/test/gis/io/wkb/read_wkb.cpp (working copy) @@ -17,11 +17,18 @@ #include #include +#include #include #include #include #include +#include +#include +#include + +#include + namespace bg = boost::geometry; namespace { // anonymous @@ -53,11 +60,11 @@ //template //void test_polygon_wkt(std::string const& wkt) //{ -// typedef bg::model::linestring

linestring_type; -// typedef bg::model::polygon polygon_type; +// typedef bg::model::linestring

linestring_type; +// typedef bg::model::polygon polygon_type; // -// polygon_type poly; -// bg::read_wkb(wkb, poly); +// polygon_type poly; +// bg::read_wkb(wkb, poly); //} } // namespace anonymous @@ -103,6 +110,28 @@ test_geometry_equals( "01010000E0E61000005839B4C876BEF33F83C0CAA145B616400000000000002E400000000000C05340", "POINT (1.234 5.678)"); + + // + // LineString + // + + test_geometry_equals( + "0102000000030000005839B4C876BEF33F83C0CAA145B616404F401361C333224062A1D634EF3824409CC420B072482A40EB73B515FB2B3040", + "LINESTRING (1.234 5.678, 9.1011 10.1112, 13.1415 16.1718)"); + // + // MultiPoint + // + + typedef bg::model::multi_point multipoint_type; + + test_geometry_equals( + "0104000000020000000101000000000000000000F03F0000000000000040010100000000000000000008400000000000001040", + "MULTIPOINT (1 2, 3 4)"); + + test_geometry_equals( + "01040000000200000001010000005839B4C876BEF33F83C0CAA145B61640010100000062A1D634EF3824409CC420B072482A40", + "MULTIPOINT (1.234 5.678, 10.1112 13.1415)"); + return 0; }