Geo::Coordinates::Transform(3pm)

Geo::Coordinates::Transform3pm

Transform latitude/longitude between various different coordinate functions

Usage

  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);

Overview

There are several formats used to present geographic coordinates. 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 ok) and converts to the desired format. Note that special characters or non-numerical characters such as " will throw an warning and return NaN for that list item.

In addition, the input does not interpert N,S,W,E designators but expects coordinates to be in positive or negative representation.

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.

Methods

Only three methods provided. 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

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13

Author

<troxel at perlworks.com>

From libgeo-coordinates-transform-perl 0.10-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.