kleunen / boost_geometry_correct

Advanced correct for boost geometry polygons
32 stars 6 forks source link

Visual studio compilaton error #3

Open Vishnu-C opened 2 years ago

Vishnu-C commented 2 years ago

On implementation in a VS project a compilation error is thrown, any suggestions?

Code


#include <correct.hpp>
#include <boost/assign.hpp>

typedef boost::geometry::model::d2::point_xy<double> point;
typedef boost::geometry::model::polygon<point> polygon;
typedef boost::geometry::model::multi_polygon<polygon> multi_polygon;

void CRegion::CorrectPolyline(PolylineClass myPolyLine)
{
    std::vector<point> points;
    for (int p = 0;p < myPolyLine->GetNumberOfPoints();p++)
    {
        double pnt[3];
        myPolyLine->GetPoint(p, pnt);
        points.push_back(point(pnt[0], pnt[1]));
    }
    // Create a polygon object and assign the points to it.
    polygon aPolygon;
    boost::geometry::assign_points(aPolygon, points);

    multi_polygon input;
    input.push_back(aPolygon);
    multi_polygon result;
    double remove_spike_threshold = 1E-12;
    geometry::correct(input, result, remove_spike_threshold);

    for (auto const& poly : result) {
        std::cout << "Polygon area: " << boost::geometry::area(poly) << std::endl;
    }
}

Error

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\xtree(1599,1): error C3848: expression having type 'const geometry::impl::compare_point_less' would lose some const-volatile qualifiers in order to call 'bool geometry::impl::compare_point_less::operator ()(const point_t &,const point_t &)' 1> with 1> [ 1> point_t=boost::geometry::model::d2::point_xy<double,boost::geometry::cs::cartesian> 1> ]

kleunen commented 2 years ago

Can you try if this resolves things: https://github.com/kleunen/boost_geometry_correct/commit/89896f0bb7dab30f53930cf7ab4140297666de8c

(Current HEAD)

Vishnu-C commented 2 years ago

Thanks that fixed the compilation error. But the execution gets stuck inside the while loop and never leaves out. I tried the example data set from benchmark function, yet the execution was struck and incomplete.

Thanks again!

kleunen commented 2 years ago

I reverted some changes which were causing problems

Vishnu-C commented 2 years ago

Tested with the latest, still the execution is stuck inside the while loop.

kleunen commented 2 years ago

Stuck on the example data or your own polygon?

Vishnu-C commented 2 years ago

Its stuck on both.

kleunen commented 2 years ago

I noticed the vectors are not initialized with visual c++. I need to look into this

kleunen commented 2 years ago

Can you try with the current head ?

Vishnu-C commented 2 years ago

@kleunen Thanks, it works!