When using Geo::Coder:Google
, a mapping from an address to lat/lon works vice versa.
But the output is not suitable for an immediate access concerning concrete fields especially when converting lat/lon to an address.
According to my debug log:
loc by lat 48.308472 / lon 14.284578 --- \ {#012 address_components [#012 [0] {#012 long_name "Nibelungenbrücke",#012 short_name "B129",#012 types [#012 [0] "route"#012 ]#012 },#012 [1] {#012 long_name "Landstraße",#012 short_name "Landstraße",#012 types [#012 [0] "neighborhood",#012 [1] "political"#012 ]#012 },#012 [2] {#012 long_name "Innenstadt",#012 short_name "Innenstadt",#012 types [#012 [0] "sublocality",#012 [1] "political"#012 ]#012 },#012 [3] {#012 long_name "Linz",#012 short_name "Linz",#012 types [#012 [0] "locality",#012 [1] "political"#012 ]#012 },#012 [4] {#012 long_name "Linz",#012 short_name "Linz",#012 types [#012 [0] "administrative_area_level_2",#012 [1] "political"#012 ]#012 },#012 [5] {#012 long_name "Upper Austria",#012 short_name "OÖ",#012 types [#012 [0] "administrative_area_level_1",#012 [1] "political"#012 ]#012 },#012 [6] {#012 long_name "Austria",#012 short_name "AT",#012 types [#012 [0] "country",#012 [1] "political"#012 ]#012 },#012 [7] {#012 long_name 4020,#012 short_name 4020,#012 types [#012 [0] "postal_code"#012 ]#012 }#012 ],#012 formatted_address "Nibelungenbrücke, 4020 Linz, Austria",#012 geometry {#012 bounds {#012 n
Using substring subs would drive me nuts. Currently, the code:
sub map_latlon_to_loc($$){ my $lat = shift; my $lon = shift;
$location = $geocoder_google->reverse_geocode(latlng => $lat.','.$lon);
dbg("loc by lat ".$lat." / lon ".$lon." --- " . p $location);
}
Which concrete way / method / sub is suitable to access attributes within $location
?
btw p
refers to a Printer module
Have nothing seen on CPAN, which would do the trick. It should not work only for US. My implementation has to cope with any country.