# File generated by Wizard 2.9.0 on Dec 16, 2024.
zone tw
   polygonal lat_lon
   maximum_altitude 20 km
   
   point 25:39:39.36n 120:30:25.18e
   point 25:06:17.31n 122:29:29.13e
   point 21:32:49.50n 121:05:56.86e
   point 22:19:43.20n 119:36:49.51e
   
   fill_color red 
   line_color red 
end_zone

processor randomPatrol WSF_SCRIPT_PROCESSOR 

   script Array<WsfGeoPoint> GenerateRandomPoints(int numPoints)
      WsfZone zone = zone.FindZone("tw");
      WsfGeoPoint pMax = zone.MaxPoint();
      WsfGeoPoint pMin = zone.MinPoint();
      Array<WsfGeoPoint> randomPoints = {};
      
      double minLatitude = pMin.Latitude();
      double maxLatitude = pMax.Latitude();
      
      double minLongitude = pMin.Longitude();
      double maxLongitude = pMax.Longitude();
      
      while(randomPoints.Size() < numPoints)
      {
         double randomLatitude = RANDOM.Uniform(minLatitude,maxLatitude);
         double randomLongitude = RANDOM.Uniform(minLongitude,maxLongitude);
         WsfGeoPoint candidatePoint = candidatePoint.Construct(randomLatitude,randomLongitude,5000);
         if( zone.PointIsInside(candidatePoint))
         {
            randomPoints.PushBack(candidatePoint);
         }
      }
      return randomPoints;
   end_script
   execute at_time 20 sec relative
      Array<WsfGeoPoint> randomPoints = GenerateRandomPoints(10);
      WsfRoute route;
      WsfRoute r1 = route.Create("lx");
#      WsfWaypoint wwp1;
#      wwp1.SetLabel("start");
#      r1.Insert(0,wwp1);
      foreach(WsfGeoPoint vertex in randomPoints)
      {
         r1.Append(vertex,190);
      }
#      WsfWaypoint wwp2;
#      wwp2.SetLabel("start");
#      r1.Insert(r1.Size()-1,wwp2);
#      r1.Print();
      PLATFORM.FollowRoute(r1);
   end_execute



end_processor