IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11372


Ignore:
Timestamp:
Jan 29, 2007, 11:12:55 AM (19 years ago)
Author:
Paul Price
Message:

Fixing writing of sexagesimal notation.

File:
1 edited

Legend:

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

    r11358 r11372  
    237237
    238238    // We choose to write sexagesimal format
    239     int big, medium;
    240     float small;
    241     big = (int)coords;
    242     medium = (int)(60.0*(coords - (double)big));
    243     small = 3600.0*(coords - (double)big - 60.0 * (double)medium);
     239    int big, medium;                    // Degrees and minutes
     240    float small;                        // Seconds
     241    bool negative = (coords < 0);       // Are we working below zero?
     242    coords = fabs(coords);
     243    big = (int)abs(coords);
     244    coords -= big;
     245    medium = 60.0 * coords;
     246    coords -= medium / 60.0;
     247    small = 3600.0 * coords;
     248    if (negative) {
     249        big *= -1;
     250    }
    244251    psString coordString = NULL;        // String with the coordinates in sexagesimal format
    245     psStringAppend(&coordString, "%d:%d:%.2f", big, medium, small);
     252    psStringAppend(&coordString, "%d:%02d:%05.2f", big, medium, small);
    246253    psMetadataItem *coordItem = psMetadataItemAllocStr(concept->name, concept->comment, coordString);
    247254    psFree(coordString);
Note: See TracChangeset for help on using the changeset viewer.