Opened 6 years ago

Closed 6 years ago

#12342 closed Bugs (fixed)

boost rtree and polygon with adapted point type doesn't compile

Reported by: soldevelopment1234@… Owned by: Barend Gehrels
Milestone: Boost 1.62.0 Component: geometry
Version: Boost 1.61.0 Severity: Problem
Keywords: rtree intersects box polygon Cc: soldevelopment1234@…

Description

I am using boost 1.61

Compiling with VS2015

The following code won't compile. I expect it to --- I think it is the use of the adapter BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET that is upsetting things.

#include <boost/geometry/geometry.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <vector>
#include <boost/geometry/geometries/register/point.hpp>

class wxPoint
{
public:
    wxPoint(double x, double y)
        : m_x(x),
          m_y(y)
    {
    }

    wxPoint() {}

    double  getx() const
    {
        return m_x;
    }
    double gety() const
    {
        return m_y;
    }
    void setx(double in)
    {
        m_x = in;
    }
    void sety(double in)
    {
        m_y = in;
    }
private:
    double m_x;
    double m_y;
};

BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(
    wxPoint,
    double,
    boost::geometry::cs::geographic<boost::geometry::degree>,
    wxPoint::getx,
    wxPoint::gety,
    wxPoint::setx,
    wxPoint::sety)


typedef std::pair<wxPoint, unsigned> value;


int main()
{

    boost::geometry::index::rtree< value, boost::geometry::index::quadratic<16> > rtree;

    wxPoint p(4, 1);

    rtree.insert(std::make_pair(p, 1));

    std::vector<value> result_s;

    typedef boost::geometry::model::polygon<wxPoint> polygon_type;

    polygon_type poly;
    boost::geometry::read_wkt(
        "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
        "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", poly);

    rtree.query(boost::geometry::index::within(poly), std::back_inserter(result_s));

    return 0;
}

compiler output attached as a file

Attachments (1)

compileroutput.txt (74.5 KB ) - added by anonymoussoldevelopment1234@… 6 years ago.
compiler output

Download all attachments as: .zip

Change History (2)

by anonymoussoldevelopment1234@…, 6 years ago

Attachment: compileroutput.txt added

compiler output

comment:1 by awulkiew, 6 years ago

Keywords: intersects box polygon added
Milestone: To Be DeterminedBoost 1.62.0
Resolution: fixed
Status: newclosed

Thanks!

This bug was fixed in Boost 1.62.

Fix: https://github.com/boostorg/geometry/commit/54de9f96a1b29d11e1a8044ac8fcc6accfa5201f

It's more or less a duplicate of: https://svn.boost.org/trac/boost/ticket/12189. More or less because in this case geometries are defined in non-cartesian CS. This bug is fixed in two ways in 1.62. The cartesian intersection strategy is fixed as mentioned above but also new spherical intersection strategy is introduced and used for geometries in non-cartesian coordinate systems.

Note: See TracTickets for help on using tickets.