diff --git a/pusher.chv.com.b4a b/Pusher.b4a similarity index 100% rename from pusher.chv.com.b4a rename to Pusher.b4a diff --git a/subs.bas b/subs.bas index 71c876f..7071c5d 100644 --- a/subs.bas +++ b/subs.bas @@ -136,4 +136,51 @@ End Sub 'Centra un panel dentro de un elemento superior Sub centraPanel(elemento As Panel, anchoElementoSuperior As Int) 'ignore elemento.Left = Round(anchoElementoSuperior/2)-(elemento.Width/2) +End Sub + +'Geo-Zone Determination (Point in Polygon) +'Use this to determine If a vehicle is within a defined zone made of 5 or more lat/lon coordinates. +'Point 1 Is also Point 5 (first point And last point are same value). +'You can add the points clockwise or counterclockwise. +Sub FindInZone( polx As List, poly As List, x As Double, y As Double) As Boolean 'ignore + ' polx = list of lats for polygon + ' poly = list of lons for polygon + ' y = lon to test + ' x = lat to test + Dim x1, y1, x2, y2, D As Double + Dim i, ni As Int + ni = 0 + x1 = polx.Get(0) + y1 = poly.Get(0) + For i = 0 To polx.Size -1 + If i < polx.Size Then + x2 = polx.Get(i) + y2 = poly.Get(i) + Else + x2 = polx.Get(0) ' checks the last line + y2 = poly.Get(0) + End If + If y >= Min(y1, y2) Then + If y <= Max(y1, y2) Then + If x <= Max(x1, x2) Then + If (x = x1 And y = y1) Or (x = x1 And x = x2) Then ' checks vertices and vertical lines + Return True + End If + If y1 <> y2 Then + D = (y - y1) * (x2 - x1) / (y2 - y1) + x1 + If x1 = x2 Or x <= D Then + ni = ni + 1 + End If + End If + End If + End If + End If + x1 = x2 + y1 = y2 + Next + If ni Mod 2 = 0 Then + Return False + Else + Return True + End If End Sub \ No newline at end of file