def remove_mission_nofly(self, key, selection_index):
        '''remove a mission nofly polygon'''
        if not self.validate_nofly():
            print("NoFly invalid")
            return
        print("NoFly valid")

        idx = self.selection_index_to_idx(key, selection_index)
        wploader = self.module('wp').wploader

        if idx < 0 or idx >= wploader.count():
            print("Invalid wp number %u" % idx)
            return
        wp = wploader.wp(idx)
        if wp.command != mavutil.mavlink.MAV_CMD_NAV_FENCE_POLYGON_VERTEX_EXCLUSION:
            print("Not an exclusion point (%u)" % idx)
            return

        # we know the list is valid.  Search for the start of the sequence to delete
        tmp_idx = idx
        while tmp_idx > 0:
            tmp = wploader.wp(tmp_idx-1)
            if (tmp.command != wp.command or
                tmp.param1 != wp.param1):
                break
            tmp_idx -= 1

        start_idx_to_delete = idx - ((idx-tmp_idx)%int(wp.param1))
        for i in range(int(start_idx_to_delete+wp.param1)-1,start_idx_to_delete-1,-1):
            # remove in reverse order as wploader.remove re-indexes
            print("Removing at %u" % i)
            deadun = wploader.wp(i)
            wploader.remove(deadun)
        self.module('wp').send_all_waypoints()
def remove_mission_nofly ( self , key , selection_index ) : if not self . validate_nofly ( ) : print ( "NoFly invalid" ) return print ( "NoFly valid" ) idx = self . selection_index_to_idx ( key , selection_index ) wploader = self . module ( 'wp' ) . wploader if idx < 0 or idx >= wploader . count ( ) : print ( "Invalid wp number %u" % idx ) return wp = wploader . wp ( idx ) if wp . command != mavutil . mavlink . MAV_CMD_NAV_FENCE_POLYGON_VERTEX_EXCLUSION : print ( "Not an exclusion point (%u)" % idx ) return tmp_idx = idx while tmp_idx > 0 : tmp = wploader . wp ( tmp_idx - 1 ) if ( tmp . command != wp . command or tmp . param1 != wp . param1 ) : break tmp_idx -= 1 start_idx_to_delete = idx - ( ( idx - tmp_idx ) % int ( wp . param1 ) ) for i in range ( int ( start_idx_to_delete + wp . param1 ) - 1 , start_idx_to_delete - 1 , - 1 ) : print ( "Removing at %u" % i ) deadun = wploader . wp ( i ) wploader . remove ( deadun ) self . module ( 'wp' ) . send_all_waypoints ( )
remove a mission nofly polygon