From 53ed9141de1567ddc83f85dc4ca3096d1094d7af Mon Sep 17 00:00:00 2001 From: Daniel Asher Resnick Date: Wed, 25 Nov 2020 21:07:40 -0600 Subject: [PATCH] kml.pl: Implement set operation --- kml.pl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/kml.pl b/kml.pl index 6454831..32c8180 100755 --- a/kml.pl +++ b/kml.pl @@ -61,7 +61,27 @@ elsif ($mode eq 'remove') elsif ($mode eq 'set') { - say "Set mode"; + my ($name, $coordinates) = @ARGV; + unless (defined($name) && defined($coordinates)) + { + say "Not enough args for set operation"; + USAGE(1); + } + $name = to_id($name); + my ($placemark) = $xpc->findnodes("//k:Placemark[\@id=\"$name\"]"); + if(defined($placemark)) + { + my ($coordinates_node) = $xpc->findnodes("./k:Point/k:coordinates", $placemark); + my ($description_node) = $xpc->findnodes("./k:description", $placemark); + $coordinates_node->firstChild()->setData($coordinates); + $description_node->firstChild()->setData($coordinates); + print $dom->toString(1); + } + else + { + say "$name was not found in $filename"; + exit(1); + } } else