|
|
|
@ -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 |
|
|
|
|
{ |
|
|
|
|