mirror of
https://gitlab.com/tiggr/enex2kml.git
synced 2024-12-24 16:00:59 +01:00
added CSV export
This commit is contained in:
parent
782fa6f694
commit
a5625b89c7
30
enex2kml.pl
30
enex2kml.pl
@ -24,12 +24,15 @@ my $verbose = 0;
|
||||
my $showSkipped = 0;
|
||||
my $foldername = 'Evernote';
|
||||
my $help = 0;
|
||||
my $csv = 0;
|
||||
my @csvdata = ();
|
||||
|
||||
GetOptions( 'i|input=s' => \$inFile,
|
||||
'o|output=s' => \$outFile,
|
||||
'v|verbose' => \$verbose,
|
||||
's|showSkipped' => \$showSkipped,
|
||||
'f|folder=s' => \$foldername,
|
||||
'c|csv' => \$csv,
|
||||
'h|help' => \$help);
|
||||
|
||||
if ($help || $inFile eq '' || $outFile eq '') {
|
||||
@ -40,12 +43,17 @@ if ($help || $inFile eq '' || $outFile eq '') {
|
||||
|
||||
my $parser = XML::LibXML->new();
|
||||
my $notes = $parser->parse_file($inFile);
|
||||
my $kml;
|
||||
my $folder;
|
||||
my $root;
|
||||
my $document;
|
||||
|
||||
my $kml = XML::LibXML::Document->new('1.0', 'utf-8');
|
||||
my $root = $kml->createElement('kml');
|
||||
if ($csv == 0) {
|
||||
$kml = XML::LibXML::Document->new('1.0', 'utf-8');
|
||||
$root = $kml->createElement('kml');
|
||||
$root->setAttribute('xmlns'=> 'http://www.opengis.net/kml/2.2');
|
||||
my $document = $kml->createElement('Document');
|
||||
my $folder = $kml->createElement('Folder');
|
||||
$document = $kml->createElement('Document');
|
||||
$folder = $kml->createElement('Folder');
|
||||
my $name = $kml->createElement('name');
|
||||
$name->appendTextNode($foldername);
|
||||
$root->appendChild($document);
|
||||
@ -73,7 +81,9 @@ if ($help || $inFile eq '' || $outFile eq '') {
|
||||
|
||||
$document->appendChild($style);
|
||||
$document->appendChild($folder);
|
||||
} else {
|
||||
|
||||
}
|
||||
foreach my $note ($notes->findnodes('/en-export/note')) {
|
||||
my($title) = $note->findnodes('./title');
|
||||
my($lat) = $note->findnodes('./note-attributes/latitude');
|
||||
@ -100,6 +110,7 @@ if ($help || $inFile eq '' || $outFile eq '') {
|
||||
if ($lat && $long && $lat->to_literal != 0 && $long->to_literal != 0) {
|
||||
$exported++;
|
||||
|
||||
if ($csv == 0) {
|
||||
my $place = $kml->createElement('Placemark');
|
||||
my $name = $kml->createElement('name');
|
||||
$name->appendTextNode($title->to_literal);
|
||||
@ -115,15 +126,25 @@ if ($help || $inFile eq '' || $outFile eq '') {
|
||||
if ($done eq 'Yes') { $place->appendChild($styleurl); }
|
||||
$place->appendChild($point);
|
||||
$folder->appendChild($place);
|
||||
} else {
|
||||
my $t = '"'.$title->to_literal.'"';
|
||||
push(@csvdata, join(',', $long->to_literal, $lat->to_literal, $t));
|
||||
}
|
||||
} elsif ($showSkipped) {
|
||||
print encode_utf8("Skipped: ".$title->to_literal."\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($csv == 0) {
|
||||
open KMLOUT, ">", $outFile or die $!;
|
||||
print KMLOUT $kml->toString(1);
|
||||
close KMLOUT;
|
||||
} else {
|
||||
open CSVOUT, ">", $outFile or die $!;
|
||||
foreach (@csvdata) { print CSVOUT $_."\n"; }
|
||||
close CSVOUT;
|
||||
}
|
||||
|
||||
my $skipped = $count-$exported;
|
||||
print "\ninput:\t$inFile\n";
|
||||
@ -156,6 +177,7 @@ please visit http://creativecommons.org/licenses/by-sa/3.0/deed.de
|
||||
o|output file to write/overwrite
|
||||
v|verbose show more infos
|
||||
s|showSkipped show skipped entries
|
||||
c|csv save in csv for Navigon instead of kml
|
||||
f|folder foldername in kml/Google Earth
|
||||
h|help show this help
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user