New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid envelope of spherical polygon #471

Closed
awulkiew opened this Issue Apr 9, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@awulkiew
Member

awulkiew commented Apr 9, 2018

It seems envelope() function return incorrect bounding box for spherical polygon in Boost 1.67.0.

To reproduce:

#include <boost/geometry.hpp>
#include <iostream>

using coordinate_system = boost::geometry::cs::spherical_equatorial<boost::geometry::degree>;
using lonlat = boost::geometry::model::point<double, 2, coordinate_system>;
using box = boost::geometry::model::box<lonlat>;
using polygon = boost::geometry::model::polygon<lonlat>;
using linestring = boost::geometry::model::linestring<lonlat>;

int main()
{
    polygon p{{{
            {2.4, 48.9021},
            {2.4, 48.89},
            {2.3, 48.89},
            {2.3, 48.9021},
            {2.4, 48.9021}
    }}};
    linestring l{
            {2.4, 48.9021},
            {2.4, 48.89},
            {2.3, 48.89},
            {2.3, 48.9021},
            {2.4, 48.9021}
    };

    box mbr1 = boost::geometry::return_envelope<box>(p);
    box mbr2 = boost::geometry::return_envelope<box>(l);

    std::cout << std::setprecision(7) << std::fixed;
    std::cout << boost::geometry::wkt(mbr1.min_corner()) << " " << boost::geometry::wkt(mbr1.max_corner()) << std::endl;
    std::cout << boost::geometry::wkt(mbr2.min_corner()) << " " << boost::geometry::wkt(mbr2.max_corner()) << std::endl;
}

Result:

POINT(2.3000000 48.8900000) POINT(2.4000000 48.9021000)
POINT(2.3000000 48.8900000) POINT(2.4000000 48.9021108)

The reason is that in the case of polygon envelope is calculated by iterating through points while in the case of linestring segments are taken into account.

@awulkiew

This comment has been minimized.

Member

awulkiew commented Apr 9, 2018

I'd expect the same issue with geographic CS.

@awulkiew awulkiew added the bug label Apr 9, 2018

@awulkiew awulkiew added this to the 1.68 milestone Apr 9, 2018

@awulkiew awulkiew closed this Apr 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment