kml.pl: don't add duplicate places

pull/2/head
Daniel Asher Resnick 4 years ago
parent 8ef2546678
commit d652656be6
  1. 13
      kml.pl

@ -17,6 +17,7 @@ unless(defined($mode))
{
USAGE();
}
if ($mode eq 'add')
{
my ($name, $coordinates) = @ARGV;
@ -25,12 +26,19 @@ if ($mode eq 'add')
say "Not enough args for add operation";
USAGE(1);
}
my $name_id = to_id($name);
my ($placemark) = $xpc->findnodes("//k:Placemark[\@id=\"$name_id\"]");
if(defined($placemark))
{
say "$name already exists in $filename";
exit(1);
}
append_placemark($name, $coordinates, uri_escape($name));
print $dom->toString(1);
}
elsif ($mode eq 'remove')
{
# say "Remove mode";
my ($name) = @ARGV;
unless (defined($name))
{
@ -49,12 +57,13 @@ elsif ($mode eq 'remove')
say "$name was not found in $filename";
exit(1);
}
# say $placemark->toString(1);
}
elsif ($mode eq 'set')
{
say "Set mode";
}
else
{
say "Invalid operation";

Loading…
Cancel
Save