Geo-Functions-0.08/0000755000175000017500000000000014332064273013455 5ustar mdavismdavisGeo-Functions-0.08/lib/0000755000175000017500000000000014332064273014223 5ustar mdavismdavisGeo-Functions-0.08/lib/Geo/0000755000175000017500000000000014332064273014735 5ustar mdavismdavisGeo-Functions-0.08/lib/Geo/Functions.pm0000644000175000017500000000767214332063074017255 0ustar mdavismdavispackage Geo::Functions; use strict; use warnings; use vars qw(@ISA @EXPORT_OK); require Exporter; use Geo::Constants qw{RAD DEG KNOTS}; @ISA = qw(Exporter); @EXPORT_OK = (qw{deg_rad rad_deg deg_dms rad_dms dms_deg dm_deg round mps_knots knots_mps}); our $VERSION = '0.08'; =head1 NAME Geo::Functions - Package for standard Geo:: functions. =head1 SYNOPSIS use Geo::Functions qw{deg_rad deg_dms rad_deg}; #import into namespace print "Degrees: ", deg_rad(3.14/4), "\n"; use Geo::Functions; my $obj = Geo::Functions->new; print "Degrees: ", $obj->deg_rad(3.14/2), "\n"; =head1 DESCRIPTION Package for standard Geo:: functions. =head1 CONVENTIONS Function naming convention is "format of the return" underscore "format of the parameters." For example, you can read the deg_rad function as "degrees given radians" or "degrees from radians". =head1 CONSTRUCTOR =head2 new The new() constructor my $obj = Geo::Functions->new(); =cut sub new { my $this = shift(); my $class = ref($this) || $this; my $self = {}; bless $self, $class; $self->initialize(@_); return $self; } =head1 METHODS =head2 initialize =cut sub initialize { my $self = shift(); %$self = @_; } =head2 deg_dms Degrees given degrees minutes seconds. my $deg = deg_dms(39, 29, 17.134); my $deg = deg_dms(39, 29, 17.134, 'N'); =cut sub deg_dms { my $self = shift(); my $d = ref($self) ? shift()||0 : $self; my $m = shift()||0; my $s = shift()||0; my $nsew = shift()||'N'; my $sign = ($nsew=~m/[SW-]/i) ? -1 : 1; #matches "-" to support -1 return $sign * ($d + ($m + $s/60)/60); } =head2 deg_rad Degrees given radians. my $deg = deg_rad(3.14); =cut sub deg_rad { my $self = shift(); my $rad = ref($self) ? shift() : $self; return $rad*DEG(); } =head2 rad_deg Radians given degrees. my $rad = rad_deg(90); =cut sub rad_deg { my $self = shift(); my $deg = ref($self) ? shift() : $self; return $deg*RAD(); } =head2 rad_dms Radians given degrees minutes seconds. my $rad = rad_dms(45 30 20.0); =cut sub rad_dms { return rad_deg(deg_dms(@_)); } =head2 round Round to the nearest integer. This formula rounds toward +/- infinity. my $int = round(42.2); =cut sub round { my $self = shift(); my $number = ref($self) ? shift() : $self; return int($number + 0.5 * ($number <=> 0)); } =head2 dms_deg Degrees minutes seconds given degrees. my ($d, $m, $s, $sign) = dms_deg($degrees, qw{N S}); my ($d, $m, $s, $sign) = dms_deg($degrees, qw{E W}); =cut sub dms_deg { my $self = shift(); my $number = ref($self) ? shift() : $self; my @sign = @_; my $sign = $number >= 0 ? $sign[0]||1 : $sign[1]||-1; $number = abs($number); my $d = int($number); my $m = int(($number-$d) * 60); my $s = ((($number-$d) * 60) - $m) * 60; my @dms = ($d, $m, $s, $sign); return wantarray ? @dms : join(' ', @dms); } =head2 dm_deg Degrees minutes given degrees. my ($d, $m, $sign) = dm_deg($degrees, qw{N S}); my ($d, $m, $sign) = dm_deg($degrees, qw{E W}); =cut sub dm_deg { my $self = shift(); my $number = ref($self) ? shift() : $self; my @sign = @_; my $sign = $number >= 0 ? $sign[0]||1 : $sign[1]||-1; $number = abs($number); my $d = int($number); my $m = ($number-$d) * 60; my @dm = ($d, $m, $sign); return wantarray ? @dm : join(' ', @dm); } =head2 mps_knots meters per second given knots my $mps = mps_knots(50.0); =cut sub mps_knots { my $self = shift(); my $number = ref($self) ? shift() : $self; return $number * KNOTS(); } =head2 knots_mps knots given meters per second my $knots = knots_mps(25.0); =cut sub knots_mps { my $self = shift(); my $number = ref($self) ? shift() : $self; return $number / KNOTS(); } =head1 BUGS Please log on GitHub =head1 AUTHOR Michael R. Davis =head1 LICENSE MIT License Copyright (c) 2022 Michael R. Davis =head1 SEE ALSO L, L =cut 1; Geo-Functions-0.08/t/0000755000175000017500000000000014332064273013720 5ustar mdavismdavisGeo-Functions-0.08/t/001_load.t0000644000175000017500000000546514051753700015414 0ustar mdavismdavis#!/usr/bin/perl -w # -*- perl -*- # # $Id: base.t,v 0.1 2006/02/21 eserte Exp $ # Author: Michael R. Davis # =head1 NAME base.t - Good examples concerning how to use this module =cut use strict; use lib q{lib}; use lib q{../lib}; use constant NEAR_DEFAULT => 7; sub near { my $x=shift(); my $y=shift(); my $p=shift()||NEAR_DEFAULT; if (($x-$y)/$y < 10**-$p) { return 1; } else { return 0; } } BEGIN { if (!eval q{ use Test; 1; }) { print "1..0 # tests only works with installed Test module\n"; exit; } } BEGIN { plan tests => 2239 } # just check that all modules can be compiled ok(eval {require Geo::Functions; 1}, 1, $@); my $o = Geo::Functions->new(); ok(ref $o, "Geo::Functions"); ok ($o->deg_rad(atan2(1,1)), 45); ok ($o->deg_dms(40,42,46.5,"N"), 40+(42+46.5/60)/60); ok ($o->rad_dms(40,42,46.5,"N"), $o->rad_deg(40+(42+46.5/60)/60)); ok ($o->rad_deg(45), atan2(1,1)); ok ($o->round(45.9), 46); foreach (qw{5 10 25 50}) { ok($_, $o->mps_knots($o->knots_mps($_))); } use Geo::Functions qw{deg_rad deg_dms rad_deg round rad_dms dms_deg dm_deg mps_knots knots_mps}; ok (deg_rad(atan2(1,1)), 45); ok (deg_dms(40,42,46.5,"s"), -1*(40+(42+46.5/60)/60)); ok (deg_dms(40,42,46.5,"S"), -1*(40+(42+46.5/60)/60)); ok (deg_dms(40,42,46.5,"w"), -1*(40+(42+46.5/60)/60)); ok (deg_dms(40,42,46.5,"W"), -1*(40+(42+46.5/60)/60)); ok (deg_dms(40,42,46.5,-1), -1*(40+(42+46.5/60)/60)); ok (deg_dms(40,42,46.5,-40), -1*(40+(42+46.5/60)/60)); ok (deg_dms(40,42,46.5,"N"), 1*(40+(42+46.5/60)/60)); ok (deg_dms(40,42,46.5,"n"), 1*(40+(42+46.5/60)/60)); ok (deg_dms(40,42,46.5,""), 1*(40+(42+46.5/60)/60)); ok (deg_dms(40,42,46.5,undef), 1*(40+(42+46.5/60)/60)); ok (deg_dms(40,42,46.5), 1*(40+(42+46.5/60)/60)); ok (rad_deg(45), atan2(1,1)); ok (rad_deg(90), atan2(1,0)); ok (rad_deg(180), atan2(0,-1)); ok (rad_deg(-90), atan2(-1,0)); ok (round(0), 0); ok (round(5.1), 5); ok (round(5.5), 6); ok (round(5.6), 6); ok (round(-5.1), -5); ok (round(-5.5), -6); ok (round(-5.6), -6); ok (rad_dms(55, 34, 76, "N"), rad_deg(deg_dms(55, 34, 76, "N"))); foreach my $d1 (0,5,15,67,88) { foreach my $m1 (0,3,43,57) { foreach my $s1 (5,15,34,45,56) { foreach my $sign1 (qw{N S}) { my ($d2,$m2,$s2,$sign2)=dms_deg(deg_dms($d1,$m1,$s1,$sign1), qw{N S}); my ($d3,$m3,$sign3)=dm_deg(deg_dms($d1,$m1,$s1,$sign1), qw{N S}); ok ($d1, $d2); ok ($m1, $m2); ok (near $s1, $s2); ok ($sign1, $sign2); ok ($d1, $d3); ok (near $m1+$s1/60, $m3); ok ($sign1, $sign3); } foreach my $sign1 (qw{E W}) { my ($d2,$m2,$s2,$sign2)=dms_deg(deg_dms($d1,$m1,$s1,$sign1), qw{E W}); ok ($d1, $d2); ok ($m1, $m2); ok (near $s1, $s2); ok ($sign1, $sign2); } } } } foreach (qw{5 10 25 50}) { ok($_, mps_knots(knots_mps($_))); } Geo-Functions-0.08/Changes0000644000175000017500000000074614332062376014761 0ustar mdavismdavis0.08 2022-11-06 - Moved to GitHub - Changed license from Perl to MIT 0.07 2007-10-07 - Absolutely nothing. It's a perl testing thing. 0.06 2007-01-15 - Added mps_knots and knots_mps functions 0.05 2007-01-12 - Added methods dms_deg and dm_deg 0.04 2006-12-09 - Documentation 0.03 2006-12-08 - Added () for imported Geo::Constants as some systems don't like barewords - Added rad_dms method 0.02 2006-12-05 - Documentation 0.01 2006-12-02 - Original version Geo-Functions-0.08/MANIFEST0000644000175000017500000000032614332064273014607 0ustar mdavismdavisChanges lib/Geo/Functions.pm LICENSE CONTRIBUTING.md Makefile.PL MANIFEST META.yml README.md t/001_load.t perl-Geo-Functions.spec META.json Module JSON meta-data (added by MakeMaker) Geo-Functions-0.08/README.md0000644000175000017500000000347114332062446014741 0ustar mdavismdavis# NAME Geo::Functions - Package for standard Geo:: functions. # SYNOPSIS use Geo::Functions qw{deg_rad deg_dms rad_deg}; #import into namespace print "Degrees: ", deg_rad(3.14/4), "\n"; use Geo::Functions; my $obj = Geo::Functions->new; print "Degrees: ", $obj->deg_rad(3.14/2), "\n"; # DESCRIPTION # CONVENTIONS Function naming convention is "format of the return" underscore "format of the parameters." For example, you can read the deg\_rad function as "degrees given radians" or "degrees from radians". # CONSTRUCTOR ## new The new() constructor my $obj = Geo::Functions->new(); # METHODS ## initialize ## deg\_dms Degrees given degrees minutes seconds. my $deg = deg_dms(39, 29, 17.134); my $deg = deg_dms(39, 29, 17.134, 'N'); ## deg\_rad Degrees given radians. my $deg = deg_rad(3.14); ## rad\_deg Radians given degrees. my $rad = rad_deg(90); ## rad\_dms Radians given degrees minutes seconds. my $rad = rad_dms(45 30 20.0); ## round Round to the nearest integer. This formula rounds toward +/- infinity. my $int = round(42.2); ## dms\_deg Degrees minutes seconds given degrees. my ($d, $m, $s, $sign) = dms_deg($degrees, qw{N S}); my ($d, $m, $s, $sign) = dms_deg($degrees, qw{E W}); ## dm\_deg Degrees minutes given degrees. my ($d, $m, $sign) = dm_deg($degrees, qw{N S}); my ($d, $m, $sign) = dm_deg($degrees, qw{E W}); ## mps\_knots meters per second given knots my $mps = mps_knots(50.0); ## knots\_mps knots given meters per second my $knots = knots_mps(25.0); # BUGS Please log on GitHub # LIMITS # AUTHOR Michael R. Davis # LICENSE MIT License Copyright (c) 2022 Michael R. Davis # SEE ALSO [Geo::Constants](https://metacpan.org/pod/Geo::Constants), [Geo::Ellipsoids](https://metacpan.org/pod/Geo::Ellipsoids) Geo-Functions-0.08/CONTRIBUTING.md0000644000175000017500000000024414332061266015705 0ustar mdavismdavis# Contributing Guidelines Fork repository on GitHub and submit a pull request. Submitting a pull request indicates your acceptance of the license of the project. Geo-Functions-0.08/perl-Geo-Functions.spec0000644000175000017500000000244514332063126017752 0ustar mdavismdavisName: perl-Geo-Functions Version: 0.08 Release: 1%{?dist} Summary: Package for standard Geo:: functions License: CHECK(Distributable) Group: Development/Libraries URL: http://search.cpan.org/dist/Geo-Functions/ Source0: http://www.cpan.org/modules/by-module/Geo/Geo-Functions-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch BuildRequires: perl(Exporter) BuildRequires: perl(ExtUtils::MakeMaker) BuildRequires: perl(Geo::Constants) >= 0.06 Requires: perl(Exporter) Requires: perl(Geo::Constants) >= 0.06 Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) %description Package for standard Geo:: functions. %prep %setup -q -n Geo-Functions-%{version} %build %{__perl} Makefile.PL INSTALLDIRS=vendor make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make pure_install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \; find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null \; %{_fixperms} $RPM_BUILD_ROOT/* %check make test %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc Changes LICENSE README.md %{perl_vendorlib}/* %{_mandir}/man3/* %changelog Geo-Functions-0.08/LICENSE0000644000175000017500000000206114332060411014447 0ustar mdavismdavisMIT License Copyright (c) 2022 Michael R. Davis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Geo-Functions-0.08/Makefile.PL0000644000175000017500000000174114332063623015430 0ustar mdavismdavisuse ExtUtils::MakeMaker; WriteMakefile( LICENSE => 'mit', NAME => q{Geo::Functions}, VERSION_FROM => q{lib/Geo/Functions.pm}, ABSTRACT_FROM => 'lib/Geo/Functions.pm', PREREQ_PM => { 'Exporter' => 0, 'Geo::Constants' => 0.06, }, 'META_MERGE' => { 'resources' => { 'repository' => { 'web' => 'https://github.com/mrdvt92/perl-Geo-Functions.git', 'url' => 'git@github.com:mrdvt92/perl-Geo-Functions.git', 'type' => 'git' }, 'homepage' => 'https://github.com/mrdvt92/perl-Geo-Functions', 'bugtracker' => { 'web' => 'https://github.com/mrdvt92/perl-Geo-Functions/issues' } }, 'meta-spec' => {'version' => 2}, }, ); Geo-Functions-0.08/META.yml0000664000175000017500000000127714332064273014737 0ustar mdavismdavis--- abstract: 'Package for standard Geo:: functions.' author: - unknown build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.52, CPAN::Meta::Converter version 2.150001' license: mit meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Geo-Functions no_index: directory: - t - inc requires: Exporter: '0' Geo::Constants: '0.06' resources: bugtracker: https://github.com/mrdvt92/perl-Geo-Functions/issues homepage: https://github.com/mrdvt92/perl-Geo-Functions repository: https://github.com/mrdvt92/perl-Geo-Functions.git version: '0.08' Geo-Functions-0.08/META.json0000664000175000017500000000230114332064273015074 0ustar mdavismdavis{ "abstract" : "Package for standard Geo:: functions.", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.52, CPAN::Meta::Converter version 2.150001", "license" : [ "mit" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Geo-Functions", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Exporter" : "0", "Geo::Constants" : "0.06" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/mrdvt92/perl-Geo-Functions/issues" }, "homepage" : "https://github.com/mrdvt92/perl-Geo-Functions", "repository" : { "type" : "git", "web" : "https://github.com/mrdvt92/perl-Geo-Functions.git" } }, "version" : "0.08" }