| 2067 | // allows the similar computations to be coded only once. |
| 2068 | |
| 2069 | char *SzLocation(real lon, real lat) |
| 2070 | { |
| 2071 | static char szLoc[25]; |
| 2072 | int i, j, i2, j2, i3, j3; |
| 2073 | real rT; |
| 2074 | char chDeg, chLon, chLat; |
| 2075 | flag fSav = us.fSeconds; |
| 2076 | |
| 2077 | // Check if seconds are zero so don't have to be output. |
| 2078 | if (us.fSecondHide && us.fSeconds) { |
| 2079 | rT = RAbs(lon)*60.0 + rSmall; |
| 2080 | if (RFract(rT) < rRound/3600.0/1000.0) { |
| 2081 | rT = RAbs(lat)*60.0 + rSmall; |
| 2082 | if (RFract(rT) < rRound/3600.0/1000.0) |
| 2083 | us.fSeconds = fFalse; |
| 2084 | } |
| 2085 | } |
| 2086 | is.ichLocSplit = VSeconds(7, 10, 14); |
| 2087 | |
| 2088 | // Round location to nearest unit if specified. |
| 2089 | if (us.fRound) |
| 2090 | rT = VSeconds(rRound/60.0, rRound/3600.0, rRound/3600.0/1000.0); |
| 2091 | else |
| 2092 | rT = rSmall; |
| 2093 | lon = RSgn(lon) * (RAbs(lon) + rT); |
| 2094 | lat = RSgn(lat) * (RAbs(lat) + rT); |
| 2095 | |
| 2096 | // Determine degrees, minutes, and seconds of location. |
| 2097 | i = (int)(RFract(RAbs(lon))*60.0); |
| 2098 | j = (int)(RFract(RAbs(lat))*60.0); |
| 2099 | if (us.fSeconds) { |
| 2100 | i2 = (int)(RFract(RAbs(lon))*3600.0) % 60; |
| 2101 | j2 = (int)(RFract(RAbs(lat))*3600.0) % 60; |
| 2102 | if (us.fSecond1K) { |
| 2103 | i3 = (int)(RFract(RAbs(lon))*3600.0*1000.0) % 1000; |
| 2104 | j3 = (int)(RFract(RAbs(lat))*3600.0*1000.0) % 1000; |
| 2105 | } |
| 2106 | } |
| 2107 | chLon = (lon < 0.0 ? 'E' : 'W'); |
| 2108 | chLat = (lat < 0.0 ? 'S' : 'N'); |
| 2109 | |
| 2110 | if (us.fAnsiChar == 4) { |
| 2111 | // Format like "47N36,122W19", as seen in AAF files. |
| 2112 | if (!us.fSeconds) |
| 2113 | sprintf(szLoc, "%.0f%c%02d,%.0f%c%02d", |
| 2114 | RFloor(RAbs(lat)), chLat, j, RFloor(RAbs(lon)), chLon, i); |
| 2115 | else |
| 2116 | sprintf(szLoc, "%.0f%c%02d:%02d,%.0f%c%02d:%02d", |
| 2117 | RFloor(RAbs(lat)), chLat, j, j2, RFloor(RAbs(lon)), chLon, i, i2); |
| 2118 | return szLoc; |
| 2119 | } |
| 2120 | if (us.fAnsiChar != 3) { |
| 2121 | chDeg = ChDeg(); |
| 2122 | if (us.nDegForm != df360) { |
| 2123 | if (!us.fSeconds) |
| 2124 | sprintf(szLoc, "%3.0f%c%02d%c%3.0f%c%02d%c", |
| 2125 | RFloor(RAbs(lon)), chDeg, i, chLon, |
| 2126 | RFloor(RAbs(lat)), chDeg, j, chLat); |
no test coverage detected