|
Geometry : |
Subject: [ggl] Within polygon detection including the polygon borders
From: Ivan Marin (ispmarin)
Date: 2009-09-03 17:23:57
Dear all,
I successfully compiled the examples and now I'm trying to use the ggl. I
need to check if a point is inside a polygon, and I want to consider de
borders as part of the polygon. Is this possible in ggl? All the tests that
I've made showed me that this is not possible. Am I wrong?
Thank you!
Ivan
+++++++++++++++++++++++
#include <geometry/geometry.hpp>
#include <geometry/geometries/cartesian2d.hpp>
#include <geometry/io/wkt/streamwkt.hpp>
#include <geometry/algorithms/within.hpp>
#include <vector>
#include <iostream>
std::string boolstr(bool v)
{
return v ? "true" : "false";
}
using namespace geometry;
using namespace geometry::strategy::within;
int main () {
geometry::polygon_2d poly;
geometry::point_2d c3 = make<point_2d>(1.0,1.0);
geometry::point_2d c4 = make<point_2d>(1.0,3.0);
geometry::point_2d c5 = make<point_2d>(3.0,3.0);
geometry::point_2d c6 = make<point_2d>(3.0,1.0);
geometry::point_2d c7 = make<point_2d>(1.0,1.0);
std::vector <geometry::point_2d> vec;
vec.push_back(c3);
vec.push_back(c4);
vec.push_back(c5);
vec.push_back(c6);
vec.push_back(c7);
geometry::assign(poly,vec);
geometry::correct(poly);
std::cout << poly << std::endl;
std::cout << "point in polygon:"
<< " p1: " << boolstr(within(make<point_2d>(1.5, 1.0),
poly))
<< std::endl;
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/ggl/attachments/20090903/f274a306/attachment.html
Geometry list run by mateusz at loskot.net