Diff for /mk-kml.perl between versions 3.1 and 3.4

version 3.1, 2019/08/02 04:45:36 version 3.4, 2025/05/18 05:02:15
Line 1 Line 1
 #! /usr/bin/perl -w  #! /usr/bin/perl -w
 use XML::Simple;  use JSON;
 use strict;  use strict;
   
 # Spit out a simple KML version of OmLand.gpx.  # Spit out a simple KML version of OmLand.xml
 open KML, "> OmLand.kml" or die "Couldn't write OmLand.kml: $!\n";  open KML, "> OmLand.kml" or die "Couldn't write OmLand.kml: $!\n";
 print KML q{<?xml version="1.0" encoding="UTF-8"?>  print KML q{<?xml version="1.0" encoding="UTF-8"?>
 <kml xmlns="http://www.opengis.net/kml/2.2">  <kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>   <Document>
   <name>NZ Landouts</name>    <name>South Island Landouts</name>
 };  };
   
   my $json = JSON->new;
   
 my $strips = XMLin('OmLand.gpx');  open my $fh, '<', OmLand.geojson or die "error opening OmLand.geojson $!\n";
   my $text =  do { local $/; <$fh> };
   close $fh;
   
   my $geojson = $json->decode( $text );
   
 my $gobook = "";  my $gobook = "";
 my $alt = "";  my $alt = "";
   
 foreach my $stripnum ( sort keys %{$strips->{'wpt'}} ){  foreach my $feature ( @{$geojson->{'features'}} ){
   my $placemark = sprintf(q{  <Placemark>   my $placemark = sprintf(q{  <Placemark>
     <name>%s</name>      <name>%s</name>
     <description>%s</description>      <description>%s</description>
     <Point>      <Point>
Line 26  foreach my $stripnum ( sort keys %{$stri Line 31  foreach my $stripnum ( sort keys %{$stri
     </Point>      </Point>
   </Placemark>    </Placemark>
 },  },
   $stripnum,    $feature->{'id'},
   $strips->{'wpt'}->{$stripnum}->{'desc'},    $feature->{'properties'}->{'name'},
   $strips->{'wpt'}->{$stripnum}->{'lon'},    $feature->{'geometry'}->{'coordinates'}->[0],
   $strips->{'wpt'}->{$stripnum}->{'lat'},    $feature->{'geometry'}->{'coordinates'}->[1],
   $strips->{'wpt'}->{$stripnum}->{'ele'});    $feature->{'geometry'}->{'coordinates'}->[2]);
   if ( defined $strips->{'wpt'}->{$stripnum}->{'extensions'}->{gobook}  and $strips->{'wpt'}->{$stripnum}->{'extensions'}->{gobook} eq "yes" ){  
     if ( defined $feature->{'properties'}->{'gobook'} and 
                  $feature->{'properties'}->{'gobook'} eq "yes" ){
    $gobook .= $placemark;     $gobook .= $placemark;
   }    }
   else{    else{
Line 39  foreach my $stripnum ( sort keys %{$stri Line 46  foreach my $stripnum ( sort keys %{$stri
   }    }
 }  }
 print KML q{  <Folder>  print KML q{  <Folder>
    <name>Glide Omarama Landouts</name>     <name>Omarama Landouts</name>
    <description>Glide Omarama recommended soaring area landouts</description>     <description>Omarama recommended soaring area landouts</description>
 };  };
 print KML $gobook;  print KML $gobook;
 print KML q{  </Folder>  print KML q{  </Folder>

Removed from v.3.1  
changed lines
  Added in v.3.4


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