Last active
August 29, 2015 14:01
-
-
Save mariosv/9c8f4fa106c0546f95cf to your computer and use it in GitHub Desktop.
[boost::geometry] within() invalid result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <boost/geometry.hpp> | |
#include <boost/geometry/geometries/geometries.hpp> | |
#include <boost/geometry/io/wkt/wkt.hpp> | |
#include <boost/geometry/strategies/cartesian/point_in_poly_franklin.hpp> | |
#include <boost/geometry/strategies/cartesian/point_in_poly_crossings_multiply.hpp> | |
namespace bg = boost::geometry; | |
typedef bg::model::point<double, 2, bg::cs::cartesian> Point; | |
typedef bg::model::polygon<Point> Polygon; | |
int main() | |
{ | |
Polygon poly; | |
bg::read_wkt("POLYGON((-2.00000000000000000000 -1.99999999999999977796," | |
"-1.99999999999999977796 2.00000000000000000000," | |
"2.00000000000000000000 1.99999999999999977796," | |
"1.99999999999999977796 -2.00000000000000000000," | |
"-2.00000000000000000000 -1.99999999999999977796))", | |
poly); | |
Point p; | |
bg::read_wkt("POINT(4.00000000000000000000 -2.00000000000000044409)", p); | |
bool r1 = bg::within(p, poly); | |
bool r2 = bg::within(p, poly, bg::strategy::within::franklin<Point>()); | |
bool r3 = bg::within(p, poly, | |
bg::strategy::within::crossings_multiply<Point>()); | |
std::cout << "results: " << r1 << ", " << r2 << ", " << r3 << "\n"; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment