Geo::GoogleEarth::Document::Base - Base for Geo::GoogleEarth::Document::* packages


Geo-GoogleEarth-Document documentation Contained in the Geo-GoogleEarth-Document distribution.

Index


Code Index:

NAME

Top

Geo::GoogleEarth::Document::Base - Base for Geo::GoogleEarth::Document::* packages

SYNOPSIS

Top

  use base qw{Geo::GoogleEarth::Document::Base};

DESCRIPTION

Top

The is the base of all Geo::GoogleEarth::Document packages.

USAGE

Top

CONSTRUCTOR

Top

new

  my $document = Geo::GoogleEarth::Document->new(key1=>value1,
                                                 key2=>[value=>{opt1=>val1}],
                                                 key3=>{value=>{opt2=>val2}});

METHODS

Top

function

This is an internal method that may allow hackers to add custom fields.

  $placemark->function('HashKey' => {key1=>value1, key2=>value2});

options

Returns options hash.

name

Sets or returns the name property.

  my $name=$folder->name;
  $placemark->name("New Name");
  $document->name("New Name");

BUGS

Top

SUPPORT

Top

Try geo-perl email list.

AUTHOR

Top

    Michael R. Davis (mrdvt92)
    CPAN ID: MRDVT

COPYRIGHT

Top

SEE ALSO

Top

Geo::GoogleEarth::Document creates a GoogleEarth KML Document.


Geo-GoogleEarth-Document documentation Contained in the Geo-GoogleEarth-Document distribution.
package Geo::GoogleEarth::Document::Base;
use strict;

sub new {
  my $this = shift();
  my $class = ref($this) || $this;
  my $self = {};
  bless $self, $class;
  $self->initialize(@_);
  return $self;
}

sub initialize {
  my $self = shift();
  %$self=@_;
  foreach my $key (keys %$self) {
    if (ref($self->{$key}) eq 'ARRAY') {
      #[text => {opt->val}]
      my @array=@{$self->{$key}};
      $self->{'options'}->{$key}=$array[1] if defined($array[1]);
      $self->{$key}=$array[0];
      #use Data::Dumper qw{};
      #print Data::Dumper->Dump([@array]) ,"\n";
    } elsif (ref($self->{$key}) eq 'HASH') {
      #{text => {opt->val}}
      my @array=%{$self->{$key}};
      $self->{'options'}->{$key}=$array[1] if defined($array[1]);
      $self->{$key}=$array[0];
    } else { #scalar and objects that overload ""
      #text
    }
  }
}

sub function {
  my $self=shift();
  my $function=shift();
  if (@_) {
    $self->{$function} = shift();
    if (@_) {
      my $hash=shift();
      $self->{'options'}->{$function}=ref($hash) eq 'HASH' ? $hash : {};
    }
  }
  return $self->{$function};
}

sub options {
  my $self=shift();
  my $hash=$self->{'options'};
  if (ref($hash) eq 'HASH') {
    return wantarray ? %$hash : $hash;
  } else {
    return wantarray ? () : undef();
  }
}

sub name {
  my $self=shift();
  return $self->function('name', @_);
}

1;