root/lang/perl/HTML-MobileJp/trunk/lib/HTML/MobileJp/Plugin/GPS.pm @ 4686

Revision 4686, 3.4 kB (checked in by tokuhirom, 5 years ago)

lang/perl/HTML-MobileJp?: added documents.

Line 
1package HTML::MobileJp::Plugin::GPS;
2use strict;
3use warnings;
4use URI::Escape;
5use Params::Validate;
6use HTML::Entities;
7use base qw/Exporter/;
8
9our @EXPORT = qw/gps_a gps_a_attributes/;
10
11my $codes = +{
12    E => +{
13        basic => sub {
14            # http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html
15            +{ href => 'device:location?url=' . uri_escape $_[0] };
16        },
17        gps => sub {
18            # http://www.siisise.net/gps.html#augps
19            # datum:wgs84, unit:dms
20            +{
21                href => (
22                        'device:gpsone?url='
23                      . uri_escape( $_[0] )
24                      . '&ver=1&datum=0&unit=0&acry=0&number=0'
25                )
26            };
27          }
28    },
29    I => +{
30        gps => sub {
31            # http://www.nttdocomo.co.jp/service/imode/make/content/gps/
32            +{ href => $_[0], lcs => 'lcs' };
33        },
34        basic => sub {
35            # http://www.nttdocomo.co.jp/service/imode/make/content/iarea/
36            +{
37                href => (
38                        'http://w1m.docomo.ne.jp/cp/iarea'
39                      . '?ecode=OPENAREACODE&msn=OPENAREAKEY&posinfo=1&nl='
40                      . uri_escape $_[0]
41                )
42            };
43        },
44    },
45    H => +{
46        basic => sub {
47            # http://www.willcom-inc.com/ja/service/contents_service/club_air_edge/for_phone/homepage/index.html
48            +{      href => 'http://location.request/dummy.cgi?my='
49                  . uri_escape( $_[0] )
50                  . '&pos=$location' };
51        },
52    },
53    V => +{
54        gps => sub {
55            # http://developers.softbankmobile.co.jp/dp/tool_dl/web/position.php
56            +{ href => 'location:auto?url=' . uri_escape($_[0]) };
57        },
58        basic => sub {
59            # http://developers.softbankmobile.co.jp/dp/tool_dl/web/position.php
60            +{ href => $_[0], z => 'z' };
61        }
62    },
63};
64
65sub gps_a_attributes {
66    validate(
67        @_,
68        +{
69            callback_url => qr{^https?://},
70            carrier      => qr{^[IEVH]$},
71            is_gps       => 1,
72        }
73    );
74    my %args = @_;
75
76    $codes->{$args{carrier}}->{$args{is_gps} ? 'gps' : 'basic'}->($args{callback_url});
77}
78
79sub gps_a {
80    validate(
81        @_,
82        +{
83            callback_url => qr{^https?://},
84            carrier      => qr{^[IEVH]$},
85            is_gps       => 1,
86        }
87    );
88    my %args = @_;
89
90    my $attributes = gps_a_attributes(%args);
91
92    my $ret = "";
93    for my $name (sort { $a cmp $b } keys %$attributes) {
94        $ret .= qq{ $name="} . encode_entities($attributes->{$name}) . q{"};
95    }
96    "<a$ret>";
97}
98
991;
100__END__
101
102=for stopwords mobile-jp html TODO CGI ezweb
103
104=encoding utf8
105
106=head1 NAME
107
108HTML::MobileJp::Plugin::GPS - generate GPS tags
109
110=head1 SYNOPSIS
111
112    use HTML::MobileJp;
113    gps_a(
114        carrier => 'I',
115        is_gps => 0,
116        callback_url => 'http://example.com/gps/jLKJFJDSL',
117    );
118    # => <a href="http://w1m.docomo.ne.jp/cp/iarea?ecode=OPENAREACODE&amp;msn=OPENAREAKEY&amp;posinfo=1&amp;nl=http%3A%2F%2Fexample.com%2Fgps%2FjLKJFJDSL">
119
120=head1 DESCRIPTION
121
122generate 'A' tag for send the location information.
123
124=head1 AUTHOR
125
126Tokuhiro Matsuno E<lt>tokuhirom aaaatttt gmail dotottto commmmmE<gt>
127
128=head1 SEE ALSO
129
130L<HTML::MobileJp>, L<http://www.au.kddi.com/ezfactory/tec/spec/wap_tag5.html>
131
132=head1 LICENSE
133
134This library is free software; you can redistribute it and/or modify
135it under the same terms as Perl itself.
136
137=cut
Note: See TracBrowser for help on using the browser.