Point in Multipolygon

Topics: General Topics, Algorithms, SharpMap v0.9 / v1.x
Aug 3, 2007 at 10:25 AM
Anyone has an example of checking Point in (Multi)polygon area ?
Thanks
Developer
Aug 3, 2007 at 12:50 PM
What do you mean exactly? If a point is inside a polygon?
I think you must use NTS functionalities, see the example here:
http://www.codeplex.com/SharpMap/Wiki/View.aspx?title=NetTopologySuite%20Data%20Provider
Aug 5, 2007 at 4:20 AM
It's more like geofence, Let say I've predefined 3 coordinate : (1,1), (7,1), (7,5)
and I want to check does point x(6,2) and point y(1,10) is inside the area or not. what should I used ?

Thanks
Coordinator
Aug 6, 2007 at 4:54 AM
You need to use NTS for that. See D_Guidi's link: NetTopologySuite Data Provider.
Aug 6, 2007 at 7:34 AM
Yup, i've seen it. but i dont see how to 'define' the coordinate instead. how to define the coordinate in sharpmap ?

thanks


codekaizen wrote:
You need to use NTS for that. See D_Guidi's link: NetTopologySuite Data Provider.

Aug 7, 2007 at 6:56 PM
Edited Aug 7, 2007 at 6:59 PM
Hi there,
I want to check, whether a point is inside an area or outside an area:

// the polygon we've to predefine.It'll be project an area.
List<Geometry> shapex = new List<Geometry>();
shapex.Add(new Point(0, 0));
shapex.Add(new Point(10, 0));
shapex.Add(new Point(10, 10));
shapex.Add(new Point(0, 10));

// here is the point we want to check.
SharpMap.Geometries.Point oPoint = new SharpMap.Geometries.Point(100, 100);
GisSharpBlog.NetTopologySuite.Geometries.Geometry oPt =
SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(oPoint, new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory());

how to check if the oPoint is in the area of shapex or not ?

Thanks
Developer
Aug 7, 2007 at 8:37 PM
Edited Aug 7, 2007 at 8:38 PM
Shapex is not a polygon but is a list of points, so it's a nonsense to check if a point is inside a list of points, right?
You need simply to build a polygon from a shapex list of points, then you could convert the SharpMap polygon to NTS polygon using the usual ToNTSGeometry and then call ntsPolygon.Contains(ntsPoint)...
Could be more easier? :D
Aug 8, 2007 at 8:04 AM
Edited Aug 8, 2007 at 8:06 AM
Ok Got It. Problem Solved. Just a little confious between List of Point and Polygon.
Is it anyway to put list of points to build a polygon in SQL Database ? How to do that ?

Thanks.


D_Guidi wrote:
Shapex is not a polygon but is a list of points, so it's a nonsense to check if a point is inside a list of points, right?
You need simply to build a polygon from a shapex list of points, then you could convert the SharpMap polygon to NTS polygon using the usual ToNTSGeometry and then call ntsPolygon.Contains(ntsPoint)...
Could be more easier? :D