package dude; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(%states %states_ %abbrs @formats $docroot $date $author $hostname $site $pwd $cwd $wd $title $title_ $state $state_ $font $fontt $sample @letters makeBanner setTitle %quads %names readpl slurpList doCommand zoom_to); @EXPORT_OK = qw(); BEGIN { %states = ( "AL", "Alabama", "AK", "Alaska", "WA", "Washington", "WV", "West_Virginia", "WI", "Wisconsin", "WY", "Wyoming" ); $category{"Topographic.7.5'.1:20,000"} = 'r'; $category{"Topographic.7.5'.1:24,000"} = 'o'; $category{"Topographic -- Provisional.7.5'.1:24,000"} = 'o'; $category{"Topographic and Bathymetric.7.5'.1:24,000"} = 'o'; $category{"Topographic and Bathymetric.7.5'x15'.1:24,000"} = 'o'; $category{"Mineral Management Status.7.5'.1:24,000"} = 'm'; $category{"Orthophotomap.7.5'.1:24,000"} = 'p'; $category{"Topographic.7.5'.1:25,000"} = 'l'; $category{"Topographic.7.5'.1:30,000"} = 'j'; $category{"Topographic.7.5'x15'.1:24,000"} = 'k'; $category{"Topographic.7.5'x15'.1:25,000"} = 'k'; $category{"Topographic.Alaska.1:63,360"} = 'i'; $category{"Planimetric.30'x60'.1:100,000"} = 'g'; $category{"Topographic.30'x60'.1:100,000"} = 'f'; $category{"Topographic.1x2degree.1:250,000"} = 'c'; $series{"r"} = "Topographic 7.5' 1:20,000"; $series{"o"} = "Topographic 7.5' 1:24,000"; $series{"p"} = "Orthophotomap 7.5' 1:24,000"; $series{"l"} = "Topographic 7.5' 1:25,000"; $series{"j"} = "Topographic 7.5' 1:30,000"; $series{"k"} = "Topographic 7.5'x15' 1:25,000"; $series{"i"} = "Topographic Alaska 1:63,360"; $series{"g"} = "Planimetric 30'x60' 1:100,000"; $series{"f"} = "Topographic 30'x60' 1:100,000"; $series{"c"} = "Topographic 1x2degree 1:250,000"; ($::prog) = reverse split ("/", $0); chomp ($pwd =`pwd`); @pwdparts = split ("/", $pwd); # state and title and var cwd are set here to the tail of `pwd` $state_ = $state = $title = $title_ = $cwd = $pwdparts[$#pwdparts]; $state_ = $state = $pwdparts[$#pwdparts - 1] if ($state eq "Places"); $title =~ s/_/\ /g; $state_ =~ s/_/\ /g; # for this var the underscore paradigm is backwards # why do we need three shifts here instead of two? shift @pwdparts; shift @pwdparts; shift @pwdparts; $wd = join ("/", @pwdparts); $title = join (" ", @pwdparts); chomp ($date = `date`); chomp ($author= `id | awk '{print \$1}' |sed -e 's/^....//' |tr -dc "a-z"`); chomp ($hostname = `hostname`); $www = "http://www.topolabs.com"; $site = $server = "http://$hostname"; @letters = ('a' .. 'h'); $abbrs{$states{$_}} = $_ foreach (keys %states); $font= "-b&h-lucida sans-medium-r-normal-sans-8-0-100-72-p-140-iso8859-1"; $fontt="-b&h-lucida sans-medium-r-normal-sans-10-0-100-72-p-140-iso8859-1"; $ifont ="-b&h-lucida sans-medium-i-normal-sans-10-0-100-72-p-140-iso8859-1"; $font ="-b&h-lucida-medium-r-normal-sans-10-100-75-75-p-58-iso8859-1"; # some fonts for use on webpages $degree_font = "helvB12.bdf"; $status_font = "helvB08.bdf"; $quadname_font = "helvR10.bdf"; $placenamesURL = "http://mapping.usgs.gov/www/gnis/gnisftp.html"; $listURL = 'http://mac.usgs.gov/mac/maplists/mlp001.cgi?scale=C&initial=A&state=STATE&listtype=f'; $sample200 = "/California/37122/o37122g4.200.png"; $sample250 = "/Wyoming/44110/o44110a1.250.png"; } sub new { my $type = shift; my $self = {}; $self->{hilong} = $self->{hilat} = 0; $self->{lowlong} = $self->{lowlat} = 999; $self->{projection} = "UTM"; $self->{datum} = "NAD27"; $self->{minDPI} = 25; $self->{maxDPI} = 250; $self->{origDPI} = 250; $self->{defaultDPI} = 25; $self->{filetypes} = ["tif", "tfw"]; $self->{indexW} = 60; $self->{indexH} = 72; $self->{sorts} = ["name", "index"]; $self->{formats} = ["png"]; $self->{defaultFormat} = "png"; $self->{flavor} = "coverage"; $self->{map} = "/map"; $self->{tile} = "/tile"; $self->{category}=("o"); #$self->{scales}=("24", "100", "250", "500"); #$scale="24"; #$self->{letters24} = ('a' .. 'h'); #$self->{letters100} = ('a', 'e'); #$self->{prefix}{"24"} = "o"; #$self->{prefix}{"100"} = "f"; #$self->{prefix}{"250"} = "c"; #$self->{high}{"24"} = "7"; #$self->{high}{"100"} = "1"; return bless $self, $type; } sub setTitle { $title = shift; makeBanner($title) unless defined $::noImages; $title_ = $title; $title_ =~ s/\ /_/g; } sub deval { $command = shift; print "$command\n" if ((defined $::verbose) or (defined $::noexec)); eval $command unless (defined $::noexec); } sub doCommand { $command = shift; print "$command\n" if (defined $::verbose or defined $::debug or defined $::noexec); system($command) unless ((defined $::noexec) and ($::noexec ne "")); my $sta = $?; my $actual = $sta % 255 ; my $sig = $sta & 255 ; print "doCommand: status=$sta, actual=$actual, signal=$sig\n" if $::debug; } # slurpList replaces readpl which was developed to work on the file # cdsort.pl which was derived from cdsort.htm which was a teale thing sub slurpList { ($self, $all) = @_; open(INPUT, "<$state.list") or die "can't get $state.list"; $self->{total} = 0; print "all \n" if ((defined $all) and ("$all" eq "all")); # at the second instance of the word Scale we cease extracting 24k maps $lastletter = ""; while () { if (/Scale/) { $theScale = $_; $theScale =~ s/<.*><.*><.>//; # remove part up to scale ($scale, $theWordScale) = split (" ",$theScale); # I don't understand "1:24,000/1:25,000" so just chop it after the / $scale =~ s/\/.*$//; print "$scale...\n" unless defined $::quiet; } next unless (defined $scale); next unless (($scale =~ /24.000/) or ($scale =~ /25.000/)); next if (! /^/); # only process this line if it begins with this #next if (! /Topographic/); # next if it's not a topo tr/\'\"//d; # remove single and double quotes s/..176//g; s///g; # yank s/<.TR>//g; # yank s//"/g; # change to " s/<.TD>/",/g; # change to ", s/,$/)/g; # remove xtra, trailing comma with close paren s/^/(/g; # insert preceeding paren # we should have now transformed the line into perl my ($stockno,$name,$latitude,$longitude,$year1,$year2,$maptype) = eval $_; #print "slurpList: stopckno=$stopckno,name=$name,latitude=$latitude,longitude=$longitude,year1=$year1,year2=$year2,maptype=$maptype\n" if defined $::debug; my @letters = ('a' .. 'h'); $abbr = substr ($stockno,1,2); #next if (($abbr ne $abbrs{$state}) and ($all ne "all")); $name =~ s/\s*$//; my $lat = substr ($latitude,0,2); my $long = substr ($longitude,0,3); next if ((not defined $lat) or ($lat eq "")); next if ((not defined $long) or ($long eq "")); my @latparts = split(" ",$latitude); my @longparts = split(" ",$longitude); my $latletter = int($latparts[1] / 7); my $longnumber = int($longparts[1] / 7) + 1; # fudge factor because we should really be dividing by 7.5 above # but if we did we would have to count the minutes and seconds $latletter = 7 if ($latletter > 7); # determine the series of the quad # see http://mcmcweb.er.usgs.gov/drg/drg_name.html my $theSeries = "7.5'"; $theSeries = "7.5'x15'" if ($name =~ /7.5x15/); $theSeries = "Alaska" if ($scale =~ /63,360/); $theSeries = "30'x60'" if ($scale =~ /100,000/); $theSeries = "1x2degree" if ($scale =~ /250,000/); #$maptype =~ s/ -- Provisional// if ($maptype =~ / -- Provisional/); print "slurpList: maptype=$maptype,series=$theSeries,scale=$scale, lowlat=$self->{lowlat} , hilat=$self->{hilat} \n" if defined $::debug; #my $catg = 'o'; # map category defaults to "o" my $catg = 'u'; # map category defaults to u for unknown # set the category to the appropriate letter if one is defined if (defined $category{"$maptype.$theSeries.$scale"}) { $catg = $category{"$maptype.$theSeries.$scale"} } else { print "Error: Category unknown: $maptype.$theSeries.$scale\n"; } my $quad = $catg . substr ($latitude,0,2) . substr ($longitude,0,3) . $letters[$latletter] . $longnumber; print "slurpList: $name: latitude=$latitude, lat=$lat, longitude=$longitude, long=$long, letter=$latletter, number=$longnumber, year1=$year1, year2=$year2, maptype=$maptype, series=$theSeries scale=$scale, category=$catg, quad=$quad\n" if defined $::debug; # only do quads that begin with "o" for now #next if ($catg ne $self->{category}) and ($self->{category} ne "all"); $quads{"$name"} = $quad; $names{"$quad"} = $name; $self->{hilat} = $lat if ($lat > $self->{hilat}); $self->{hilong} = $long if ($long > $self->{hilong}); $self->{lowlat} = $lat if ($lat < $self->{lowlat}); $self->{lowlong} = $long if ($long < $self->{lowlong}); print "$name: \t\t\t$self->{lowlong},$self->{lowlat}, $self->{hilong}, $self->{hilat}\n" if defined $::debug; $self->{total}++; $self->{"names"} = \%names; $self->{"$quad.name"} = $name; $self->{"$quad.abbr"} = $abbr; $self->{"$quad.SElong"} = $longitude; $self->{"$quad.SElat"} = $latitude; $self->{"$quad.maptype"} = $maptype; $self->{"$quad.year1"} = $year1; $self->{"$quad.year2"} = $year2; $self->{"$quad.scale"} = $scale; #print qq|$abbr $quads{$name} $names{$quad}, $self->{"$quad.SElat"} $self->{"$quad.SElong"}\n|; #print "$quad\t$name\n"; #print "."; my $firstletter = substr ($names{$quad},0,1); #print "$firstletter\n" if ($firstletter ne $lastletter); $lastletter = $firstletter; } #print "\n"; #print qq|found $self->{total} quads in $state\n|; close(INPUT); } 1; __END__ =head1 NAME dude - Class to represent a dude wide index to USGS maps =head1 SYNOPSIS use dude; print $_, "\n" foreach (keys %state); =head1 DESCRIPTION This module contains support for www.dudewheresmyvm.com =head1 BUGS Speling is horibl in this part =head1 AUTHOR Douglas Landau