Is point within polygon?

Jun 27, 2012 at 5:01 PM
Edited Jul 2, 2012 at 5:16 PM

Hi,

using MapWinGIS 4.8 ...

I finally came up with a function that tells me whether a given point is within a given polygon; it looks like this (VB6):

 

Private Function IsPointInPolygon(pol As MapWinGIS.Shape, pt As MapWinGIS.Point) As Boolean
Dim p As MapWinGIS.Shape, l As Long
Debug.Assert pol.ShapeType = SHP_POLYGON
Set p = New MapWinGIS.Shape
p.Create SHP_POINT
p.InsertPoint pt, l
Debug.Assert l = 0
IsPointInPolygon = p.Within(pol)
Debug.Assert IsPointInPolygon = pol.PointInThisPoly(pt)  'assertion fails - bug???
Debug.Assert IsPointInPolygon = pol.Contains(p)          'assertion fails - bug???
End Function

 

.Within() works as expected, however .PointInThisPoly and .Contains do not - they return False all the time even when .Within returns True. Why don't they? Am I getting something wrong, or are these bugs?

Any input appreciated!

Wolfgang