--- gobook.perl 2008/05/20 04:23:49 1.1 +++ gobook.perl 2017/07/15 00:04:02 3.4 @@ -1,22 +1,26 @@ #! /usr/bin/perl -w +# $Id: gobook.perl,v 3.4 2017/07/15 00:04:02 philip Exp $ use XML::Simple; use strict; use PostScript::Simple; use Text::Wrap; $Text::Wrap::columns = 30; -my $strips; +#my $strips; -my $xml = "OmLand.xml"; -if ( defined $xml ){ - $strips = XMLin($xml, KeyAttr => {strip => 'id'}); -} +#my $xml = "OmLand.xml"; +#if ( defined $xml ){ +# $strips = XMLin($xml, KeyAttr => {strip => 'id'}); +#} + +my $strips = XMLin('OmLand.gpx'); + +# create a new PostScript object; -# create a new PostScript object -my $p = new PostScript::Simple(papersize => "A5", - colour => 1, - eps => 0, - units => "mm",); +my $p = new PostScript::Simple(papersize => "A5", + colour => 1, + eps => 0, + units => "mm"); # co-ords are horizontal, vertical. from bottom left corner. 148 x 210 @@ -51,6 +55,9 @@ $p->setcolour("white"); $p->text(60,190, "Omarama"); $p->setcolour(60,28,0); $p->text(35,175, "Land-Out Guide"); +$p->setfont("Helvetica", 17); +$p->setcolour("white"); +$p->text(12,52, "5th Edition 2017"); $p->newpage; # Contents @@ -76,7 +83,7 @@ $p->text($t1,$v, "Land-Out Etiquette"); $p->text($t6,$v, "(7)"); $v -= $ls; $p->text($t1,$v, "The Land-Outs"); -$p->text($t6,$v, "220 - 602"); +$p->text($t6,$v, "138 - 602"); $v -= $ls; $p->text($t1,$v, "Landowner & Retrieve Information"); $p->text($t6,$v, "appendix 1"); @@ -91,14 +98,16 @@ $p->text($t1,$v, "Photos by Gavin Wills. $v -= $ls; $p->text($t1,$v, "Text by Phil Plane and Gavin Wills. "); $v -= $ls; -$p->text($t1,$v, "Copyright GlideOmarama.com 2007."); +$p->text($t1,$v, "Copyright GlideOmarama.com 2013."); +$v -= $ls; +$p->text($t1,$v, "First Edition published November 2007."); $v -= $ls; -$p->text($t1,$v, "First Edition published November 2007. "); +$p->text($t1,$v, "Fifth Edition published February 2017."); $p->text(70,5, "(" . $pn++ . ")"); -my $welcome = q{Produced for Omarama based glider pilots to assist safe emergency landings and satisfactory retrieves, this Guide has been nearly 4 years in the making. Special thanks to Phil Plane, Chris Streat, Chris Rudge, Malcolm Walls and posthumously to Richard Halstead who started it all. +my $welcome = q{Produced for Omarama based glider pilots to assist safe emergency landings and satisfactory retrieves, this Guide and the associated South Island Gliding Maps (SIGMap) have been nearly 4 years in the making. Special thanks to Phil Plane, Chris Streat, Chris Rudge, Malcolm Walls and posthumously to Richard Halstead who started it all. -The Guide endeavors to be accurate but local airstrips and glider land-out areas change significantly with time. These strips are not maintained for glider pilots and many are not maintained at all. Careful inspection before landing is therefore essential. Look for washouts, rabbit holes, stock, new fences, grown up trees and power lines +The Guide endeavors to be accurate but local airstrips and glider land-out areas change significantly with time. These strips are not maintained for glider pilots and many are not maintained at all. Careful inspection before landing is therefore essential. Look for washouts, rabbit holes, stock, new fences, grown up trees and power lines. Please report any discrepancies or changes back to GlideOmarama.com for future Guide updates and editions. @@ -106,7 +115,7 @@ While glider pilots have the right to la Full price subscribers to this publication are entitled to future updated editions at half price. Thank you for your support. -Gavin Wills, Glide Omarama.com +Gavin Wills, GlideOmarama.com }; $p->newpage; $p->setcolour("black"); @@ -124,13 +133,13 @@ while (my $ln = shift @para){ $p->text(70,5, "(" . $pn++ . ")"); -my $howto = q{Land-outs are listed by their three digit "Omarama GPS Map" number. The numbers are very roughly grouped by area and the locations are listed in the Omarama turn-point data base and plotted on the "Omarama GPS Map". (1:500,000 scale, and published by GlideOmarama.com.) +my $howto = q{Land-outs are listed by their three digit South Island Gliding Map (SIGMap) number. The numbers are very roughly grouped by area and the locations are listed in the Omarama turn-point data base and plotted on the SIGMap. (1:550,000 scale, and published by GlideOmarama.com.) The Guide is far from exhaustive; there are many other possible fields and airstrips for good landings. However the land-outs chosen are strategic, often located in remote areas and not always easy to find or to use. Little attempt has been made to detail land-outs in well cultivated areas such as the Cromwell or Alexandra valleys. There are plenty farmers' fields to choose from. Look for fenced, cultivated fields near farms or roads. Hay fields are often the best. -Public airfields have not been recorded in this edition. Information on these may be found in the Visual Flight Guide. +Some public airfields have been included in this edition. Further information on these may be found in the Visual Flight Guide and at http://www.aip.net.nz. Information on each land-out is defined in the Terms and Definitions pages and includes the common name, grid coordinates, altitude, length, slope, width, location indicators, comments and the most suitable alternative land-out opportunity. @@ -317,7 +326,7 @@ $p->text($t1,$v,"GPS number:"); $p->setfont("Helvetica", 12); $v -= 6; $Text::Wrap::columns = 60; -@para = split (/\n/,wrap('', '', "Unique numeric identifier used in the GPS database and on the Omarama GPS map published by Glide Omarama. Also used when reporting a landout back to Omarama base.")); +@para = split (/\n/,wrap('', '', "Unique numeric identifier used in the GPS database and on the South Island Gliding map published by Glide Omarama. Also used when reporting a landout back to Omarama base.")); while (my $ln = shift @para){ $p->text($t1,$v, $ln); $v -= 5; @@ -381,7 +390,7 @@ $p->text(70,5, "(" . $pn++ . ")"); my $etiquette = q{You have the right to make an emergency landing and to recover your glider but the landowner has the right to make any reasonable restrictions and to claim damages. -Your primary responsibilities are to advise base you are landing (or landed), to secure the glider and contact the landowner to negotiate the retrieve by trailer or by aero tow. +Your primary responsibilities are to advise base you are landing (or landed), to secure the glider and contact the landowner to negotiate the retrieve by trailer or by aero tow. Farmers are generally very helpful and cooperative providing you are polite, respect their property and their stock, ask permission to retrieve and say thank you at the end. }; @@ -437,36 +446,36 @@ $p->text(70,5, "(" . $pn++ . ")"); # Start the strip pages with pictures: -foreach my $stripnum ( sort keys %{$strips->{strip}} ){ - if ( $strips->{strip}->{$stripnum}->{gobook} eq "yes" ){ - $strips{$strips->{strip}->{$stripnum}->{name}} = $stripnum; +foreach my $stripnum ( sort keys %{$strips->{'wpt'}} ){ + if ( $strips->{'wpt'}->{$stripnum}->{'extensions'}->{gobook} eq "yes" ){ + $strips{$strips->{'wpt'}->{$stripnum}->{'desc'}} = $stripnum; # create a new page for the pic and data $p->newpage; $p->setcolour("blue"); $p->setfont("Helvetica", 20); - $p->text($t1,195, $strips->{strip}->{$stripnum}->{name}); + $p->text($t1,195, $strips->{'wpt'}->{$stripnum}->{'desc'}); $p->text($t1+115,195, $stripnum); $p->setcolour("black"); $p->setfont("Helvetica", 14); - if ( defined $strips->{strip}->{$stripnum}->{elev} ){ - $p->text($t5,195, $strips->{strip}->{$stripnum}->{elev} . 'ft'); + if ( defined $strips->{'wpt'}->{$stripnum}->{'ele'} ){ + $p->text($t5,195, printfeet($strips->{'wpt'}->{$stripnum}->{'ele'})); } - if ( defined $strips->{strip}->{$stripnum}->{length} ){ - $p->text($t6,195, $strips->{strip}->{$stripnum}->{length} . 'm'); + if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'length'} ){ + $p->text($t6,195, $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'length'} . 'm'); } $p->setfont("Helvetica", 10); - my $latlng = $strips->{strip}->{$stripnum}->{lat} . " " . - $strips->{strip}->{$stripnum}->{lng}; + my $latlng = printlat($strips->{'wpt'}->{$stripnum}->{'lat'}) . " " . + printlon($strips->{'wpt'}->{$stripnum}->{'lon'}); $p->text($t1,190, $latlng); - if ( defined $strips->{strip}->{$stripnum}->{slope} ){ - $p->text($t1 + 45,190, 'Slope: ' . $strips->{strip}->{$stripnum}->{slope}); + if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'slope'} ){ + $p->text($t1 + 45,190, 'Slope: ' . $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'slope'}); } - if ( defined $strips->{strip}->{$stripnum}->{surface} ){ - $p->text($t5 ,190, 'Sfc: ' . $strips->{strip}->{$stripnum}->{surface}); + if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{surface} ){ + $p->text($t5 ,190, 'Sfc: ' . $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'surface'}); } - if ( defined $strips->{strip}->{$stripnum}->{width} ){ - $p->text($t6 ,190, 'Width: ' . $strips->{strip}->{$stripnum}->{width}); + if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'width'} ){ + $p->text($t6 ,190, 'Width: ' . $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'width'}); } my $eps = "M" . $stripnum . ".ps"; @@ -480,17 +489,17 @@ foreach my $stripnum ( sort keys %{$stri else { $p->setcolour(255,54,0); # Glide Omarama Orange $p->setfont("Helvetica", 32); - $p->text({rotate => 45}, $t2 ,20, 'Details in next edition' ); + $p->text({rotate => 45}, $t2 ,20, 'No picture yet' ); $p->setcolour("black"); } my $v = 185; $p->setfont("Helvetica", 12); $p->text($t5,$v,"Location:"); - if ( defined $strips->{strip}->{$stripnum}->{location} ){ + if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'location'} ){ $v -= 5; $Text::Wrap::columns = 30; - my @para = split (/\n/,wrap('', '', $strips->{strip}->{$stripnum}->{location})); + my @para = split (/\n/,wrap('', '', $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'location'})); while (my $ln = shift @para){ $p->text($t5,$v, $ln); $v -= 5; @@ -500,23 +509,31 @@ foreach my $stripnum ( sort keys %{$stri $v -= 10; $p->text($t5,$v,"Comment:"); - if ( defined $strips->{strip}->{$stripnum}->{comment} ){ + if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'comment'} ){ $v -= 5; $Text::Wrap::columns = 30; - my @para = split (/\n/,wrap('', '', $strips->{strip}->{$stripnum}->{comment})); + if ( $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'comment'} =~ /Danger/ ){ + $p->setcolour("red"); + # Draw over image ... + $p->setlinewidth(4); + $p->arc( 70, 60, 20, 0, 360); + $p->line(50,40, 90,80); + } + my @para = split (/\n/,wrap('', '', $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'comment'})); while (my $ln = shift @para){ $p->text($t5,$v, $ln); $v -= 5; } $v += 5; + $p->setcolour("black"); } $v -= 10; $p->text($t5,$v,"Alternate:"); - if ( defined $strips->{strip}->{$stripnum}->{alternate} ){ + if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'alternate'} ){ $v -= 5; $Text::Wrap::columns = 30; - my @para = split (/\n/,wrap('', '', $strips->{strip}->{$stripnum}->{alternate})); + my @para = split (/\n/,wrap('', '', $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'alternate'})); while (my $ln = shift @para){ $p->text($t5,$v, $ln); $v -= 5; @@ -530,25 +547,25 @@ foreach my $stripnum ( sort keys %{$stri startpage(); $v = 185; -foreach my $stripnum ( sort keys %{$strips->{strip}} ){ - if ( $strips->{strip}->{$stripnum}->{gobook} eq "yes" ){ - $strips{$strips->{strip}->{$stripnum}->{name}} = $stripnum; +foreach my $stripnum ( sort keys %{$strips->{'wpt'}} ){ + if ( $strips->{'wpt'}->{$stripnum}->{'extensions'}->{gobook} eq "yes" ){ + $strips{$strips->{'wpt'}->{$stripnum}->{'desc'}} = $stripnum; $p->setfont("Helvetica-Bold", 12); $p->text($t1,$v, $stripnum); - $p->text($t2,$v, $strips->{strip}->{$stripnum}->{name}); + $p->text($t2,$v, $strips->{'wpt'}->{$stripnum}->{'desc'}); $p->setfont("Helvetica", 12); $v -= 8; $p->text($t1,$v,"Station:"); - if ( defined $strips->{strip}->{$stripnum}->{station} ){ - $p->text($t2,$v, $strips->{strip}->{$stripnum}->{station}); + if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'station'} ){ + $p->text($t2,$v, $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'station'}); } $v -= 6; $p->text($t1,$v,"Contact:"); - if ( defined $strips->{strip}->{$stripnum}->{contact} ){ + if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'contact'} ){ $Text::Wrap::columns = 50; - my @para = split (/\n/,wrap('', '', $strips->{strip}->{$stripnum}->{contact})); + my @para = split (/\n/,wrap('', '', $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'contact'})); while (my $ln = shift @para){ $p->text($t2,$v, $ln); $v -= 6; @@ -557,8 +574,8 @@ foreach my $stripnum ( sort keys %{$stri } $v -= 6; $p->text($t1,$v,"Retrieve:"); - if ( defined $strips->{strip}->{$stripnum}->{retrieve} ){ - $p->text($t2,$v, $strips->{strip}->{$stripnum}->{retrieve}); + if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'retrieve'} ){ + $p->text($t2,$v, $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'retrieve'}); } $v -= 8; @@ -575,7 +592,7 @@ my $h = 15; newindex(); foreach my $stripname ( sort keys %strips ){ $p->text($h,$v, $stripname); - $p->text($h + 40,$v, $strips{$stripname}); + $p->text($h + 45,$v, $strips{$stripname}); $v -= 5; if ( $v < 10 ){ $h += 70; @@ -590,6 +607,9 @@ foreach my $stripname ( sort keys %strip # write the output to a file $p->output("gobook.ps"); +# use ghostscript to convert to pdf ... +`gs -q -dNOPAUSE -dSAFER -dBATCH -sDEVICE=pdfwrite -sOutputFile=gobook.pdf gobook.ps`; + exit 0; sub startpage { @@ -607,3 +627,42 @@ sub newindex { $p->setfont("Helvetica", 12); } +sub printlat { + my $latitude = shift(@_); + my $minutes = 0; + my $degrees = 0; + my $northing = ""; + + if ($latitude < 0) { + $northing = "S"; + $latitude = 0 - $latitude; + } + else{ + $northing = "N"; + } + $degrees = int($latitude); + $minutes = ($latitude - $degrees) * 60; + return sprintf("%d:%06.3f%s",$degrees,$minutes,$northing); +} + +sub printlon { + my $longitude = shift(@_); + my $minutes = 0; + my $degrees = 0; + my $westing = ""; + if ($longitude < 0) { + $westing = "W"; + $longitude = 0 - $longitude; + } + else{ + $westing = "E"; + } + $degrees = int($longitude); + $minutes = ($longitude - $degrees) * 60; + return sprintf("%d:%06.3f%s",$degrees,$minutes,$westing); +} + +sub printfeet { + my $meters = shift(@_); + return sprintf("%d ft", int($meters * 3.2808399)); +}