|
Geometry : |
Subject: [ggl] Geographical point in a polygon
From: chris kaiser (mustanga30)
Date: 2011-12-06 16:57:50
Hi,
I'm trying to determine is geographical point lies in a geographical polygon. I've created a test app (see below) that defines a polygon that encompasses the North Pole. I then define a point that?corresponds?to the North Pole. The within function returns false. Am I doing something wrong here? Any help would be appreciated.
Thanks,
Chris
#include <iostream>
#include <iomanip>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/extensions/algorithms/parse.hpp>
#include <boost/geometry/extensions/gis/latlong/latlong.hpp>
#include <vector>
int main()
{
? ? using namespace boost::geometry;
? ? typedef model::ll::point<degree> latlon_point;
? ? typedef model::polygon<latlon_point> polygon_latlon;
? ? polygon_latlon poly;
? ? latlon_point a, b, c, d, p;
? ? a.lat(dms<north>(60, 0, 0));
? ? a.lon(dms<east>(0, 0, 0));
? ? append(poly, a);
? ? b.lat(dms<north>(60, 0, 0));
? ? b.lon(dms<west>(90, 0, 0));
? ? append(poly, b);
? ? c.lat(dms<north>(60, 0, 0));
? ? c.lon(dms<east>(180, 0, 0));
? ? append(poly, c);
? ??
? ? d.lat(dms<north>(60, 0, 0));
? ? d.lon(dms<east>(90, 0, 0));
? ? append(poly, d);
? ? p.lat(dms<north>(90,0,0));
? ? p.lon(dms<east>(0,0,0));
?
? ? std::cout << "within: " << (boost::geometry::within(p, poly) ? "yes" : "no") << std::endl;
? ??
? ? return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/ggl/attachments/20111206/1a09defe/attachment.html
Geometry list run by mateusz at loskot.net