Diff for /cup.perl between versions 1.5 and 1.6

version 1.5, 2023/12/26 01:23:11 version 1.6, 2025/05/18 05:59:20
Line 1 Line 1
 #! /usr/bin/perl -w  #! /usr/bin/perl -w
 # $Id$  # $Id$
 use XML::Simple;  use JSON;
 use strict;  use strict;
 use Data::Dumper;  
   
 my $strips = XMLin('OmLand.gpx');  my $json = JSON->new;
   
   open my $fh, '<', 'OmLand.geojson' or die "error opening OmLand.geojson $!\n";
   my $text =  do { local $/; <$fh> };
   close $fh;
   
   my $geojson = $json->decode( $text );
   
   
 open CUP, "> OmLand.cup" or die "Couldn't open OmLand.cup: $!\n";  open CUP, "> OmLand.cup" or die "Couldn't open OmLand.cup: $!\n";
   
Line 32  open CUP, "> OmLand.cup" or die "Couldn' Line 38  open CUP, "> OmLand.cup" or die "Couldn'
   
 my %strips;  my %strips;
   
 foreach my $stripnum ( sort keys %{$strips->{'wpt'}} ){  foreach my $feature ( @{$geojson->{'features'}} ){
  if ( ! defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'aip'} ) {   if ( ! defined $feature->{'properties'}->{'aip'} ) {
   print CUP cupstr($stripnum);    print CUP cupstr($feature);
  }   }
 }  }
   
 close CUP;  close CUP;
   
 exit;  exit;
   
 sub cupstr {  sub cupstr {
  my $stripnum = shift(@_);   my $feature = shift(@_);
  my $location = "";   my $location = "";
  my $rwlen = "";   my $rwlen = "";
  my $rwdir = "";   my $rwdir = "";
  my $freq = "";   my $freq = "";
  if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'location'} ) {   if ( defined $feature->{'properties'}->{'location'} ) {
   $location = $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'location'};    $location = $feature->{'properties'}->{'location'};
  }   }
  if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'rwlen'} ) {   if ( defined $feature->{'properties'}->{'rwlen'} ) {
   $rwlen = $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'rwlen'};    $rwlen = $feature->{'properties'}->{'rwlen'};
  }   }
  if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'rwdir'} ) {   if ( defined $feature->{'properties'}->{'rwdir'} ) {
   $rwdir = $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'rwdir'};    $rwdir = $feature->{'properties'}->{'rwdir'};
  }   }
  if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{'freq'} ) {   if ( defined $feature->{'properties'}->{'freq'} ) {
   $freq = qq{"$strips->{'wpt'}->{$stripnum}->{'extensions'}->{'freq'}"};    $freq = qq{"$feature->{'properties'}->{'freq'}"};
  }   }
  return sprintf( qq{"%s","L%s",NZ,%s,%s,%0.1fm,3,%s,%s,%s,"%s",,\r\n},   return sprintf( qq{"%s","L%s",NZ,%s,%s,%0.1fm,3,%s,%s,%s,"%s",,\r\n},
   $strips->{'wpt'}->{$stripnum}->{'desc'},    $feature->{'properties'}->{'name'},
   $stripnum,    $feature->{'id'},
   printlat($strips->{'wpt'}->{$stripnum}->{'lat'}),    printlat($feature->{'geometry'}->{'coordinates'}->[1]),
   printlon($strips->{'wpt'}->{$stripnum}->{'lon'}),    printlon($feature->{'geometry'}->{'coordinates'}->[0]),
   $strips->{'wpt'}->{$stripnum}->{'ele'},    $feature->{'geometry'}->{'coordinates'}->[2],
   $rwlen,    $rwlen,
   $rwdir,    $rwdir,
   $freq,    $freq,
   $location);    $location);
 }  }
   
 sub printlat {  sub printlat {
  my $latitude = shift(@_);   my $latitude = shift(@_);
  my $minutes = 0;   my $minutes = 0;

Removed from v.1.5  
changed lines
  Added in v.1.6


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>