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

version 3.2, 2023/12/26 01:23:11 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.xml  # Spit out a simple KML version of OmLand.xml
 open KML, "> SI.kml" or die "Couldn't write SI.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>South Island Landouts</name>    <name>South Island Landouts</name>
 };  };
   
   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 );
   
 my $strips = XMLin('OmLand.xml', KeyAttr => {strip => 'id'});  
 my $gobook = "";  my $gobook = "";
 my $alt = "";  my $alt = "";
   
 foreach my $stripnum ( sort keys %{$strips->{strip}} ){  foreach my $feature ( @{$geojson->{'features'}} ){
  my $lat;  
  my $lng;  
  my $min;  
  ($lat,$min) = split /\:/,$strips->{strip}->{$stripnum}->{lat};  
  $min = (substr($min,0,6)) / 60;  
  $lat += $min;  
  ($lng,$min) = split /\:/,$strips->{strip}->{$stripnum}->{lng};  
  $min = (substr($min,0,6)) / 60;  
  $lng += $min;  
  my $placemark = sprintf(q{  <Placemark>   my $placemark = sprintf(q{  <Placemark>
     <name>%s</name>      <name>%s</name>
     <description>%s</description>      <description>%s</description>
     <Point>      <Point>
       <altitudeMode>absolute></altitudeMode>        <altitudeMode>absolute></altitudeMode>
       <coordinates>%3.6f,-%2.6f,%4.1f</coordinates>        <coordinates>%3.6f,%2.6f,%4.1f</coordinates>
     </Point>      </Point>
   </Placemark>    </Placemark>
 },  },
   $stripnum,    $feature->{'id'},
   $strips->{strip}->{$stripnum}->{name},    $feature->{'properties'}->{'name'},
   $lng,    $feature->{'geometry'}->{'coordinates'}->[0],
   $lat,    $feature->{'geometry'}->{'coordinates'}->[1],
   $strips->{strip}->{$stripnum}->{elev} / 3.28);    $feature->{'geometry'}->{'coordinates'}->[2]);
   if ( $strips->{strip}->{$stripnum}->{gobook} eq "yes" ){  
     if ( defined $feature->{'properties'}->{'gobook'} and 
                  $feature->{'properties'}->{'gobook'} eq "yes" ){
    $gobook .= $placemark;     $gobook .= $placemark;
   }    }
   else{    else{

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


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