#ifndef TS_RESOLVE_H
#define TS_RESOLVE_H

#include <dervish.h>

/* The end row in a field for a segment is required to lie at least this
 * distance in pixels away from the actual first or last non-overlap rows
 * in a field.  This takes up any of the curvature of nu vs. col along
 * the row, so that we need not worry about objects flipping across the
 * boundary row between fields when we worry about objects flipping across
 * the boundary mu between segments.
 */
#define ROW_BUFFER  5

/* The status of a segment of fields in the survey */
typedef enum
{
  TS_PRIMARY,         /* already resolved into a primary segment */
  TS_SECONDARY,       /* already resolved into a secondary segment */
  TS_BAD,             /* already resolved into a bad segment */
  TS_UNRESOLVED_BAD,  /* unresolved unacceptable data */
  TS_UNRESOLVED_OK,   /* unresolved potentially acceptable data */
  TS_UNDETERMINED,    /* unresolved, but data quality not set */
  TS_UNPROCESSED      /* lacking processing steps before resolve */
} TSSEGMENTSTATUS;

/* A segment of fields. */
typedef struct tsSegment
{
  int startMu;               /* The beginning great circle longitude of the  
                              * segment. (arcsecs) */
  int endMu;                 /* The ending great circle longitude of the  
                              * segment. (arcsecs) */
  int field0;                /* Beginning field. */
  int nFields;               /* Number of fields in the segment.  */
  TSSEGMENTSTATUS status;    /* Status of this segment within the survey. */
} TSSEGMENT; /* pragma SCHEMA */

/* A Frames Pipeline Run, for purposes of resolving. */
typedef struct tsRun
{
  int stripe;                     /* Stripe number. */
  int strip;                      /* Strip (1-north, 0-south). */
  int camCol;                     /* Camera column. */
  int scanline;                   /* stripe * 12 + (camCol - 1) * 2 + strip */
  int run;                        /* Imaging run number. */
  int rerun;                      /* Rerun number. */
  int field0;                     /* First field in run. */
  int nFields;                    /* Number of fields in run. */
  CHAIN *segments;                /* Chain of segments. */
} TSRUN; /* pragma SCHEMA */

#endif
