kml.pl: Can remove placemarks

pull/2/head
Daniel Asher Resnick 4 years ago
parent d0e398f974
commit 966018aab2
  1. 28
      kml.pl

@ -13,6 +13,10 @@ my $xpc = XML::LibXML::XPathContext->new($dom);
$xpc->registerNs('k', "http://earth.google.com/kml/2.2");
my $mode = shift;
unless(defined($mode))
{
USAGE();
}
if ($mode eq 'add')
{
my ($name, $coordinates) = @ARGV;
@ -26,7 +30,26 @@ if ($mode eq 'add')
}
elsif ($mode eq 'remove')
{
say "Remove mode";
# say "Remove mode";
my ($name) = @ARGV;
unless (defined($name))
{
say "No place name provided to delete operation";
USAGE(1);
}
$name = to_id($name);
my ($placemark) = $xpc->findnodes("//k:Placemark[\@id=\"$name\"]");
if(defined($placemark))
{
$placemark->unbindNode();
print $dom->toString(1);
}
else
{
say "$name was not found in $filename";
exit(1);
}
# say $placemark->toString(1);
}
elsif ($mode eq 'set')
{
@ -34,6 +57,7 @@ elsif ($mode eq 'set')
}
else
{
say "Invalid operation";
USAGE(1);
}
@ -41,7 +65,7 @@ sub USAGE
{
my $code = shift;
say "USAGE: ";
exit($code);
exit($code || 0);
}
sub add_empty_child
{

Loading…
Cancel
Save