Difference between revisions of "CPP/Boost/Geometry/PointInPolygon"
From ProgrammingExamples
< CPP
Daviddoria (Talk | contribs) (Created page with 'Can't pass a point_xy as the point argument of within()? ==PointInPolygon.cpp== <source lang="cpp"> #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hp…') |
(No difference)
|
Revision as of 15:16, 29 July 2011
Can't pass a point_xy as the point argument of within()?
PointInPolygon.cpp
#include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/polygon.hpp> //using namespace boost::geometry; #include <iostream> int main () { double points[][2] = {{2.0, 1.3}, {4.1, 3.0}, {5.3, 2.6}, {2.9, 0.7}, {2.0, 1.3}}; boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > poly; boost::geometry::append(poly, points); //boost::tuple<double, double> p = boost::make_tuple(3.7, 2.0); boost::geometry::model::d2::point_xy<double> p(3.7, 2.0); std::cout << "Point p is in polygon? " << std::boolalpha << boost::geometry::within(p, poly) << std::endl; return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) Project(PointInPolygon) set(Boost_USE_MULTITHREADED ON) FIND_PACKAGE(Boost 1.38 COMPONENTS required) INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS}) ADD_EXECUTABLE(PointInPolygon PointInPolygon.cpp)