Geo::C...ansform(3pm)
π« NAME π«
Geo::Coordinates::Transform β bestie, this is your glow-up station for transforming Latitude/Longitude between various different coordinate functions. πβ¨
(also known around these parts as Geo::Coordinates::Transform from the User Contributed Perl Documentation, and the header up top calls it Geo::C...ansform(3pm) because even manpages have to abbreviate sometimes π)
β¨ SYNOPSIS β¨
okay so here's the whole vibe in one sitting, no notes:
use Geo::Coordinates::Convert;
# List of a lat/longs in various formats.
my @lst = ( 47.9805, -116.5586, '47 58.8300', '-116 33.5160', '47 58 49', '-116 33 30');
my $cnv = new Geo::Coordinates::Convert();
my $out_ref = []; # Array reference
# Convert List to Decimal-Degrees... DD.DDDD
$out_ref = $cnv->cnv_to_dd(\@lst);
# Convert List to Degree Decimal-Degrees... DD MM.MMMM
$out_ref = $cnv->cnv_to_ddm(\@lst);
# Convert List to Degrees Minutes Decimal Seconds DD MM SS.SSSS
$out_ref = $cnv->cnv_to_dms(\@lst);
like. look at her. she does everything. π
πΈ DESCRIPTION πΈ
there are, unfortunately, multiple formats used to present geographic coordinates. it's giving chaos, and we're living in it. for example:
- DMS Degrees:Minutes:Seconds (
48 30 30, -117 30' 30") - DM Degrees:Decimal-Minutes (
48 30.5, -117 30.5'), - DD Decimal-Degrees (
48.5083333, -17.5083333)
this module converts a list of provided latitude and longitude coordinates in any of the three formats above (mixed input is totally ok, she's flexible like that π ) and converts to the desired format.
β οΈ ok important β special characters or non-numerical characters such as"will throw an warning and returnNaNfor that list item. so like, watch out for that one bestie. π
in addition, the input does not interpert N,S,W,E designators but expects coordinates to be in positive or negative representation. so don't come at her with a compass rose, she wants numbers with signs. no cap. π§π«
format of the output can be controlled via input arguments in the constructor. the arguments are expected to be in the form of a hash reference. for example:
# Change output format
# Hash aruements are
# 'dd_fmt' = Decimal-Degrees format
# 'dm_fmt' = Decimal-Minutes format
# 'ds_fmt' = Decimal-Second format
# Example
my $cnv = new Geo::Coordinates::Convert( {dd_fmt=>'%3.2f', dm_fmt=>'%3.1f', ds_fmt=>'%d'} );
minimal sanity checks are performed. 75 minutes will be handled as 1 degree and 15 minutes. she's not gonna fight you about it, she'll just do the math and move on. π«Ά
π SEE ALSO π
the Geographic Coordinate System wiki ia good place for background documentation β http://en.wikipedia.org/wiki/Geographic_coordinate_system
a useful web interface using this module can be found here.
http://perlworks.com/calculate/latitude-longitude-conversion/
π¦ METHODS π¦
only three methods provided, queen of not wasting your time. expected input is a reference to a list and output is a reference to list.
$out_ref = $cnv->cnv_to_dd(\@lst); # To Degree Decimal-Degrees... DD.DDDDDDD
$out_ref = $cnv->cnv_to_ddm(\@lst); # To Degree Decimal-Minutes... DD MM.MMMM
$out_ref = $cnv->cnv_to_dms(\@lst); # To Degrees Minutes Decimal Seconds DD MM SS.SSSS
three methods, one job, absolutely ate. π₯
π AUTHOR π
<troxel at perlworks.com>
π COPYRIGHT AND LICENSE π
Copyright (C) 2010 by Troxel
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
and that's the whole thing, bestie π«Ά this ran on perl v5.40.1, dated 2025-03-08, and yeah β the footer says Geo::C...ansform(3pm) too. same girl, different font. periodt. πβ¨
π¦ where this page comes from
- debian trixie: libgeo-coordinates-transform-perl 0.10-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgeo-coordinates-transform-perl 0.10-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgeo-coordinates-transform-perl 0.10-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms