/[maps]/lib/KML.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/KML.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations)
Fri Dec 7 15:53:41 2007 UTC (16 years, 4 months ago) by dpavlin
File size: 1014 byte(s)
exporter for KML placemarks
1 package KML;
2
3 use strict;
4 use warnings;
5
6 Template::Declare->init( roots => ['KML::Templates']);
7
8 sub output {
9 my $self = shift;
10 return Template::Declare->show('main', @_);
11 }
12
13
14 package KML::Templates;
15
16 use base 'Template::Declare';
17 use blib;
18 use Template::Declare::Tags qw/ KML /;
19
20 use Data::Dump qw/dump/;
21
22 template main => sub {
23 my $self = shift;
24 my $args = {@_};
25 warn "## args = ",dump( $args );
26 xml_decl { 'xml', version => '1.0', encoding=> "UTF-8" };
27 xml_decl { 'kml', 'xmlns' => "http://earth.google.com/kml/2.2" };
28 Document {
29 name { $args->{document} || 'KML export' }
30 Folder {
31 name { $args->{folder} || 'placemarks' };
32 if ( ref( $args->{placemarks} ) eq 'ARRAY' ) {
33 foreach my $placemark ( @{ $args->{placemarks} } ) {
34 Placemark {
35 name { $placemark->{number} }
36 description { outs_raw( $placemark->{html} ) }
37 Point {
38 foreach my $point ( $placemark->{point} ) {
39 coordinates { join(',', @$point) };
40 }
41 }
42 }
43 }
44 }
45 }
46 }
47 };
48
49
50 1;

  ViewVC Help
Powered by ViewVC 1.1.26