# include "relastro.h"

// this function operates on Measure, not MeasureTiny
int UpdateMeasures (Catalog *catalog, int Ncatalog) {

  off_t i, Nimage;
  Image *image;

  int badImage = 
    ID_IMAGE_ASTROM_NOCAL | 
    ID_IMAGE_ASTROM_POOR | 
    ID_IMAGE_ASTROM_FAIL | 
    ID_IMAGE_ASTROM_SKIP | 
    ID_IMAGE_ASTROM_FEW;

  image = getimages (&Nimage, NULL);

  for (i = 0; i < Nimage; i++) {

    /* skip DIS images (since they have no associated detections) */
    if (!strcmp(&image[i].coords.ctype[4], "-DIS")) continue;

    // skip images that have failed solutions (divergent or otherwise)
    if (image[i].flags & badImage) continue;

    /* convert measure coordinates to raw entries */
    fixImageRaw (catalog, Ncatalog, i);
  }

  return (TRUE);
}

