Skip to content
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

registered types vs existing models: within function compilation error #364

Closed
daniel-j-h opened this issue Sep 10, 2016 · 1 comment
Closed
Assignees
Labels

Comments

@daniel-j-h
Copy link

I have the following use-case: check if a linestring is within a polygon.
Coordinate system is Spherical Equatorial.

The support-matrix in the documentation says this should work.

When I use the existing Boost.Geometry linestring and polygon models the

within(linestring, polygon)

function call compiles fine. But when I'm switching out the existing Boost.Geometry linestring model with my own type (which I registered as a linestring) compilation fails.

Here is a small self-contained test case reproducing this issue:

#include <vector>

#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>

struct myPoint { float x, y; };
struct myLine { std::vector<myPoint> pts; };

BOOST_GEOMETRY_REGISTER_POINT_2D(myPoint, float, cs::spherical_equatorial<degree>, x, y)
BOOST_GEOMETRY_REGISTER_LINESTRING(std::vector<myPoint>)

using bgPoint = boost::geometry::model::point<float, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>>;
using bgPoly = boost::geometry::model::polygon<bgPoint>;

int main() {
  myLine ln;
  bgPoly ply;

  boost::geometry::within(ln.pts, ply);  // does not compile

  // but this does, although I expected this to be exactly the same
  //
  //using bgLine = boost::geometry::model::linestring<bgPoint>;
  //bgLine ln2;
  //boost::geometry::within(ln2, ply);
}

This is surprising to me since both types are spherical equatorial, float precision, degree unit. There is no semantic difference from what I can see. I expected them to behave identically.

Here is the full error log. Boost version is 1.62 beta1.
https://gist.github.com/daniel-j-h/64bae0c01caaff30c2e40d27f7a98406

@awulkiew
Copy link
Member

Thanks!
Fix: c5b7468

@awulkiew awulkiew added the bug label Dec 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants