| 9 | | my $location = $agent->get_location( { |
| 10 | | lat => '35.21.03.342', lon => '138.34.45.725', geo => 'wgs84' |
| 11 | | } ); |
| 12 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 13 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 14 | | { lat => '35.21.03.342', lng => '138.34.45.725' } ); |
| 15 | | |
| 16 | | # BasicLocation on GPS compliant device |
| 17 | | $location = $agent->get_location( { |
| 18 | | AREACODE => '05902', LAT => '+35.39.43.538', LON => '+139.44.06.232', GEO => 'wgs84', XACC => 1 |
| 19 | | }, { locator => $LOCATOR_BASIC } ); |
| 20 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 21 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 22 | | { lat => '35.39.43.538', lng => '139.44.06.232' } ); |
| 23 | | |
| 24 | | $location = $agent->get_location( { |
| 25 | | AREACODE => '05902' |
| 26 | | }, { locator => $LOCATOR_BASIC } ); |
| 27 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 28 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 29 | | { lat => '35.39.43.535', lng => '139.44.06.233' } ); |
| 30 | | } |
| 32 | | { |
| 33 | | local $ENV{HTTP_USER_AGENT} = 'DoCoMo/1.0/P503i/c10'; |
| 34 | | my $agent = HTTP::MobileAgent->new; |
| 35 | | my $location = $agent->get_location( { AREACODE => '05902', LAT => '+35.39.43.538', LON => '+139.44.06.232', GEO => 'wgs84', XACC => 1 } ); |
| 36 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 37 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 38 | | { lat => '35.39.43.538', lng => '139.44.06.232' } ); |
| 39 | | } |
| 40 | | |
| 41 | | { |
| 42 | | local $ENV{HTTP_USER_AGENT} = 'DoCoMo/1.0/P503i/c10'; |
| 43 | | my $agent = HTTP::MobileAgent->new; |
| 44 | | my $location = $agent->get_location( { AREACODE => '05902' } ); |
| 45 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 46 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 47 | | { lat => '35.39.43.535', lng => '139.44.06.233' } ); |
| 48 | | } |
| 49 | | |
| 50 | | { |
| 51 | | local $ENV{HTTP_USER_AGENT} = 'KDDI-CA31 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0'; |
| 52 | | local $ENV{HTTP_X_UP_DEVCAP_MULTIMEDIA} = '0200000000000000'; |
| 53 | | my $agent = HTTP::MobileAgent->new; |
| 54 | | my $location = $agent->get_location( { |
| 55 | | lat => '+35.21.03.342', lon => '+138.34.45.725', datum => '0' |
| 56 | | } ); |
| 57 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 58 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 59 | | { lat => '35.21.03.342', lng => '138.34.45.725' } ); |
| 60 | | |
| 61 | | # BasicLocation on GPS compliant device |
| 62 | | $location = $agent->get_location( { lat => '35.21.03.342', lon => '138.34.45.725' }, { locator => $LOCATOR_BASIC } ); |
| 63 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 64 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 65 | | { lat => '35.21.03.342', lng => '138.34.45.725' } ); |
| 66 | | } |
| 67 | | |
| 68 | | { |
| 69 | | local $ENV{HTTP_USER_AGENT} = 'KDDI-CA31 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0'; |
| 70 | | my $agent = HTTP::MobileAgent->new; |
| 71 | | my $location = $agent->get_location( { lat => '35.21.03.342', lon => '138.34.45.725' } ); |
| 72 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 73 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 74 | | { lat => '35.21.03.342', lng => '138.34.45.725' } ); |
| 75 | | } |
| 76 | | |
| 77 | | { |
| 78 | | local $ENV{HTTP_USER_AGENT} = 'SoftBank/1.0/911T/TJ001 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1'; |
| 79 | | my $agent = HTTP::MobileAgent->new; |
| 80 | | my $location = $agent->get_location( { pos => 'N35.21.03.342E138.34.45.725' } ); |
| 81 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 82 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 83 | | { lat => '35.21.03.342', lng => '138.34.45.725' } ); |
| 84 | | |
| 85 | | |
| 86 | | # BasicLocation on GPS compliant device |
| 87 | | local $ENV{ HTTP_X_JPHONE_GEOCODE } = '352051%1a1383456%1afoo'; |
| 88 | | $location = $agent->get_location(undef, { locator => $LOCATOR_BASIC }); |
| 89 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 90 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 91 | | { lat => '35.21.02.678', lng => '138.34.44.820' } ); |
| 92 | | } |
| 93 | | |
| 94 | | { |
| 95 | | local $ENV{HTTP_USER_AGENT} = 'J-PHONE/2.0/J-DN02'; |
| 96 | | local $ENV{ HTTP_X_JPHONE_GEOCODE } = '352051%1a1383456%1afoo'; |
| 97 | | my $agent = HTTP::MobileAgent->new; |
| 98 | | my $location = $agent->get_location(); |
| 99 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 100 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 101 | | { lat => '35.21.02.678', lng => '138.34.44.820' } ); |
| 102 | | } |
| 103 | | |
| 104 | | { |
| 105 | | local $ENV{HTTP_USER_AGENT} = 'Mozilla/3.0(DDIPOCKET;JRC/AH-J3001V,AH-J3002V/1.0/0100/c50)CNF/2.0'; |
| 106 | | my $agent = HTTP::MobileAgent->new; |
| 107 | | my $location = $agent->get_location( { pos => 'N35.20.51.664E138.34.56.905' } ); |
| 108 | | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| 109 | | is_deeply( { lat => $location->lat, lng => $location->lng }, |
| 110 | | { lat => '35.21.03.342', lng => '138.34.45.725' } ); |
| | 29 | for my $option_ref (@{$option_refs}) { |
| | 30 | my $location = $agent->get_location( $params, $option_ref ); |
| | 31 | is ref $location, 'Geo::Coordinates::Converter::Point'; |
| | 32 | is_deeply( { lat => $location->lat, lng => $location->lng } => $output ); |
| | 33 | } |
| | 37 | { # DoCoMo GPS device |
| | 38 | local $ENV{HTTP_USER_AGENT} = 'DoCoMo/2.0 SH904i(c100;TB;W24H16)'; |
| | 39 | |
| | 40 | locator_test( |
| | 41 | $for_gps_option_refs, |
| | 42 | { lat => '35.21.03.342', lon => '138.34.45.725', geo => 'wgs84' }, |
| | 43 | { lat => '35.21.03.342', lng => '138.34.45.725'} |
| | 44 | ); |
| | 45 | locator_test( |
| | 46 | $for_basic_on_gps_option_refs, |
| | 47 | { AREACODE => '05902', LAT => '+35.39.43.538', LON => '+139.44.06.232', GEO => 'wgs84', XACC => 1 }, |
| | 48 | { lat => '35.39.43.538', lng => '139.44.06.232' } |
| | 49 | ); |
| | 50 | locator_test( |
| | 51 | $for_basic_on_gps_option_refs, |
| | 52 | { AREACODE => '05902' }, |
| | 53 | { lat => '35.39.43.535', lng => '139.44.06.233' } |
| | 54 | ); |
| | 55 | |
| | 56 | } |
| | 57 | |
| | 58 | { # DoCoMo Basic device |
| | 59 | local $ENV{HTTP_USER_AGENT} = 'DoCoMo/1.0/P503i/c10'; |
| | 60 | |
| | 61 | locator_test( |
| | 62 | $for_basic_option_refs, |
| | 63 | { AREACODE => '05902', LAT => '+35.39.43.538', LON => '+139.44.06.232', GEO => 'wgs84', XACC => 1 }, |
| | 64 | { lat => '35.39.43.538', lng => '139.44.06.232' } |
| | 65 | ); |
| | 66 | locator_test( |
| | 67 | $for_basic_option_refs, |
| | 68 | { AREACODE => '05902' }, |
| | 69 | { lat => '35.39.43.535', lng => '139.44.06.233' } |
| | 70 | ); |
| | 71 | } |
| | 72 | |
| | 73 | |
| | 74 | { # au GPS device |
| | 75 | local $ENV{HTTP_USER_AGENT} = 'KDDI-CA31 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0'; |
| | 76 | local $ENV{HTTP_X_UP_DEVCAP_MULTIMEDIA} = '0200000000000000'; |
| | 77 | |
| | 78 | locator_test( |
| | 79 | $for_gps_option_refs, |
| | 80 | { lat => '+35.21.03.342', lon => '+138.34.45.725', datum => '0' }, |
| | 81 | { lat => '35.21.03.342', lng => '138.34.45.725' } |
| | 82 | ); |
| | 83 | locator_test( |
| | 84 | $for_basic_on_gps_option_refs, |
| | 85 | { lat => '35.21.03.342', lon => '138.34.45.725', datum => 'wgs84' }, |
| | 86 | { lat => '35.21.03.342', lng => '138.34.45.725' } |
| | 87 | ); |
| | 88 | } |
| | 89 | |
| | 90 | { # au Basic device |
| | 91 | local $ENV{HTTP_USER_AGENT} = 'KDDI-CA31 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0'; |
| | 92 | |
| | 93 | locator_test( |
| | 94 | $for_basic_option_refs, |
| | 95 | { lat => '35.21.03.342', lon => '138.34.45.725', datum => 'wgs84' }, |
| | 96 | { lat => '35.21.03.342', lng => '138.34.45.725' } |
| | 97 | ); |
| | 98 | } |
| | 99 | |
| | 100 | { # SoftBank GPS device |
| | 101 | local $ENV{HTTP_USER_AGENT} = 'SoftBank/1.0/911T/TJ001 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1'; |
| | 102 | |
| | 103 | locator_test( |
| | 104 | $for_gps_option_refs, |
| | 105 | { pos => 'N35.21.03.342E138.34.45.725' }, |
| | 106 | { lat => '35.21.03.342', lng => '138.34.45.725' } |
| | 107 | ); |
| | 108 | |
| | 109 | local $ENV{ HTTP_X_JPHONE_GEOCODE } = '352051%1a1383456%1afoo'; |
| | 110 | locator_test( |
| | 111 | $for_basic_on_gps_option_refs, |
| | 112 | undef, |
| | 113 | { lat => '35.21.02.678', lng => '138.34.44.820' } |
| | 114 | ); |
| | 115 | } |
| | 116 | |
| | 117 | { # SoftBank Basic device |
| | 118 | local $ENV{HTTP_USER_AGENT} = 'J-PHONE/2.0/J-DN02'; |
| | 119 | local $ENV{ HTTP_X_JPHONE_GEOCODE } = '352051%1a1383456%1afoo'; |
| | 120 | |
| | 121 | locator_test( |
| | 122 | $for_basic_option_refs, |
| | 123 | undef, |
| | 124 | { lat => '35.21.02.678', lng => '138.34.44.820' } |
| | 125 | ); |
| | 126 | } |
| | 127 | |
| | 128 | { # Willcom |
| | 129 | local $ENV{HTTP_USER_AGENT} = 'Mozilla/3.0(DDIPOCKET;JRC/AH-J3001V,AH-J3002V/1.0/0100/c50)CNF/2.0'; |
| | 130 | |
| | 131 | locator_test( |
| | 132 | $for_basic_option_refs, |
| | 133 | { pos => 'N35.20.51.664E138.34.56.905' }, |
| | 134 | { lat => '35.21.03.342', lng => '138.34.45.725' } |
| | 135 | ); |
| | 136 | } |
| | 137 | |
| | 138 | |