mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2025-03-22 10:11:55 +00:00
[svn r6682] * Stop layout going odd when kat_status is null (e.g. 218)
* AUTOMAGIC .CVSIGNORE GENERATION * Add descriptive "Area:" field * Make it bitch if link cave entries contain too much info * Only insert the JavaScript back() if it is necessary * Bitch on large output files * Linked entrances now grab info (Entrance Name, Location Data etc.) from linked to cave. * Link Entrances. These allow info grabbing for linked entrances to be done reliably when target cave has multiple entrances * Initial cut at Autogen $area/index.html stuff. Currently disabled.
This commit is contained in:
parent
0f66b99454
commit
5dd3c700e1
@ -1,11 +1,14 @@
|
||||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
use Cwd;
|
||||
use File::Find;
|
||||
use File::Path;
|
||||
use Getopt::Long;
|
||||
|
||||
# header column never has any info...
|
||||
|
||||
((my $progname = $0) =~ s/^.*(\/|\\)//ig); # basename $0
|
||||
((my $progname = $0) =~ s/^.*\///ig); # basename $0
|
||||
my $warnings; # set this if we have non fatal problems
|
||||
|
||||
# Parse options
|
||||
my $no_verbose_progress = 0;
|
||||
@ -20,14 +23,31 @@ if ($usage) {
|
||||
}
|
||||
|
||||
unless ($ARGV[0]) {
|
||||
print STDERR "Specify a CSV file name as the program's argument(e.g. CAVETAB2.CSV)\n";
|
||||
print STDERR "Specify a CSV file name as the program's argument(e.g. CAVETAB2.CSV)\n\n";
|
||||
usage();
|
||||
}
|
||||
|
||||
# One day this may be proofed against this problem, but another command line parameter (location of expoweb) is enevitable, and unappealing
|
||||
($_ = cwd()) =~ s/^.*\///ig;
|
||||
if ($_ ne "noinfo") {
|
||||
print STDERR "This program expects to be run from a CWD of noinfo!\n\n";
|
||||
usage();
|
||||
}
|
||||
|
||||
open (CSV, "< $ARGV[0]") or print STDERR "That filename could not be opened. Exiting.\n" and die $!;
|
||||
|
||||
# Start writing index file
|
||||
open INDXAL, ">..\/indxal.htm" or die $!;
|
||||
# Go down a directory
|
||||
chdir "..";
|
||||
|
||||
# Clean out old .cvsignore files, and make the new ones ignore themselves...
|
||||
find(\&wanted , '.');
|
||||
|
||||
# Start writing index file, and .cvsignore it
|
||||
open CI, "> .cvsignore" or die $!;
|
||||
print CI ".cvsignore\n";
|
||||
print CI "indxal.htm\n";
|
||||
close CI;
|
||||
open INDXAL, "> indxal.htm" or die $!;
|
||||
print INDXAL << "END";
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<!-- *** This file is auto-generated by $progname - edit cavetab2.csv instead -->
|
||||
@ -50,13 +70,10 @@ END
|
||||
<CSV>; # starting to read in csv file, eat header line
|
||||
|
||||
# Read in pos file to @pos now rather than later so we don't repeat it n times
|
||||
open INPUT2, "< all.pos" or print STDERR "Could not find all.pos in the current directory\n" and die $!;
|
||||
open INPUT2, "< noinfo/all.pos" or print STDERR "Could not find all.pos in the noinfo directory\n" and die $!;
|
||||
my @pos = <INPUT2>;
|
||||
close INPUT2;
|
||||
|
||||
# Go down a directory
|
||||
chdir "..";
|
||||
|
||||
# While loop which reads in each line of csv file
|
||||
while (<CSV>) {
|
||||
chomp;
|
||||
@ -99,7 +116,38 @@ print INDXAL << "END";
|
||||
END
|
||||
|
||||
close INDXAL;
|
||||
print "Information: Done\n";
|
||||
|
||||
#print "Information: Making area indices\n";
|
||||
#make_indices();
|
||||
|
||||
print "Information: Done";
|
||||
if ($warnings) {
|
||||
print " (with warnings)"
|
||||
}
|
||||
unless ($no_verbose_progress) {
|
||||
print ". Run with -q to see what problems occurred.";
|
||||
}
|
||||
print "\n";
|
||||
|
||||
# Function to find and remove old .cvsignore files
|
||||
sub wanted {
|
||||
/^\.cvsignore\z/s && unlink($_);
|
||||
}
|
||||
|
||||
# Function to determine if a directory has (not) been deleted in CVS
|
||||
sub notcvsdeleted {
|
||||
my $d;
|
||||
|
||||
open(ENTRIES, "$_[0]/Entries") or die $!;
|
||||
if (read(ENTRIES, $d, 3) == 2) {
|
||||
if ($d eq "D\n") {
|
||||
close(ENTRIES);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
close(ENTRIES);
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Process a line of the CSV file
|
||||
# First argument is contents of line to process
|
||||
@ -109,9 +157,9 @@ print "Information: Done\n";
|
||||
# Returns nothing
|
||||
sub do_this_line {
|
||||
# Split single line into all the fields
|
||||
my ($kat_num, $kat_status, $ents, $other_number, $mult_ents, $file, $linkfile, $name, $unofficial_name, $comment, $area, $explorers, $u_description, $equipment, $qmlist, $katstatus, $references, $u_centre_line, $u_drawn_survey, $survex_file, $length, $depth, $extent, $header, $footer, $notes, $ent_name, $tag_punkt, $other_punkt, $desc_other_punkt, $exact_punkt, $fix_type, $gpspresa, $gpspostsa, $northing, $easting, $altitude, $bearings, $map, $location, $approach, $ent_desc, $ent_photo, $marking) = &parse_csv($_[0]);
|
||||
my ($kat_num, $kat_status, $ents, $other_number, $mult_ents, $file, $linkfile, undef, $name, $unofficial_name, $comment, $area, $explorers, $u_description, $equipment, $qmlist, $katstatus, $references, $u_centre_line, $u_drawn_survey, $survex_file, $length, $depth, $extent, $header, $footer, $notes, $ent_name, $tag_punkt, $other_punkt, $desc_other_punkt, $exact_punkt, $fix_type, $gpspresa, $gpspostsa, $northing, $easting, $altitude, $bearings, $map, $location, $approach, $ent_desc, $ent_photo, $marking) = &parse_csv($_[0]);
|
||||
my $parents_name;
|
||||
|
||||
|
||||
# If we have been called to process an entrance, we may have been given the cave's Kataster number or Other number
|
||||
if ($_[1] and ! $kat_num) {
|
||||
$kat_num = $_[1];
|
||||
@ -123,6 +171,16 @@ sub do_this_line {
|
||||
$parents_name = $_[3];
|
||||
}
|
||||
|
||||
# Bitch if a link file has too much information.
|
||||
if ($linkfile && $file) {
|
||||
print STDERR "Warning: both a file ($file) and a linkfile ($linkfile) specified. This makes no sense.\n\n";
|
||||
$warnings = 1;
|
||||
}
|
||||
if ($linkfile && ($kat_status || $name || $unofficial_name || $comment || $area || $explorers || $u_description || $equipment || $qmlist || $katstatus || $references || $u_centre_line || $u_drawn_survey || $survex_file || $length || $depth || $extent || $header || $footer || $notes || $ent_name || $tag_punkt || $other_punkt || $desc_other_punkt || $exact_punkt || $fix_type || $gpspresa || $gpspostsa || $northing || $easting || $altitude || $bearings || $map || $location || $approach || $ent_desc || $ent_photo || ($marking and $marking ne "\r" and $marking ne "\r\n" and $marking ne "\n"))) {
|
||||
print STDERR "Warning: In the link cave $kat_num($ents) -> $other_number there is extraneous information provided that will not be used. Please merge it into the description of the cave to which it links. The only information allowed in a link file is Kataster Number,\nEntrances, Other Number, Multiple Entrances, and the name of the linkfile.\n\n";
|
||||
$warnings = 1;
|
||||
}
|
||||
|
||||
# Generate $linkid which will be kataster no., or other no. if no kataster no. present. Per HTML4 (and XHTML etc.) ID and NAME tokens must begin with alpha characters - hence "id" prepend
|
||||
my $linkid = "id$kat_num";
|
||||
my $other_number_no_brackets = $other_number;
|
||||
@ -179,14 +237,15 @@ sub do_this_line {
|
||||
print INDXAL "</td></tr>\n";
|
||||
}
|
||||
|
||||
# If the cave does not have a filename allocated, but does have multiple entrances, keep going through the CSV file until we are at the last entrance, before we return
|
||||
# If the cave does not have a filename allocated, but does have multiple entrances, keep going through the CSV file until we are at the last entrance, before we return. This could go wrong if we ever did a linkfile for an entire cave (not just an entrance), which possessed multiple entrances. Until we do it stays like this
|
||||
unless ($file) { # this IS necessary
|
||||
if ($mult_ents eq "yes") {
|
||||
die "Umm, this code hasn't been tested recently and may be wrong (specifically using the file snarfer without assigning the return). Comment this death out to see what happens";
|
||||
my $e_mult_ents;
|
||||
do {
|
||||
my $e = <CSV>;
|
||||
<CSV>;
|
||||
chomp;
|
||||
my (undef, undef, undef, undef, $emult_ents) = &parse_csv($e);
|
||||
my $emult_ents = (&parse_csv($_))[4];
|
||||
$e_mult_ents = $emult_ents;
|
||||
} while ($e_mult_ents ne "last entrance");
|
||||
}
|
||||
@ -198,12 +257,30 @@ sub do_this_line {
|
||||
print "Progress: $file\n";
|
||||
}
|
||||
|
||||
# Make the directory that the file is in, in case it doesn't exist yet
|
||||
my $fn = $file;
|
||||
$fn =~ s/^.*\///g;
|
||||
# Determine $file's basename and dirname
|
||||
(my $fn = $file) =~ s/^.*\///ig;
|
||||
my $path = $file;
|
||||
$path =~ s/\/$fn//g;
|
||||
|
||||
# Make the directory that the file is in, in case it doesn't exist yet, and cvsignore it. I know the method it uses is not particularly neat, but I don't care.
|
||||
mkpath($path);
|
||||
unless (-d "$path/CVS" && notcvsdeleted("$path/CVS")) {
|
||||
open CI, ">> $path\/..\/.cvsignore" or die $!;
|
||||
if (tell(CI) == 0) {
|
||||
print CI ".cvsignore\n";
|
||||
}
|
||||
($_ = $path) =~ s/^.*\///ig;
|
||||
print CI "$_\n";
|
||||
close CI;
|
||||
}
|
||||
|
||||
# Add created files to a .cvsignore
|
||||
open CI, ">> $path\/.cvsignore" or die $!;
|
||||
if (tell(CI) == 0) {
|
||||
print CI ".cvsignore\n";
|
||||
}
|
||||
print CI "$fn\n";
|
||||
close CI;
|
||||
|
||||
# Open the file and start writing to it
|
||||
open FILE, "> $file" or die $!;
|
||||
@ -239,10 +316,7 @@ END
|
||||
}
|
||||
|
||||
print FILE "<table id=\"cavepage\">\n";
|
||||
print FILE "<tr><th id=\"kat_no\">";
|
||||
if ($kat_num) {
|
||||
print FILE "$kat_num";
|
||||
}
|
||||
print FILE "<tr><th id=\"kat_no\">$kat_num"; # if no $kat_num, no problem
|
||||
if ($ents) {
|
||||
print FILE " - $ents";
|
||||
}
|
||||
@ -259,11 +333,7 @@ END
|
||||
}
|
||||
print FILE " ($unofficial_name)";
|
||||
}
|
||||
print FILE "</th>";
|
||||
if ($kat_status) {
|
||||
print FILE "<th id=\"status\">$kat_status</th>";
|
||||
}
|
||||
print FILE "</tr>\n</table>";
|
||||
print FILE "</th><th id=\"status\">$kat_status</th></tr>\n</table>"; # if no $kat_status, no problem
|
||||
|
||||
if ($length or $depth or $extent) {
|
||||
print FILE "\n\n<p>";
|
||||
@ -298,6 +368,15 @@ END
|
||||
}
|
||||
|
||||
# Cave general bit
|
||||
if ($area) {
|
||||
print FILE "\n\n<p><b>Nominal area:</b> ";
|
||||
foreach $_ (split(/ /, $area)) { # deal with caves allocated multiple areas
|
||||
if (expandarea($_, 0)) { # drop junk words in $area such as "or"
|
||||
print FILE "$_ - <a href=\"$toroot\/", (expandarea($_, 0))[1], "\/index.htm#$linkid\">", (expandarea($_, 0))[0], "</a> "; # this sucketh mightily. How can I get a horizontal tab? FIXME
|
||||
}
|
||||
}
|
||||
print FILE "</p>";
|
||||
}
|
||||
if ($location) {
|
||||
print FILE "\n\n<p><b>Location:</b> $location</p>";
|
||||
}
|
||||
@ -356,59 +435,36 @@ END
|
||||
|
||||
print FILE "\n\n<!-- LINKS -->\n<hr /><ul>\n";
|
||||
|
||||
# Count how many times the filename for FILE is in the CSV
|
||||
my $storedoffset;
|
||||
$counter = 0;
|
||||
$storedoffset = tell(CSV);
|
||||
seek(CSV, 0, 0);
|
||||
while (<CSV>) {
|
||||
chomp;
|
||||
if (grep(/,\"$file\",/, $_)) {
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
seek(CSV, $storedoffset, 0);
|
||||
|
||||
# If it is more than once, it is being linked to in some fashion, so provide a method to go back
|
||||
if ($counter > 1) {
|
||||
print FILE "<li><a href=\"javascript:history.back(1)\">Go Back (Javascript)</a></li>\n"; # ACCK! ACCK! Evil JavaScript! - this is done for linkfiles (mainly), where the reader could have got there by numerous routes, and we don't know how to return them whence they came in advance
|
||||
}
|
||||
if ($mult_ents =~ /entrance/) {
|
||||
print FILE "<li><a href=\"javascript:history.back(1)\">Go Back (Javascript)</a></li>\n"; # ACCK! ACCK! Evil JavaScript! - this HAS to be done, for things like 78a, where the reader could have got there either via 78 OR 40 (and we have NO way of knowing
|
||||
print FILE "<li><a href=\"$parents_name\">Go up to overall cave description for this entrance</a></li>\n";
|
||||
}
|
||||
# Find the area the cave is in, and add appropriate links
|
||||
if ($area =~ /(1a|1b|1c|1d)/) {
|
||||
print FILE "<li><a href=\"$toroot\/plateau\/index.htm#$linkid\">Plateau area index and description</a></li>\n";
|
||||
}
|
||||
if ($area =~ /(2a|2b)/) {
|
||||
print FILE "<li><a href=\"$toroot\/smkridge\/index.htm#$linkid\">Schwarzmooskogel ridge area index and description</a></li>\n";
|
||||
}
|
||||
if ($area =~ /3/) {
|
||||
print FILE "<li><a href=\"$toroot\/br-alm\/index.htm#$linkid\">Bräuning Alm area index and description</a></li>\n";
|
||||
}
|
||||
if ($area =~ /4/) {
|
||||
print FILE "<li><a href=\"$toroot\/kratzer\/index.htm#$linkid\">Kratzer valley index and description</a></li>\n";
|
||||
}
|
||||
if ($area =~ /5/) {
|
||||
print FILE "<li><a href=\"$toroot\/wilden\/index.htm#$linkid\">Schwarzmoos-Wildensee area index and description</a></li>\n";
|
||||
}
|
||||
if ($area =~ /^6$/) {
|
||||
print FILE "<li><a href=\"$toroot\/remote\/index.htm#$linkid\">Far plateau area index and description</a></li>\n";
|
||||
print FILE "<li><a href=\"$toroot\/1626\/index.htm\">Adjacent area 1626</a></li>\n";
|
||||
}
|
||||
if ($area =~ /7/) {
|
||||
print FILE "<li><a href=\"$toroot\/egglgrub\/index.htm#$linkid\">Egglgrube area index and description</a></li>\n";
|
||||
}
|
||||
if ($area =~ /(8a|8b|8c|8d)/) {
|
||||
print FILE "<li><a href=\"$toroot\/loser\/index.htm#$linkid\">Loser/Augst See area index and description</a></li>\n";
|
||||
}
|
||||
if ($area =~ /9/) {
|
||||
print FILE "<li><a href=\"$toroot\/gschwand\/index.htm#$linkid\">Gschwandt area index and description</a></li>\n";
|
||||
}
|
||||
if ($area =~ /10/) {
|
||||
print FILE "<li><a href=\"$toroot\/aaussee\/index.htm#$linkid\">N & NE shore of Altauseer See</a></li>\n";
|
||||
}
|
||||
if ($area =~ /11/) {
|
||||
print FILE "<li><a href=\"$toroot\/augstb\/index.htm#$linkid\">Augstbach area index and description</a></li>\n";
|
||||
}
|
||||
if ($area =~ /1626/) {
|
||||
print FILE "<li><a href=\"$toroot\/1626\/index.htm#$linkid\">1626 (Rauher - Schönberg) area index and description</a></li>\n";
|
||||
foreach $_ (split(/ /, $area)) { # deal with caves allocated multiple areas
|
||||
if (expandarea($_, 1)) { # drop junk words in $area such as "or"
|
||||
print FILE "<li><a href=\"$toroot\/", (expandarea($_, 1))[1], "\/index.htm#$linkid\">", (expandarea($_, 1))[0], " area index and description</a></li>\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Finish writing to file
|
||||
|
||||
if ($area =~ /1626/) {
|
||||
print FILE "<li><a href=\"$toroot\/indxal.htm\">Full Index to area 1623</a></li>";
|
||||
}
|
||||
else {
|
||||
print FILE "<li><a href=\"$toroot\/indxal.htm#$linkid\">Full Index</a></li>";
|
||||
}
|
||||
|
||||
print FILE << "END";
|
||||
<li><a href="$toroot/indxal.htm#$linkid">Full Index of 1623 Caves</a></li>
|
||||
<li><a href="$toroot/areas.htm">Other Areas</a></li>
|
||||
<li><a href="$toroot/index.htm">Back to Expedition Intro page</a></li>
|
||||
</ul>
|
||||
@ -418,6 +474,9 @@ END
|
||||
</html>
|
||||
END
|
||||
|
||||
if (tell(FILE) > 15000) {
|
||||
print STDERR "Warning: File $file is bigger than 15kb; consider splitting its contents up\n\n";
|
||||
}
|
||||
close FILE;
|
||||
}
|
||||
|
||||
@ -446,6 +505,46 @@ sub parse_csv {
|
||||
return(@parsedline);
|
||||
}
|
||||
|
||||
# Find the entrance information, from the entrance the link points at
|
||||
# 1st arg - the filename (as in the CSV) to which the link goes
|
||||
# 2nd arg - the entrance of the cave to which the link goes
|
||||
# Returns nothing
|
||||
sub do_link_ent {
|
||||
my $linkfile = $_[0];
|
||||
my $linkent = $_[1];
|
||||
my $linkname = $_[2];
|
||||
my $storedoffset;
|
||||
|
||||
$storedoffset = tell(CSV);
|
||||
seek(CSV, 0, 0);
|
||||
|
||||
while (<CSV>) {
|
||||
chomp;
|
||||
if (grep(/,\"$linkfile\",/, $_)) {
|
||||
if ((&parse_csv($_))[5] eq $linkfile) {
|
||||
|
||||
if ((&parse_csv($_))[4] eq "yes") {
|
||||
while ((&parse_csv($_))[2] ne $linkent) {
|
||||
$_ = <CSV>;
|
||||
chomp;
|
||||
if ((&parse_csv($_))[4] eq "last entrance" && (&parse_csv($_))[2] ne $linkent) {
|
||||
print STDERR "Warning: Link entrance for $linkname not found\n\n";
|
||||
$warnings = 1;
|
||||
seek(CSV, $storedoffset, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my (undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $lent_name, $ltag_punkt, $lother_punkt, $ldesc_other_punkt, $lexact_punkt, $lfix_type, $lgpspresa, $lgpspostsa, $lnorthing, $leasting, $laltitude) = &parse_csv($_);
|
||||
do_ent($ltag_punkt,$lother_punkt,$lexact_punkt,$lgpspostsa,$lgpspresa,$leasting,$lnorthing,$laltitude,$lent_name,$lfix_type,$ldesc_other_punkt);
|
||||
seek(CSV, $storedoffset, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Process the location data for the entrance
|
||||
# Returns nothing
|
||||
sub do_ent {
|
||||
@ -535,8 +634,10 @@ sub do_ent {
|
||||
print FILE "<b>Alt:</b> $calc_altitude ";
|
||||
print FILE "<b>N</b>$calc_northing ";
|
||||
print FILE "<b>E</b>$calc_easting ";
|
||||
} else
|
||||
{ print STDERR "Warning: Lookup point for $desc data not found: $punkt\n"; }
|
||||
} else {
|
||||
print STDERR "Warning: Lookup point for $desc data not found: $punkt\n\n";
|
||||
$warnings = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -559,9 +660,9 @@ sub multi_ents {
|
||||
# Process each entrance
|
||||
do {
|
||||
my $e = <CSV>;
|
||||
chomp;
|
||||
chomp($e);
|
||||
|
||||
my ($ekat_num, undef, $eents, $eother_number, $emult_ents, $efile, $elinkfile, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $eent_name, $etag_punkt, $eother_punkt, $edesc_other_punkt, $eexact_punkt, $efix_type, $egpspresa, $egpspostsa, $enorthing, $eeasting, $ealtitude) = &parse_csv($e);
|
||||
my ($ekat_num, undef, $eents, $eother_number, $emult_ents, $efile, $elinkfile, $elinkent, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $eent_name, $etag_punkt, $eother_punkt, $edesc_other_punkt, $eexact_punkt, $efix_type, $egpspresa, $egpspostsa, $enorthing, $eeasting, $ealtitude) = &parse_csv($e);
|
||||
|
||||
if ($eother_number) {
|
||||
$eother_number = "($eother_number)"; # wrap it in brackets, so it doesn't appear to be official
|
||||
@ -572,18 +673,22 @@ sub multi_ents {
|
||||
if ($elinkfile) { # this is a link to another cave - add link to entrance into cave file but don't generate another file for the entrance
|
||||
print FILE "<a href=\"$toroot\/$elinkfile\">$eents $eother_number</a> ";
|
||||
do_this_line($e, $kat_num, $other_number_no_brackets);
|
||||
# Process the location data for the entrance
|
||||
do_link_ent($elinkfile, $elinkent, join('', $ekat_num, $eents));
|
||||
} elsif ($efile) { # call ourselves recursively to create a file for the entrance
|
||||
print FILE "<a href=\"$toroot\/$efile\">$eents $eother_number</a> ";
|
||||
close FILE; # perl filehandles are not recursively safe (when hacking at 4 in the morning). thus do this.
|
||||
|
||||
do_this_line($e, $kat_num, $other_number_no_brackets, (($_ = $file) =~ s/^.*(\/|\\)//ig) && $_);
|
||||
do_this_line($e, $kat_num, $other_number_no_brackets, (($_ = $file) =~ s/^.*\///ig) && $_);
|
||||
open FILE, ">> $file" or die $!;
|
||||
# Process the location data for the entrance
|
||||
do_ent($etag_punkt,$eother_punkt,$eexact_punkt,$egpspostsa,$egpspresa,$eeasting,$enorthing,$ealtitude,$eent_name,$efix_type,$edesc_other_punkt);
|
||||
} else { # no entrance file needed, and no link to another cave
|
||||
print FILE "$eents $eother_number";
|
||||
# Process the location data for the entrance
|
||||
do_ent($etag_punkt,$eother_punkt,$eexact_punkt,$egpspostsa,$egpspresa,$eeasting,$enorthing,$ealtitude,$eent_name,$efix_type,$edesc_other_punkt);
|
||||
}
|
||||
|
||||
# Process the location data for the entrance
|
||||
do_ent($etag_punkt,$eother_punkt,$eexact_punkt,$egpspostsa,$egpspresa,$eeasting,$enorthing,$ealtitude,$eent_name,$efix_type,$edesc_other_punkt);
|
||||
print FILE "</li>";
|
||||
$e_mult_ents = $emult_ents;
|
||||
} while ($e_mult_ents ne "last entrance");
|
||||
@ -591,12 +696,183 @@ sub multi_ents {
|
||||
print FILE "\n</ul>";
|
||||
}
|
||||
|
||||
# Return detailed area name when handed area code
|
||||
# 1st arg - area code
|
||||
# 2nd arg - generalise subareas
|
||||
sub expandarea {
|
||||
if ($_[1] == 1 && $_[0] =~ /1[a-z]/ && $_[0] ne 1626) {
|
||||
return ("Plateau", "plateau");
|
||||
}
|
||||
if ($_[1] == 0 && $_[0] eq "1a") {
|
||||
return ("Around Top Camp and below Bräuning Wall", "plateau");
|
||||
}
|
||||
if ($_[1] == 0 && $_[0] eq "1b") {
|
||||
return (""Nearer" plateau - including holes found on "geologists' walk"", "plateau");
|
||||
}
|
||||
if ($_[1] == 0 && $_[0] eq "1c") {
|
||||
return (""Nearer" plateau northeast of the col", "plateau");
|
||||
}
|
||||
if ($_[1] == 0 && $_[0] eq "1d") {
|
||||
return (""Middle" plateau", "plateau");
|
||||
}
|
||||
if ($_[1] == 1 && $_[0] =~ /2[a-z]/ && $_[0] ne 1626) {
|
||||
return ("Schwarzmooskogel ridge", "smkridge");
|
||||
}
|
||||
if ($_[1] == 0 && $_[0] eq "2a") {
|
||||
return ("Caves known or expected to link into the Stellerweg - Eishöhle and Kaninchenhöhle systems", "smkridge");
|
||||
}
|
||||
if ($_[1] == 0 && $_[0] eq "2b") {
|
||||
return ("Caves in the area of the Stellerweg - Eishöhle and Kaninchenhöhle systems, but not linked up", "smkridge");
|
||||
}
|
||||
if ($_[0] eq 3) {
|
||||
return ("Bräuning Alm", "br-alm");
|
||||
}
|
||||
if ($_[0] eq 4) {
|
||||
return ("Kratzer valley", "kratzer");
|
||||
}
|
||||
if ($_[0] eq 5) {
|
||||
return ("Schwarzmoos-Wildensee", "wilden");
|
||||
}
|
||||
if ($_[0] eq 6) {
|
||||
return ("Far plateau", "remote");
|
||||
}
|
||||
if ($_[0] eq 7) {
|
||||
return ("Egglgrube", "egglgrub");
|
||||
}
|
||||
if ($_[1] == 1 && $_[0] =~ /8[a-z]/) {
|
||||
return ("Loser/Augst See", "loser");
|
||||
}
|
||||
if ($_[1] == 0 && $_[0] eq "8a") {
|
||||
return ("South face of Loser - reached from Loser Hütte path", "loser");
|
||||
}
|
||||
if ($_[1] == 0 && $_[0] eq "8b") {
|
||||
return ("Ammerich and Höllgraben - below Dimmelwand and the last part of toll road", "loser");
|
||||
}
|
||||
if ($_[1] == 0 && $_[0] eq "8c") {
|
||||
return ("Around Augst See", "loser");
|
||||
}
|
||||
if ($_[1] == 0 && $_[0] eq "8d") {
|
||||
return ("Loser - Hochanger ridge area", "loser");
|
||||
}
|
||||
if ($_[0] eq 9) {
|
||||
return ("Gschwandt", "gschwand");
|
||||
}
|
||||
if ($_[0] eq 10) {
|
||||
return ("N & NE shore of Altauseer See", "aaussee");
|
||||
}
|
||||
if ($_[0] eq 11) {
|
||||
return ("Augstbach", "augstb");
|
||||
}
|
||||
if ($_[0] eq 1626) {
|
||||
return ("1626 (Rauher - Schönberg)", "1626");
|
||||
}
|
||||
}
|
||||
|
||||
# Usage
|
||||
sub usage {
|
||||
print << "EOF";
|
||||
USAGE: $progname [-options] <CSV file>
|
||||
-q, --quiet Be quiet about progress
|
||||
-h, --help Show this message
|
||||
|
||||
$progname must be run from noinfo directory of expoweb hierarchy.
|
||||
EOF
|
||||
exit(0);
|
||||
}
|
||||
|
||||
# Parent function for making per area tables from CAVETAB2, which may then be included in some fashion
|
||||
# Returns nothing
|
||||
sub make_indices {
|
||||
make_table(1, "1a", "plateau", "Around Top Camp and below Bräuning Wall");
|
||||
make_table(0, "1b", "plateau", ""Nearer" plateau - including holes found on "geologists' walk"", "Note that this area probably overlaps the last one - I found 171 whilst looking for 190 (as B9)...");
|
||||
make_table(0, "1c", "plateau", ""Nearer" plateau northeast of the col");
|
||||
make_table(0, "1d", "plateau", ""Middle" plateau");
|
||||
make_table(1, "2a", "smkridge", "Caves known or expected to link into the Stellerweg - Eishöhle and Kaninchenhöhle systems");
|
||||
make_table(0, "2b", "smkridge", "Caves in the same area - but not yet linked");
|
||||
make_table(1, "3", "br-alm");
|
||||
make_table(1, "4", "kratzer");
|
||||
make_table(1, "5", "wilden");
|
||||
make_table(1, "6", "remote");
|
||||
make_table(1, "7", "egglgrub");
|
||||
make_table(1, "8a", "loser", "South face of Loser - reached from Loser Hütte path");
|
||||
make_table(0, "8b", "loser", "Ammerich and Höllgraben - below Dimmelwand and the last part of toll road");
|
||||
make_table(0, "8c", "loser", "Around Augst See");
|
||||
make_table(0, "8d", "loser", "Loser - Hochanger ridge area");
|
||||
make_table(1, "9", "gschwand");
|
||||
make_table(1, "10", "aaussee");
|
||||
make_table(1, "11", "augstb");
|
||||
make_table(1, "1626", "1626");
|
||||
}
|
||||
|
||||
# Output the blurb for the index table
|
||||
# 1st argument specifies whether to overwrite output file
|
||||
# 2nd argument specifies area id
|
||||
# 3rd argument specifies area directory
|
||||
# 4rd argument (optional) gives a title to the table
|
||||
# 5th argument (optional) specifies a comment to the table
|
||||
# Returns nothing
|
||||
sub make_table {
|
||||
my @caves;
|
||||
my $i = 0;
|
||||
|
||||
if ($_[0] == 1) {
|
||||
open TAB, "> $_[2]/index.html.table" or die $!;
|
||||
} else {
|
||||
open TAB, ">> $_[2]/index.html.table" or die $!;
|
||||
}
|
||||
|
||||
@caves = area_grep("$_[1]");
|
||||
if ($_[3]) {
|
||||
print TAB "<h3 style=\"text-align:center\">$_[3]</h3>\n";
|
||||
}
|
||||
if ($_[4]) {
|
||||
print TAB "<p style=\"text-align:center; font-size: 80%\">$_[4]</p>\n";
|
||||
}
|
||||
print TAB "<table class=\"trad centre\">\n";
|
||||
while ($caves[$i][0]) {
|
||||
print TAB "<tr><td><a id=\"$caves[$i][0]\">$caves[$i][1]</a></td><td><a href=\"..\/$caves[$i][2]\">$caves[$i][3]</a></td></tr>\n";
|
||||
$i++;
|
||||
}
|
||||
print TAB "</table>\n\n";
|
||||
close TAB;
|
||||
}
|
||||
|
||||
# Goes through CSV, looking in area column for the area id passed to it in the first argument
|
||||
# Returns array, 1 x 1st dimension per matching area, 4 x 2nd dimension for linkid, number, file link, and name
|
||||
sub area_grep {
|
||||
my $givenarea = $_[0];
|
||||
my @return;
|
||||
|
||||
seek(CSV,0,0);
|
||||
while (<CSV>) {
|
||||
chomp;
|
||||
my ($kat_num, undef, undef, $other_number, undef, $file, $linkfile, undef, $name, undef, undef, $area) = &parse_csv($_);
|
||||
if ($area eq $givenarea) {
|
||||
my $linkid = "id$kat_num";
|
||||
my $number = $kat_num;
|
||||
my $link = $file;
|
||||
if ($other_number) {
|
||||
if ($kat_num) {
|
||||
$number = "$kat_num ($other_number)";
|
||||
} else {
|
||||
$linkid = "id$other_number";
|
||||
$number = $other_number;
|
||||
}
|
||||
}
|
||||
if ($linkfile && ! $file) {
|
||||
$link = $linkfile;
|
||||
}
|
||||
|
||||
# Sanitise linkid
|
||||
$linkid =~ s/\//-/g;
|
||||
$linkid =~ s/\?/q/;
|
||||
$linkid =~ s/\(/:/;
|
||||
$linkid =~ s/\)/:/;
|
||||
$linkid =~ s/ /_/;
|
||||
$linkid = lc($linkid);
|
||||
|
||||
push(@return, [$linkid, $number, $link, $name]);
|
||||
}
|
||||
}
|
||||
return(@return);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user