IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 1, 2009, 5:11:04 PM (17 years ago)
Author:
eugene
Message:

prevent multiple matches to the same input or reference source

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/pmAstrometryObjects.c

    r24022 r24034  
    8383{
    8484    psArray *matches = psArrayAllocEmpty(x1->n);
     85    psVector *found1 = psVectorAlloc(x1->n, PS_TYPE_S8);
     86    psVector *found2 = psVectorAlloc(x2->n, PS_TYPE_S8);
    8587
    8688    const double RADIUS_SQR = PS_SQR(RADIUS);
    8789    double dX, dY, dR;
     90
     91    psVectorInit (found1, 0);
     92    psVectorInit (found2, 0);
    8893
    8994    int jStart;
     
    100105        }
    101106
     107        if (found1->data.S8[i]) {
     108            i++;
     109            continue;
     110        }
     111        if (found2->data.S8[j]) {
     112            j++;
     113            continue;
     114        }
     115
    102116        jStart = j;
    103         while (fabs(dX) < RADIUS && j < x2->n) {
     117        while ((fabs(dX) < RADIUS) && (j < x2->n)) {
    104118
    105119            dX = x1->data.F64[i] - x2->data.F64[j];
     
    111125                continue;
    112126            }
     127            if (found2->data.S8[j]) {
     128                j++;
     129                continue;
     130            }
    113131
    114132            // got a match; add to output list
     
    117135            psFree (match);
    118136
     137            found1->data.S8[i] = 1;
     138            found2->data.S8[j] = 1;
     139
    119140            j++;
    120141        }
     
    122143        i++;
    123144    }
     145    psFree (found1);
     146    psFree (found2);
     147
    124148    return (matches);
    125149}
Note: See TracChangeset for help on using the changeset viewer.