[Xastir] New capability: 2008 Tiger Shapefile street maps
Lee Bengston
lee.bengston at gmail.com
Sun Apr 19 03:27:01 EDT 2009
On 4/18/09, Curt, WE7U <archer at eskimo.com> wrote:
> On Fri, 17 Apr 2009, Curt, WE7U wrote:
>
> Use the "vi" editor to change the map layers:
>
> vi ~/.xastir/config/map_index.sys
> :g/tabblock/s/01000/00995/
> :g/pointlm/s/01000/00996/
> :g/arealm/s/01000/00997/
> :wq
>
> (Who's a "sed" user? Give us some commands to do the same thing in
> sed please! Commands should be similar but can then be scripted.)
>
> Start up Xastir and select the maps. I've been selecting only these
> types of maps:
>
> arealm.shp
> areawater.shp
> edges.shp
> tabblock.shp
> As I mentioned: Perhaps we can automated the process of
> downloading/installing these maps and setting the map levels for
> them.
>
I never did warm up to vi. I put the following in a perl script
inside the ~/.xastir/config directory:
#!/usr/bin/perl
# backup the map index file
`cp ~/.xastir/config/map_index.sys ~/.xastir/config/map_index.sav`;
# Define variables
my ($indexfile, $checkline, $layer1, $layer2, $layer3);
$indexfile = "map_index.sys";
$layer1 = "00997";
$layer2 = "00996";
$layer3 = "00995";
# Enable PERL simple debug
use strict;
use warnings;
#open the config file
open(INDX, $indexfile) || die("Cannot Open File");
#open a temp output file
open(TMP, ">temp.sys");
# read lines in, fine/replace text, and write to the temp file
while(<INDX>)
{
$checkline = $_;
if (rindex($checkline, "arealm") > 0)
{
substr($checkline,44,5,$layer1);
}
elsif (rindex($checkline, "pointlm") > 0)
{
substr($checkline,44,5,$layer2);
}
elsif (rindex($checkline, "tabblock") > 0)
{
substr ($checkline,44,5,$layer3);
}
print TMP $checkline;
}
close(INDX);
close(TMP);
# copy the temporary file to the map index - thus overwriting it with
the updated version
`cp ~/.xastir/config/temp.sys ~/.xastir/config/map_index.sys`;
# Delete the temp file
unlink "temp.sys";
Regards,
Lee - K5DAT
Murphy, TX
More information about the Xastir
mailing list