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