Location warning project

As many of us have said I wouldn't trust Tasker to do it, but I made a task that will determine if you're within a box formed by four GPS coordinates and how far from the border you are if you're in it. The task requires the the GPS locations go in a clock-wise fashion. Like so:

Point A                     Point B
  *---------------------------*
  |                           |
  |                           |
  |                           |
  *---------------------------*
Point D                     Point C

here's the Task

Distance To Border (83)
A1: Variable Split [ 
    Name:%LOC 
    Splitter:, 
    Delete Base:Off ] 
A2: Variable Set [ 
    Name:%radius 
    To:6371000 
    Do Maths:On 
    Append:Off ] 
A3: Variable Set [ 
    Name:%lat1 
    To:%LOC1 
    Do Maths:Off 
    Append:Off ] 
A4: Variable Set [ 
    Name:%long1 
    To:%LOC2 
    Do Maths:Off 
    Append:Off ] 
A5: Variable Set [ 
    Name:%lat2 
    To:42.05745 
    Do Maths:Off 
    Append:Off ] 
A6: Variable Set [ 
    Name:%long2 
    To:-87.986069 
    Do Maths:Off 
    Append:Off ] 
A7: Variable Set [ 
    Name:%lat3 
    To:42.055411 
    Do Maths:Off 
    Append:Off ] 
A8: Variable Set [ 
    Name:%long3 
    To:-87.660599 
    Do Maths:Off 
    Append:Off ] 
A9: Variable Set [ 
    Name:%lat4 
    To:41.860356 
    Do Maths:Off 
    Append:Off ] 
A10: Variable Set [ 
    Name:%long4 
    To:-87.601547 
    Do Maths:Off 
    Append:Off ] 
A11: Variable Set [ 
    Name:%long4 
    To:-87.8899 
    Do Maths:Off 
    Append:Off ] 
A12: Variable Set [ 
    Name:%lat5 
    To:41.84399 
    Do Maths:Off 
    Append:Off ] 
A13: Variable Set [ 
    Name:%long5 
    To:-87.889938 
    Do Maths:Off 
    Append:Off ] 
A14: Java Function [ 
    Return:locCur 
    Class Or Object:Location 
    Function:new {Location} (String) 
    Param: 
    Param: 
    Param: 
    Param: 
    Param: ] 
A15: Java Function [ 
    Return: 
    Class Or Object:locCur 
    Function:setLatitude {} (double) 
    Param:%lat1 
    Param: 
    Param: 
    Param: 
    Param: ] 
A16: Java Function [ 
    Return: 
    Class Or Object:locCur 
    Function:setLongitude {} (double) 
    Param:%long1 
    Param: 
    Param: 
    Param: 
    Param: ] 
A17: For [ 
    Variable:%itr 
    Items:2:%lat(#) ] 
A18: Java Function [ 
    Return:locA 
    Class Or Object:Location 
    Function:new {Location} (String) 
    Param: 
    Param: 
    Param: 
    Param: 
    Param: ] 
A19: If [ %itr < %lat(#) ]
A20: Variable Set [ 
    Name:%itrnext 
    To:%itr+1 
    Do Maths:On 
    Append:Off ] 
A21: Else 
A22: Variable Set [ 
    Name:%itrnext 
    To:2 
    Do Maths:Off 
    Append:Off ] 
A23: End If 
A24: Java Function [ 
    Return: 
    Class Or Object:locA 
    Function:setLatitude {} (double) 
    Param:%lat(%itr) 
    Param: 
    Param: 
    Param: 
    Param: ] 
A25: Java Function [ 
    Return: 
    Class Or Object:locA 
    Function:setLongitude {} (double) 
    Param:%long(%itr) 
    Param: 
    Param: 
    Param: 
    Param: ] 
A26: Java Function [ 
    Return:locB 
    Class Or Object:Location 
    Function:new {Location} (String) 
    Param: 
    Param: 
    Param: 
    Param: 
    Param: ] 
A27: Java Function [ 
    Return: 
    Class Or Object:locB 
    Function:setLatitude {} (double) 
    Param:%lat(%itrnext) 
    Param: 
    Param: 
    Param: 
    Param: ] 
A28: Java Function [ 
    Return: 
    Class Or Object:locB 
    Function:setLongitude {} (double) 
    Param:%long(%itrnext) 
    Param: 
    Param: 
    Param: 
    Param: ] 
A29: Java Function [ 
    Return:%distcur(%itr) 
    Class Or Object:locA 
    Function:distanceTo {float} (Location) 
    Param:locCur 
    Param: 
    Param: 
    Param: 
    Param: ] 
A30: Java Function [ 
    Return:%distedge 
    Class Or Object:locA 
    Function:distanceTo {float} (Location) 
    Param:locB 
    Param: 
    Param: 
    Param: 
    Param: ] 
A31: Java Function [ 
    Return:%bearingcur 
    Class Or Object:locA 
    Function:bearingTo {float} (Location) 
    Param:locCur 
    Param: 
    Param: 
    Param: 
    Param: ] 
A32: Variable Set [ 
    Name:%bearingcur 
    To:torad(%bearingcur) 
    Do Maths:On 
    Append:Off ]
A33: Java Function [ 
    Return:%bearingab 
    Class Or Object:locA 
    Function:bearingTo {float} (Location) 
    Param:locB 
    Param: 
    Param: 
    Param: 
    Param: ] 
A34: Variable Set [ 
    Name:%bearingab 
    To:torad(%bearingab) 
    Do Maths:On 
    Append:Off ] 
A35: Variable Set [ 
    Name:%dtx(%itr) 
    To:asin(sin(%distcur(%itr)/%radius)*sin(%bearingcur-%bearingab))*%radius/1000 
    Do Maths:On 
    Append:Off ] 
A36: Variable Convert [ 
    Name:%dtx(%itr) 
    Function:Kilometres to Miles 
    Store Result In: ] 
A37: If [ %smallest !Set ]
A38: Variable Set [ 
    Name:%smallest 
    To:%dtx(%itr) 
    Do Maths:Off 
    Append:Off ] 
A39: Else 
A40: Variable Set [ 
    Name:%smallest 
    To:%dtx(%itr) 
    Do Maths:Off 
    Append:Off ] If [ %dtx(%itr) < %smallest ]
A41: End If 
A42: End For 
A43: Variable Set [ 
    Name:%smallest 
    To:round(%smallest) 
    Do Maths:On 
    Append:Off ] 
A44: If [ %smallest < 0 ]
A45: Flash [ 
    Text:You are out of the box 
    Long:Off ] 
A46: Else 
A47: Flash [ 
    Text:You are %smallest miles from a border 
    Long:Off ] 
A48: End If 

The four GPS coordinates form a box around Chicago, IL

I also believe the way I have it setup can be expanded to a shape with any number of edges. I haven't tested it though.

/r/tasker Thread