// file: spmtch_compare_1.cc
//

// isip include files
//
#include "subpath_match.h"
#include "subpath_match_constants.h"

// method: equal_to_cc
//
// arguments:
//  Subpath_match* match: (input) Subpath object to compare to
//  float_4 thresh: (input) overlap threshold for determining
//  whether two matches are equal
// return: a logical_1 flag indicating comparison match
//
logical_1 Subpath_match::equal_to_cc(Subpath_match* match_a, float_4 thresh_a) {
  
  // determine overlap bounds
  //
  int_4 left_bound, right_bound, overlap_left, overlap_right;
  
  // left bound
  //
  if (start_time_d <= match_a->start_time_d) {
    left_bound = start_time_d;
    overlap_left = match_a->start_time_d;
  }
  else {
    left_bound = match_a->start_time_d;
    overlap_left = start_time_d;
  }

  // right bound
  //
  if (start_time_d > match_a->end_time_d) {
    right_bound = end_time_d;
    overlap_right = match_a->end_time_d;
  }
  else {
    right_bound = match_a->end_time_d;
    overlap_right = end_time_d;
  }

  // compute overlap
  //
  float_4 overlap = (float_4)(right_bound - left_bound)/(float_4)(overlap_right - overlap_left);

  // compare info about the two matches
  //
  if (overlap >= thresh_a) {
    return ISIP_TRUE;
  }
  else {
    return ISIP_FALSE;
  }

  // exit gracefully
  //
  return ISIP_TRUE;
}
