[Xastir-dev] Re: Unix/Linux APRS Help

Curt Mills, WE7U hacker at tc.fluke.com
Mon Aug 26 12:58:22 EDT 2002


On Mon, 26 Aug 2002, Curt Mills, WE7U wrote:

> On Sun, 25 Aug 2002, Ev Tupis (W2EV) wrote:
>
> > o Support both [GR##ID]-in-comment and >GG##ggOI-in-status formats
>
> I'm not sure yet whether we support these, but they wouldn't be all
> that hard to add if not.

Here's the code in Xastir for decoding grids.  Does anyone know if
it works properly and also fits the current idea of 4 digit and
6-digit grids that were discussed recently on other mailing lists?

More to investigate:  Does it check both the comment and the status
lines for the grid?  I suppose this one would be easy to test
directly.


    } else { // is it a grid
        // first sanity checks, need more
        ok = (int)(is_num_chr(my_data[2]));
        ok = (int)(ok && is_num_chr(my_data[3]));
        ok = (int)(ok && ((my_data[0]>='A')&&(my_data[0]<='R')));
        ok = (int)(ok && ((my_data[1]>='A')&&(my_data[1]<='R')));
        if (ok) {
            strncpy(temp_grid,my_data,8);
            // this test treats >6 digit grids as 4 digit grids; >6
            // are uncommon.
            // the spec mentioned 4 or 6, I'm not sure >6 is even
            // allowed.
            if ( (temp_grid[6] != ']') || (temp_grid[4] == 0) || (temp_grid[5] == 0)){
                p_station->pos_amb = 6; // 1deg lat x 2deg lon
                temp_grid[4] = 'L';
                temp_grid[5] = 'L';
            } else {
                p_station->pos_amb = 5; // 2.5min lat x 5min lon
                temp_grid[4] = toupper(temp_grid[4]);
                temp_grid[5] = toupper(temp_grid[5]);
            }
            // These equations came from what I read in the qgrid
            // source code and
            // various mailing list archives.
            gridlon= (20.*((float)temp_grid[0]-65.) + 2.*((float)temp_grid[2]-48.) + 5.*((float)temp_grid[4]-65.)/60.) - 180.;
            gridlat= (10.*((float)temp_grid[1]-65.) + ((float)temp_grid[3]-48.) + 5.*(temp_grid[5]-65.)/120.) - 90.;
            // could check for my callsign here, and avoid changing
            // it...
            p_station->coord_lat = (unsigned long)(32400000l + (360000.0 * (-gridlat)));
            p_station->coord_lon = (unsigned long)(64800000l + (360000.0 * gridlon));
            p_station->aprs_symbol.aprs_type = '/';
            p_station->aprs_symbol.aprs_symbol = 'G';
        }        // is it valid grid or not - "ok"
        // could cut off the grid square from the comment here, but
        // why bother?
    } // is it grid or not


Curt Mills, WE7U                         hacker.NO_*SPAM at tc.fluke.com
Senior Methods Engineer/SysAdmin
"Lotto:    A tax on people who are bad at math." -- unknown
"Windows:  Microsoft's tax on computer illiterates." -- WE7U



More information about the Xastir-dev mailing list