HI,
How to determine if a point is within a polygon.
I wrote this function
Private Function inPolygon(ByVal pA As Double(,), ByVal x As Double,
ByVal y As Double) As Boolean
'-------------------------------------------------------------------'
'Point inclusion in polygon test
'Makes use of the ray-casting algorithim (based on the Jordan
Curve
'Theorem) to determine if a point is within a polygon.
'Taken from W Randolph Franklin,
'http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/
pnpoly.html
'-------------------------------------------------------------------'
Dim i As Integer = 0
Dim j As Integer = 0
Dim c As Boolean = False
j = pA.GetUpperBound(0)
For i = 0 To pA.GetUpperBound(0)
If ((((pA(i, 1) <= y) And (y < pA(j, 1))) Or ((pA(j, 1) <=
y) And (y < pA(i, 1)))) _
And (x < (pA(j, 0) - pA(i, 0)) * (y - pA(i, 1)) / (pA(j,
1) - pA(i, 1)) + pA(i, 0))) Then
c = Not c
End If
j = i
Next
Return c
End Function
I need to use this function where i am pulling the points from the
databse.I am getting error, can anybody tell me how to do this
I was using like this, i am not sure if this is correct wa of doing
or not
Dim dr As OracleClient.OracleDataReader = cmd.ExecuteReader
If dr.HasRows Then
xml = "<?xml version=""1.0"" encoding=""iso-8859-1"" ?
>" + vbNewLine
xml += "<markers>" + vbNewLine
While dr.Read()
'If inPolygon(PollyArray(longitude, latitude), dr
("longitude"), dr("latitude")) Then
xml += "<marker"
Thanks
Nive
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---