Changeset 1846
- Timestamp:
- 11/25/06 11:46:22
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/feature-geo/plagger/lib/Plagger/Plugin/Namespace/Geo.pm
r1842 r1846 15 15 my $geo_ns = "http://www.w3.org/2003/01/geo/wgs84_pos#"; 16 16 17 # XXX for now RSS only, do the same for Atom 18 my $geo = $args->{orig_entry}->{entry}->{$geo_ns} || {}; 19 $geo = $geo->{Point}->{geo} if $geo->{Point}; 20 if (defined($geo->{lat}) && defined($geo->{long})) { 21 my $loc = Plagger::Location->new; 22 $loc->latitude($geo->{lat}); 23 $loc->longitude($geo->{long}); 24 $args->{entry}->location($loc); 17 my $entry = $args->{orig_entry}->{entry}; 18 19 if (ref($entry) eq 'XML::Atom::Entry') { 20 my($lat, $long) = map $entry->get($geo_ns, $_), qw( lat long ); 21 if (defined $lat && defined $long) { 22 $args->{entry}->location($lat, $long); 23 } 24 } 25 elsif (ref($entry) eq 'HASH') { 26 my $geo = $entry->{$geo_ns} || {}; 27 $geo = $geo->{Point}->{geo} if $geo->{Point}; 28 if (defined($geo->{lat}) && defined($geo->{long})) { 29 $args->{entry}->location($geo->{lat}, $geo->{long}); 30 } 25 31 } 26 32 } … … 45 51 46 52 Jean-Yves Stervinou 53 Tatsuhiko Miyagawa 47 54 48 55 =head1 SEE ALSO branches/feature-geo/plagger/t/plugins/Namespace-Geo/base.t
r1842 r1846 4 4 5 5 test_plugin_deps; 6 plan tests => 4;6 plan 'no_plan'; 7 7 run_eval_expected; 8 8 … … 20 20 - file://$t::TestPlagger::BaseDirURI/t/samples/rss2-geo.xml 21 21 - file://$t::TestPlagger::BaseDirURI/t/samples/rss2-geo-point.xml 22 - file://$t::TestPlagger::BaseDirURI/t/samples/atom-geo.xml 22 23 - module: Namespace::Geo 23 24 - module: Aggregator::Simple … … 28 29 is $feeds[1]->entries->[0]->location->latitude, 26.58; 29 30 is $feeds[1]->entries->[0]->location->longitude, -97.83; 31 32 is $feeds[2]->entries->[0]->location->latitude, 26.58; 33 is $feeds[2]->entries->[0]->location->longitude, -97.83; 34 is $feeds[2]->entries->[1]->location->latitude, 26.58; 35 is $feeds[2]->entries->[1]->location->longitude, -97.83;
