Opened 4 years ago

#13593 new Bugs

intersects assertion failure for linestrings in spherical_equatorial coordinates

Reported by: swordvetal@… Owned by: Barend Gehrels
Milestone: To Be Determined Component: geometry
Version: Boost 1.67.0 Severity: Problem
Keywords: geometry, intersects, spherical_equatorial, linestrings Cc:

Description

I have found a specific case when boost::geometry::intersects fails with assertion "lhs.denominator() != 0" on linestrings with equal (or very close) segments in spherical_equatorial coordinate system. Here is the test example:

#include <iostream>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/version.hpp>

int main()
{
    using GeoCoordSystem = boost::geometry::cs::spherical_equatorial<boost::geometry::degree>;
    using GeoPoint = boost::geometry::model::d2::point_xy<double, GeoCoordSystem>;
    boost::geometry::model::linestring<GeoPoint> line1, line2;

    boost::geometry::read_wkt("linestring(11.5800734 48.2523631, 11.580114 48.2524051, 11.5801572 48.2524435)", line1);
    boost::geometry::read_wkt("linestring(11.5800734 48.2523631, 11.580114 48.2524051, 11.5801572 48.2524434)", line2);

    std::cout << "Using boost v" << BOOST_VERSION << std::endl;

    const bool b = boost::geometry::intersects(line1, line2);

    std::cout << "Intersects: " << (b ? "YES" : "NO") << std::endl;

    return 0;
}

Program output is the following:

Using boost v106700
a.out: /opt/Storage/Install/boost_1_67_0/boost/geometry/policies/robustness/segment_ratio.hpp:54: static bool boost::geometry::detail::segment_ratio::less<Type, false>::apply(const Ratio&, const Ratio&) [with Ratio = boost::geometry::segment_ratio<double>; Type = double]: Assertion `lhs.denominator() != 0' failed.
Aborted (core dumped)

The issue is reproducible in both boost v1.63 and latest v1.67.

Change History (0)

Note: See TracTickets for help on using tickets.