Ticket #9066: Mats-Taraldsvik-MultiPoint-WKB.patch

File Mats-Taraldsvik-MultiPoint-WKB.patch, 11.5 KB (added by Mateusz Loskot, 9 years ago)

Combined patch with Mats' changes generated against SVN trunk r85516

  • boost/geometry/algorithms/equals.hpp

     
    3333// For trivial checks
    3434#include <boost/geometry/algorithms/area.hpp>
    3535#include <boost/geometry/algorithms/length.hpp>
     36#include <boost/geometry/algorithms/num_points.hpp>
    3637#include <boost/geometry/util/math.hpp>
    3738#include <boost/geometry/util/select_coordinate_type.hpp>
    3839#include <boost/geometry/util/select_most_precise.hpp>
     
    5051namespace detail { namespace equals
    5152{
    5253
     54struct 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};
    5364
    5465template
    5566<
  • boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp

     
    6868    {
    6969        point      = 1,
    7070        linestring = 2,
    71         polygon    = 3
    72 
     71        polygon    = 3,
     72       
    7373        // TODO: Not implemented
    74         //multipoint = 4,
     74        multipoint = 4,
    7575        //multilinestring = 5,
    7676        //multipolygon = 6,
    7777        //collection = 7
  • boost/geometry/extensions/gis/io/wkb/detail/parser.hpp

     
    110110        if (value_parser<boost::uint32_t>::parse(it, end, value, order))
    111111        {
    112112            // TODO: Refine the test when multi* geometries are supported
    113 
     113           
    114114            boost::uint32_t id = value & 0xff;
    115             if (geometry_type::polygon >= id)
     115           
     116            if (geometry_type::multipoint >= id)
    116117            {
    117118                type = geometry_type::enum_t(id);
    118119                return true;
  • 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
     23namespace boost { namespace geometry
     24{
     25
     26#ifndef DOXYGEN_NO_DETAIL
     27namespace detail { namespace wkb
     28{
     29
     30template <typename MultiPoint>
     31struct 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
     17namespace boost { namespace geometry
     18{
     19
     20#ifndef DOXYGEN_NO_DISPATCH
     21namespace dispatch
     22{
     23
     24template <typename Geometry>
     25struct 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

     
    2020#include <boost/geometry/multi/geometries/concepts/check.hpp>
    2121
    2222#include <boost/geometry/algorithms/equals.hpp>
     23#include <boost/geometry/multi/algorithms/num_points.hpp>
    2324
    2425
    2526namespace boost { namespace geometry
     
    2930namespace dispatch
    3031{
    3132
     33template <typename MultiPoint1, typename MultiPoint2, bool Reverse>
     34struct 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{};
    3243
    3344template <typename MultiPolygon1, typename MultiPolygon2, bool Reverse>
    3445struct equals
  • libs/geometry/extensions/test/gis/Jamfile.v2

     
    1010
    1111build-project latlong ;
    1212build-project projections ;
     13build-project io ;
    1314
  • 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
     11build-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
     11test-suite boost-geometry-io-wkb
     12    :
     13    [ run read_wkb.cpp ]
     14    ;
     15
  • libs/geometry/extensions/test/gis/io/wkb/read_wkb.cpp

     
    2222#include <boost/geometry/extensions/gis/io/wkb/read_wkb.hpp>
    2323#include <boost/geometry/extensions/gis/io/wkb/utility.hpp>
    2424
     25#include <boost/geometry/multi/algorithms/equals.hpp>
     26#include <boost/geometry/multi/geometries/multi_geometries.hpp>
     27#include <boost/geometry/multi/io/wkt/read.hpp>
     28
     29#include <boost/geometry/extensions/multi/gis/io/wkb/read_wkb.hpp>
     30
    2531namespace bg = boost::geometry;
    2632
    2733namespace { // anonymous
     
    5359//template <typename P, bool Result>
    5460//void test_polygon_wkt(std::string const& wkt)
    5561//{
    56 //    typedef bg::model::linestring<P> linestring_type;
    57 //    typedef bg::model::polygon<linestring_type> polygon_type;
     62// typedef bg::model::linestring<P> linestring_type;
     63// typedef bg::model::polygon<linestring_type> polygon_type;
    5864//
    59 //    polygon_type poly;
    60 //    bg::read_wkb(wkb, poly);
     65// polygon_type poly;
     66// bg::read_wkb(wkb, poly);
    6167//}
    6268
    6369} // namespace anonymous
     
    103109    test_geometry_equals<point_type, false>(
    104110        "01010000E0E61000005839B4C876BEF33F83C0CAA145B616400000000000002E400000000000C05340",
    105111        "POINT (1.234 5.678)");
    106 
     112   
     113    //
     114    // LineString
     115    //
     116   
     117    //test_geometry_equals<linestring_type, true>(
     118    //  "0102000000030000005839B4C876BEF33F83C0CAA145B616404F401361C333224062A1D634EF3824409CC420B072482A40EB73B515FB2B3040",
     119    //  "LINESTRING (1.234 5.678, 9.1011 10.1112, 13.1415 16.1718)");
     120   
     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",       "MULTIPOINT (1 2, 3 4)");
     130   
     131    test_geometry_equals<multipoint_type, true>(
     132    "01040000000200000001010000005839B4C876BEF33F83C0CAA145B61640010100000062A1D634EF3824409CC420B072482A40",       "MULTIPOINT (1.234 5.678, 10.1112 13.1415)");
     133   
    107134    return 0;
    108135}