[Xastir] Script to add "bookmarks" centered on STATION_LAT/LONG

Dan Brown brown at brauhaus.org
Fri Feb 25 18:12:36 EST 2005



On Fri, 25 Feb 2005, Curt, WE7U wrote:

> On Fri, 25 Feb 2005, Dan Brown wrote:
> 
> > Attached is a perl script to add a few "bookmarks" centered on the stations
> > LAT/LONG, as read from the xastir.conf file, to the "locations.sys"
> > bookmark file.  The script attempts to be nice and checks to see if xastir
> > is running, to avoid conflicts.
> >
> > I find it useful to have several of these standard zooms, centered on my
> > default location, especially with map caching.
> 
> The only attached text I saw was a footer added by the mailman
> software.  It's possible that the list stripped it from your
> message.
> 

Try number 2. 

Here it is, inline (though will be wrapped/warped, I'm sure) 

#!/usr/bin/perl

# Quick hack to add "home" map bookmarks at various zooms. 
# Needs to have STATION_CALLSIGN, STATION_LAT, and STATION_LONG
# set in the users .xastir/config/xastir.cnf file before it will work!
# 
# Written 20050225 N8YSZ. 
#

$MYCONF="$ENV{HOME}/.xastir/config/xastir.cnf";
$MYLOCATIONS="$ENV{HOME}/.xastir/config/locations.sys";

$DEBUG=0;

# This is probably excessive 
$MAXLEVEL=5096; 

# Make an effort to avoid clobbering things if xastir is runnig
open ( PS, "ps -a|" ) || die "ERROR: Cannot exec ps: $!"; 
while (<PS>){
    /xastir/ && die "ERROR: xastir may be runing. Exiting. "; 
}
close (PS) ; 


# Read users xastir.conf file
open( CONFFILE, $MYCONF ) || die "ERROR: cannot open $MYCONF: $!" ; 

while (<CONFFILE>) {
    $DEBUG && print $_;

    (/STATION_CALLSIGN:(.*)/ ) && do {
        $MYCALL=$1; 
        next; 
    };
		
    (/STATION_LAT:(.*)/) && do { 
        $MYLAT=$1; 
        next;
    };
	
    (/STATION_LONG:(.*)/) && do {
        $MYLONG=$1; 
        next ; 
    };

    ($MYCALL & $MYLAT & $MYLONG ) && break; 
}
close CONFFILE; 

if (! ($MYCALL & $MYLAT & $MYLONG )) {

    printf (STDERR "ERROR: Did not find Call, Lat and/or Long - exiting\n") ;
    exit (-1); 

} else {

    $LEVEL=1; 

    open ( LOCATIONS, ">>$MYLOCATIONS") || die "ERROR: Cannot open $MYLOCATIONS: $!"; 

# Append bookmarks    
    while ($LEVEL <= $MAXLEVEL) {
        printf ("Adding: %s zoom %4s|%s %s %d\n",$MYCALL,$LEVEL,$MYLAT,$MYLONG, $LEVEL); 
        printf (LOCATIONS "%s zoom %4s|%s %s %d\n",$MYCALL,$LEVEL,$MYLAT,$MYLONG, $LEVEL); 
        $LEVEL*=2; 
        $DEBUG && printf "$LEVEL \n" ; 
    }

    printf "Done\n" ; 
    close (LOCATIONS) ; 
}

exit (0); 




More information about the Xastir mailing list