Boost logo

Geometry :

Subject: [geometry] [Search Point in MultiPolygon]
From: Ederson de Moura (ederbsd_at_[hidden])
Date: 2013-08-05 11:17:08


Hello guys,

I need to find a point within "MultiPolygon". I'm trying to apply the
same logic
of the "polygon" example:

http://www.boost.org/doc/libs/1_54_0/libs/geometry/doc/html/geometry/reference/algorithms/within/within_2.html

But not to the point the result is always not found. Could someone help me?

The following code:

---------------------------------------------------------------------------------------------------------------
#include <QtCore>
#include <QDebug>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/algorithms/within.hpp>

#include <iostream>

int main( int argc, char* argv[] )
{
  QCoreApplication app( argc, argv );

  typedef boost::geometry::model::d2::point_xy<int> point_xy;
  typedef boost::geometry::model::polygon<point_xy> polygon;
  typedef boost::geometry::model::multi_polygon<polygon> multi_polygon;

  multi_polygon p_multi;

  boost::geometry::read_wkt( "MULTIPOLYGON(((0 0, 0 10, 10 10, 10 0, 0 0)),
((10 5, 10 15, 20 15, 20 5, 10 5)))", p_multi );

  int x = 10;
  int y = 10;

  point_xy p( x, y );

  std::cout << "Within: " << ( boost::geometry::within( p, p_multi ) ?
"Yes" : "No" ) << std::endl;
  return app.exec();
}

---------------------------------------------------------------------------------------------------------------

Always results (Within: No) for any geometric point!

Boost Version: 1.54.0

Regards,

EDM.

-- 
Ederson de Moura
http://sites.google.com/site/edersondemoura/


Geometry list run by mateusz at loskot.net