IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 15, 2009, 3:49:50 PM (17 years ago)
Author:
Paul Price
Message:

Only write sexagesimal coordinates if we're writing RA in hours and
Dec in degrees, otherwise we're liable to confuse people. Of course,
in every other case, we write decimal values, and then the user has
to check the format anyway. Fixes ticket 1264.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r23819 r24419  
    3636// Format type for time
    3737typedef enum {
    38   TIME_FORMAT_YYYYMMDD,                 // Date stored in YYYY-MM-DD order (ISO-standard)
    39   TIME_FORMAT_DDMMYYYY,                 // Date stored in DD-MM-YYYY order
    40   TIME_FORMAT_MMDDYYYY,                 // Date stored in MM-DD-YYYY order
    41   TIME_FORMAT_JD,                       // Date stored as JD
    42   TIME_FORMAT_MJD,                      // Date stored as MJD
     38  TIME_FORMAT_YYYYMMDD,                 // Date stored in YYYY-MM-DD order (ISO-standard)
     39  TIME_FORMAT_DDMMYYYY,                 // Date stored in DD-MM-YYYY order
     40  TIME_FORMAT_MMDDYYYY,                 // Date stored in MM-DD-YYYY order
     41  TIME_FORMAT_JD,                       // Date stored as JD
     42  TIME_FORMAT_MJD,                      // Date stored as MJD
    4343} conceptTimeFormatType;
    4444
     
    391391}
    392392
     393
    393394// FPA.RA and FPA.DEC
    394395psMetadataItem *p_pmConceptFormat_FPA_Coords(const psMetadataItem *concept,
     
    410411    // How to interpret the coordinates
    411412    bool mdok = true;                   // Status of MD lookup
    412     psMetadata *formats = psMetadataLookupMetadata(&mdok,
    413                                                    cameraFormat,
    414                                                    "FORMATS");
     413    psMetadata *formats = psMetadataLookupMetadata(&mdok, cameraFormat, "FORMATS");
     414    bool sexagesimal = false;           // Write sexagesimal format?
    415415    if (mdok && formats) {
    416         psString format = psMetadataLookupStr(&mdok,formats, concept->name);
     416        psString format = psMetadataLookupStr(&mdok, formats, concept->name);
    417417        if (mdok && strlen(format) > 0) {
    418418            if (strcasecmp(format, "HOURS") == 0) {
     
    428428            coords /= defaultCoordScaling(concept);
    429429        }
     430
     431        psString ra = psMetadataLookupStr(&mdok, formats, "FPA.RA"); // Format for RA
     432        psString dec = psMetadataLookupStr(&mdok, formats, "FPA.DEC"); // Format for Dec
     433        if (ra && strcasecmp(ra, "HOURS") == 0 && dec && strcasecmp(dec, "DEGREES") == 0) {
     434            sexagesimal = true;
     435        }
    430436    } else {
    431437        coords /= defaultCoordScaling(concept);
    432438    }
    433439
    434     // We choose to write sexagesimal format
    435     int big, medium;                    // Degrees and minutes
    436     float small;                        // Seconds
    437     bool negative = (coords < 0);       // Are we working below zero?
    438     coords = fabs(coords);
    439     big = (int)abs(coords);
    440     coords -= big;
    441     medium = 60.0 * coords;
    442     coords -= medium / 60.0;
    443     small = 3600.0 * coords;
    444     small = (float)((int)(small * 1000.0)) / 1000.0;
    445     if (negative) {
    446         big *= -1;
    447     }
    448     psString coordString = NULL;        // String with the coordinates in sexagesimal format
    449     psStringAppend(&coordString, "%d:%02d:%06.3f", big, medium, small);
    450     psMetadataItem *coordItem = psMetadataItemAllocStr(concept->name, concept->comment, coordString);
    451     psFree(coordString);
     440    psMetadataItem *coordItem = NULL;   // Item with coordinates, to return
     441    if (sexagesimal) {
     442        int big, medium;                    // Degrees and minutes
     443        float small;                        // Seconds
     444        bool negative = (coords < 0);       // Are we working below zero?
     445        coords = fabs(coords);
     446        big = (int)abs(coords);
     447        coords -= big;
     448        medium = 60.0 * coords;
     449        coords -= medium / 60.0;
     450        small = 3600.0 * coords;
     451        small = (float)((int)(small * 1000.0)) / 1000.0;
     452        if (negative) {
     453            big *= -1;
     454        }
     455        psString coordString = NULL;        // String with the coordinates in sexagesimal format
     456        psStringAppend(&coordString, "%d:%02d:%06.3f", big, medium, small);
     457        coordItem = psMetadataItemAllocStr(concept->name, concept->comment, coordString);
     458        psFree(coordString);
     459    } else {
     460        coordItem = psMetadataItemAllocF64(concept->name, concept->comment, coords);
     461    }
    452462
    453463    return coordItem;
Note: See TracChangeset for help on using the changeset viewer.