Build.PL100644001750001750 45514005175655 14300 0ustar00aranaran000000000000Geo-Distance-0.25# ========================================================================= # THIS FILE IS AUTOMATICALLY GENERATED BY MINILLA. # DO NOT EDIT DIRECTLY. # ========================================================================= use 5.008_001; use strict; use Module::Build::Tiny 0.035; Build_PL(); Changes100644001750001750 1022614005175655 14334 0ustar00aranaran000000000000Geo-Distance-0.25Revision history for Perl extension Geo-Distance. 0.25 2021-01-30T06:24:44Z - Lots of documentation edits. 0.24 2019-03-10T06:48:33Z - Once again support the alt formula (now with a PP variant!). 0.23 2019-03-09T13:15:58Z - Require GIS::Distance 0.13 so that tests pass. - Fixed a coordinate ordering bug in distance(). - Added the null formula. 0.22 2019-03-08T18:36:39Z - Made the distance() method faster. 0.21 2019-03-07T23:08:39Z - Officially set the x_deprecated META flag. - Use GIS::Distance 0.11+ for all distance calculations. - Lots and lots of documentation edits for the above. - Migrate build tooling from Dist::Zilla to Minilla. 0.20 2012-10-19 - Fix a test that was comparing floating point numbers and falling over on some platforms. 0.19 2012-04-03 - Fix various typos. - Fix floating point error in the hsin formula. 0.18 2012-03-23 - Fix gcd calculation to use ** instead of ^. 0.17 2011-06-28 - Fix circular package dependencies with Geo::Distance::XS (not really an issue practically, but then again it wasn't really helping). 0.16 - No changes. The 0.15 package was broken. 0.15 - Stop "Too late to run INIT block" warning. 0.14 - Fix "splice() offset past end of array" as filed in RT 26446. 0.13 - Use Geo::Distance::XS if available. - Declare Math::Trig dependency. 0.12 - Noted GIS::Distance in POD. - Some cleanups to install process. - Check for DBI in tests before using it. 0.11 2005-09-01 - Fixed some errors in the documentation. - Added an highly accurate ellipsoid formula. - lon_field and lat_field were not being used by closest. (D. Hageman) 0.10 2005-07-11 - The closest() method has a changed argument syntax and no longer supports array searches. - The closest() method works! - A real gcd formula (still, hsin is much better). - Tweaked docs. - Added some tests (yay!). 0.09 2005-04-01 - Modified the todo list to include ideas for future algorithms. - Fixed the nautical mile, mile, yard, and light second units. - Added the British spellings for kilometre, metre, and centimetre. - Added the poppy seed, barleycorn, rod, pole, perch, chain, furlong, league, fathom, millimeter, and millimetre units. - The totw.pl script was written by Ren and can be used to take over the world. 0.08 2005-03-20 - Updated the README description. - Removed debug print()s. Eeek! 0.07 2005-03-16 - Intermixed documentation with code so it is easier to keep the docs up-to-date. - OO interface only - method interface completely removed. - By default no units are defined. Call default_units. - Slightly more precise measurement of the base kilometer rho. - Added "nautical mile" unit type. - Reworked the closest() function. 0.06 2004-06-29 - Optional Haversine formula. - Misc documentation tweaks. 0.05 2003-03-19 - Added a note in the documentation about the inaccuracies of using Math::Trig. - The 'mile' unit was being calculated wrong which meant it was returning very inaccurate distances. - Fixed a silly bug where a sub was being relied on that no longer exists. - Documentation tweaks as usual. 0.04 2003-02-18 - Documentation revised once again. - Added reg_unit() for adding your own unit type. - find_closest has been overhauled: - Now accepts more than one field in the field=>'' parameter. - Will now return an array reference of distances instead of attaching the distances to the locations array ref. - A little more effecient. - Now accepts a count argument. - Accepts an array reference for searching. Mostly good for testing, but who knows? - Removed geo_ portion of names for exported functions. - Removed some of the input checking. Just not necessary. - Enhanced tests. Now we're actually doing some real testing. Need more tests tho. 0.03 2003-02-15 - Documentation modified. - Added find_closest() which accepts a $dbh for searching in an SQL database. - distance_dirty() can now accept locations as array refs. 0.02 2003-02-14 - Based on a suggestion by Jack D. I migrated the code to use Math::Trig for most of the distance math. - POD documentation written. - Object oriented interface created. LICENSE100644001750001750 4377014005175655 14060 0ustar00aranaran000000000000Geo-Distance-0.25This software is copyright (c) 2019 by Aran Clary Deltac . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2019 by Aran Clary Deltac . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2019 by Aran Clary Deltac . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End META.json100644001750001750 434214005175655 14444 0ustar00aranaran000000000000Geo-Distance-0.25{ "abstract" : "Calculate distances and closest locations. (DEPRECATED)", "author" : [ "Aran Clary Deltac " ], "dynamic_config" : 0, "generated_by" : "Minilla/v3.1.11", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Geo-Distance", "no_index" : { "directory" : [ "t", "xt", "inc", "share", "eg", "examples", "author", "builder" ] }, "prereqs" : { "configure" : { "requires" : { "Module::Build::Tiny" : "0.035" } }, "develop" : { "requires" : { "Test::CPAN::Meta" : "0", "Test::MinimumVersion::Fast" : "0.04", "Test::PAUSE::Permissions" : "0.07", "Test::Pod" : "1.41", "Test::Spellunker" : "v0.2.7" } }, "runtime" : { "requires" : { "Carp" : "0", "Const::Fast" : "0.014", "GIS::Distance" : "0.14", "GIS::Distance::Constants" : "0.14", "perl" : "5.008001" } }, "test" : { "recommends" : { "DBD::SQLite" : "1.46" }, "requires" : { "Test2::V0" : "0.000094" } } }, "provides" : { "Geo::Distance" : { "file" : "lib/Geo/Distance.pm", "version" : "0.25" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/bluefeet/Geo-Distance/issues" }, "homepage" : "https://github.com/bluefeet/Geo-Distance", "repository" : { "url" : "git://github.com/bluefeet/Geo-Distance.git", "web" : "https://github.com/bluefeet/Geo-Distance" } }, "version" : "0.25", "x_authority" : "cpan:BLUEFEET", "x_contributors" : [ "Anirvan Chatterjee ", "Niko Tyni ", "gray ", "Ævar Arnfjörð Bjarmason " ], "x_deprecated" : 1, "x_serialization_backend" : "JSON::PP version 4.02", "x_static_install" : 1 } README.md100644001750001750 2015714005175655 14324 0ustar00aranaran000000000000Geo-Distance-0.25# NAME Geo::Distance - Calculate distances and closest locations. (DEPRECATED) # SYNOPSIS ```perl use Geo::Distance; my $geo = new Geo::Distance; $geo->formula('hsin'); $geo->reg_unit( 'toad_hop', 200120 ); $geo->reg_unit( 'frog_hop' => 6 => 'toad_hop' ); my $distance = $geo->distance( 'unit_type', $lon1,$lat1 => $lon2,$lat2 ); my $locations = $geo->closest( dbh => $dbh, table => $table, lon => $lon, lat => $lat, unit => $unit_type, distance => $dist_in_unit ); ``` # DESCRIPTION This perl library aims to provide as many tools to make it as simple as possible to calculate distances between geographic points, and anything that can be derived from that. Currently there is support for finding the closest locations within a specified distance, to find the closest number of points to a specified point, and to do basic point-to-point distance calculations. # DEPRECATED This module has been gutted and is now a wrapper around [GIS::Distance](https://metacpan.org/pod/GIS%3A%3ADistance), please use that module instead. When switching from this module to [GIS::Distance](https://metacpan.org/pod/GIS%3A%3ADistance) make sure you reverse the coordinates when passing them to ["distance" in GIS::Distance](https://metacpan.org/pod/GIS%3A%3ADistance#distance). GIS::Distance takes lat/lon pairs while Geo::Distance takes lon/lat pairs. # ARGUMENTS ## no\_units Set this to disable the loading of the default units as described in ["UNITS"](#units). # ACCESSORS ## formula ``` if ($geo->formula() eq 'hsin') { ... } $geo->formula('cos'); ``` Set and get the formula that is currently being used to calculate distances. See the available ["FORMULAS"](#formulas). `hsin` is the default. # METHODS ## distance ```perl my $distance = $geo->distance( 'unit_type', $lon1,$lat1 => $lon2,$lat2 ); ``` Calculates the distance between two lon/lat points. ## closest ```perl my $locations = $geo->closest( dbh => $dbh, table => $table, lon => $lon, lat => $lat, unit => $unit_type, distance => $dist_in_unit ); ``` This method finds the closest locations within a certain distance and returns an array reference with a hash for each location matched. The closest method requires the following arguments: ```perl dbh - a DBI database handle table - a table within dbh that contains the locations to search lon - the longitude of the center point lat - the latitude of the center point unit - the unit of measurement to use, such as "meter" distance - the distance, in units, from the center point to find locations ``` The following arguments are optional: ```perl lon_field - the name of the field in the table that contains the longitude, defaults to "lon" lat_field - the name of the field in the table that contains the latitude, defaults to "lat" fields - an array reference of extra field names that you would like returned with each location where - additional rules for the where clause of the sql bind - an array reference of bind variables to go with the placeholders in where sort - whether to sort the locations by their distance, making the closest location the first returned count - return at most these number of locations (implies sort => 1) ``` This method uses some very simplistic calculations to SQL select out of the dbh. This means that the SQL should work fine on almost any database (only tested on MySQL and SQLite so far) and this also means that it is fast. Once this sub set of locations has been retrieved then more precise calculations are made to narrow down the result set. Remember, though, that the farther out your distance is, and the more locations in the table, the slower your searches will be. ## reg\_unit ```perl $geo->reg_unit( $radius, $key ); $geo->reg_unit( $key1 => $key2 ); $geo->reg_unit( $count1, $key1 => $key2 ); $geo->reg_unit( $key1 => $count2, $key2 ); $geo->reg_unit( $count1, $key1 => $count2, $key2 ); ``` This method is used to create custom unit types. There are several ways of calling it, depending on if you are defining the unit from scratch, or if you are basing it off of an existing unit (such as saying 12 inches = 1 foot ). When defining a unit from scratch you pass the name and rho (radius of the earth in that unit) value. So, if you wanted to do your calculations in human adult steps you would have to have an average human adult walk from the crust of the earth to the core (ignore the fact that this is impossible). So, assuming we did this and we came up with 43,200 steps, you'd do something like the following. ``` # Define adult step unit. $geo->reg_unit( 43200, 'adult step' ); # This can be read as "It takes 43,200 adult_steps to walk the radius of the earth". ``` Now, if you also wanted to do distances in baby steps you might think "well, now I gotta get a baby to walk to the center of the earth". But, you don't have to! If you do some research you'll find (no research was actually conducted) that there are, on average, 4.7 baby steps in each adult step. ```perl # Define baby step unit. $geo->reg_unit( 4.7, 'baby step' => 'adult step' ); # This can be read as "4.7 baby steps is the same as one adult step". ``` And if we were doing this in reverse and already had the baby step unit but not the adult step, you would still use the exact same syntax as above. # FORMULAS - `alt` - See [GIS::Distance::ALT](https://metacpan.org/pod/GIS%3A%3ADistance%3A%3AALT). - `cos` - See [GIS::Distance::Cosine](https://metacpan.org/pod/GIS%3A%3ADistance%3A%3ACosine). - `gcd` - See [GIS::Distance::GreatCircle](https://metacpan.org/pod/GIS%3A%3ADistance%3A%3AGreatCircle). - `hsin` - See [GIS::Distance::Haversine](https://metacpan.org/pod/GIS%3A%3ADistance%3A%3AHaversine). - `mt` - See [GIS::Distance::MathTrig](https://metacpan.org/pod/GIS%3A%3ADistance%3A%3AMathTrig). - `null` - See [GIS::Distance::Null](https://metacpan.org/pod/GIS%3A%3ADistance%3A%3ANull). - `polar` - See [GIS::Distance::Polar](https://metacpan.org/pod/GIS%3A%3ADistance%3A%3APolar). - `tv` - See [GIS::Distance::Vincenty](https://metacpan.org/pod/GIS%3A%3ADistance%3A%3AVincenty). # LATITUDE AND LONGITUDE When a function needs a longitude and latitude, they must always be in decimal degree format. Here is some sample code for converting from other formats to decimal: ```perl # DMS to Decimal my $decimal = $degrees + ($minutes/60) + ($seconds/3600); # Precision Six Integer to Decimal my $decimal = $integer * .000001; ``` If you want to convert from decimal radians to degrees you can use Math::Trig's rad2deg function. # UNITS The ["distance"](#distance) and ["closest"](#closest) functions take an argument containing the name of a registered unit, such as `kilometer`, to do the computation of distance with. By default a useful set of units are registered and custom units may be added with ["reg\_unit"](#reg_unit). The default set of units are: ``` kilometer, kilometre, meter, metre, centimeter, centimetre, millimeter, millimetre, yard, foot, inch, light second, mile, nautical mile, poppy seed, barleycorn, rod, pole, perch, chain, furlong, league, fathom ``` The ["no\_units"](#no_units) argument may be set to disable the default units from being registered. # STABILITY The interface to Geo::Distance is fairly stable nowadays. If this changes it will be noted here. - `0.21` - All distance calculations are now handled by [GIS::Distance](https://metacpan.org/pod/GIS%3A%3ADistance). - `0.10` - The closest() method has a changed argument syntax and no longer supports array searches. - `0.09` - Changed the behavior of the reg\_unit function. - `0.07` - OO only, and other changes all over. # SUPPORT Please submit bugs and feature requests to the Geo-Distance GitHub issue tracker: [https://github.com/bluefeet/Geo-Distance/issues](https://github.com/bluefeet/Geo-Distance/issues) Note that, due to the ["DEPRECATED"](#deprecated) nature of this distribution, new features and such may be denied. # AUTHORS ``` Aran Clary Deltac gray Anirvan Chatterjee Ævar Arnfjörð Bjarmason Niko Tyni ``` # LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. cpanfile100644001750001750 41614005175655 14505 0ustar00aranaran000000000000Geo-Distance-0.25requires 'perl' => '5.008001'; requires 'Const::Fast' => '0.014'; requires 'GIS::Distance' => '0.14'; requires 'GIS::Distance::Constants' => '0.14'; requires 'Carp'; on test => sub { requires 'Test2::V0' => '0.000094'; recommends 'DBD::SQLite' => '1.46'; }; Distance.pm100644001750001750 4203714005175655 16416 0ustar00aranaran000000000000Geo-Distance-0.25/lib/Geopackage Geo::Distance; use 5.008001; use strict; use warnings; our $VERSION = '0.25'; use GIS::Distance; use GIS::Distance::Constants qw( :all ); use Carp qw( croak ); use Const::Fast; const our %GEO_TO_GIS_FORMULA_MAP => (qw( alt ALT cos Cosine gcd GreatCircle hsin Haversine mt MathTrig null Null polar Polar tv Vincenty )); const our @FORMULAS => (keys %GEO_TO_GIS_FORMULA_MAP); sub new { my $class = shift; my $self = bless {}, $class; my %args = @_; $self->{formula} = 'hsin'; $self->{units} = {}; if(!$args{no_units}){ $self->reg_unit( $KILOMETER_RHO, 'kilometer' ); $self->reg_unit( 1000, 'meter', => 'kilometer' ); $self->reg_unit( 100, 'centimeter' => 'meter' ); $self->reg_unit( 10, 'millimeter' => 'centimeter' ); $self->reg_unit( 'kilometre' => 'kilometer' ); $self->reg_unit( 'metre' => 'meter' ); $self->reg_unit( 'centimetre' => 'centimeter' ); $self->reg_unit( 'millimetre' => 'millimeter' ); $self->reg_unit( 'mile' => 1609.344, 'meter' ); $self->reg_unit( 'nautical mile' => 1852, 'meter' ); $self->reg_unit( 'yard' => 0.9144, 'meter' ); $self->reg_unit( 3, 'foot' => 'yard' ); $self->reg_unit( 12, 'inch' => 'foot' ); $self->reg_unit( 'light second' => 299792458, 'meter' ); $self->reg_unit( 'poppy seed' => 2.11, 'millimeter' ); $self->reg_unit( 'barleycorn' => 8.467, 'millimeter' ); $self->reg_unit( 'rod' => 5.0292, 'meter' ); $self->reg_unit( 'pole' => 'rod' ); $self->reg_unit( 'perch' => 'rod' ); $self->reg_unit( 'chain' => 20.1168, 'meter' ); $self->reg_unit( 'furlong' => 201.168, 'meter' ); $self->reg_unit( 'league' => 4.828032, 'kilometer' ); $self->reg_unit( 1.8288, 'fathom' => 'meter' ); } return $self; } sub formula { my $self = shift; return $self->{formula} if !$_[0]; my $formula = shift; my $gis_formula = $GEO_TO_GIS_FORMULA_MAP{ $formula }; croak( 'Unknown formula (available formulas are ', join(', ', sort @FORMULAS), ')', ) if !$gis_formula; $self->{formula} = $formula; $self->{gis_formula} = $gis_formula; return $formula; } sub distance { my ($self, $unit, $lon1, $lat1, $lon2, $lat2) = @_; my $unit_rho = $self->{units}->{$unit}; croak('Unkown unit type "' . $unit . '"') if !$unit_rho; my $gis = GIS::Distance->new( $self->{gis_formula} ); # Reverse lon/lat to lat/lon, the way GIS::Distance wants it. my $km = $gis->{code}->( $lat1, $lon1, $lat2, $lon2 ); return $km * ($unit_rho / $KILOMETER_RHO); } use Math::Trig qw( acos asin atan deg2rad great_circle_distance pi tan ); sub old_distance { my($self,$unit,$lon1,$lat1,$lon2,$lat2) = @_; croak('Unkown unit type "'.$unit.'"') unless($unit = $self->{units}->{$unit}); return 0 if $self->{formula} eq 'null'; return 0 if $self->{formula} eq 'alt'; if($self->{formula} eq 'mt'){ return great_circle_distance( deg2rad($lon1), deg2rad(90 - $lat1), deg2rad($lon2), deg2rad(90 - $lat2), $unit ); } $lon1 = deg2rad($lon1); $lat1 = deg2rad($lat1); $lon2 = deg2rad($lon2); $lat2 = deg2rad($lat2); my $c; if($self->{formula} eq 'cos'){ my $a = sin($lat1) * sin($lat2); my $b = cos($lat1) * cos($lat2) * cos($lon2 - $lon1); $c = acos($a + $b); } elsif($self->{formula} eq 'hsin'){ my $dlon = $lon2 - $lon1; my $dlat = $lat2 - $lat1; my $a = (sin($dlat/2)) ** 2 + cos($lat1) * cos($lat2) * (sin($dlon/2)) ** 2; $c = 2 * atan2(sqrt($a), sqrt(abs(1-$a))); } elsif($self->{formula} eq 'polar'){ my $a = pi/2 - $lat1; my $b = pi/2 - $lat2; $c = sqrt( $a ** 2 + $b ** 2 - 2 * $a * $b * cos($lon2 - $lon1) ); } elsif($self->{formula} eq 'gcd'){ $c = 2*asin( sqrt( ( sin(($lat1-$lat2)/2) )**2 + cos($lat1) * cos($lat2) * ( sin(($lon1-$lon2)/2) )**2 ) ); # Eric Samuelson recommended this formula. # http://forums.devshed.com/t54655/sc3d021a264676b9b440ea7cbe1f775a1.html # http://williams.best.vwh.net/avform.htm # It seems to produce the same results at the hsin formula, so... #my $dlon = $lon2 - $lon1; #my $dlat = $lat2 - $lat1; #my $a = (sin($dlat / 2)) ** 2 # + cos($lat1) * cos($lat2) * (sin($dlon / 2)) ** 2; #$c = 2 * atan2(sqrt($a), sqrt(1 - $a)); } elsif($self->{formula} eq 'tv'){ my($a,$b,$f) = (6378137,6356752.3142,1/298.257223563); my $l = $lon2 - $lon1; my $u1 = atan((1-$f) * tan($lat1)); my $u2 = atan((1-$f) * tan($lat2)); my $sin_u1 = sin($u1); my $cos_u1 = cos($u1); my $sin_u2 = sin($u2); my $cos_u2 = cos($u2); my $lambda = $l; my $lambda_pi = 2 * pi; my $iter_limit = 20; my($cos_sq_alpha,$sin_sigma,$cos2sigma_m,$cos_sigma,$sigma); while( abs($lambda-$lambda_pi) > 1e-12 && --$iter_limit>0 ){ my $sin_lambda = sin($lambda); my $cos_lambda = cos($lambda); $sin_sigma = sqrt(($cos_u2*$sin_lambda) * ($cos_u2*$sin_lambda) + ($cos_u1*$sin_u2-$sin_u1*$cos_u2*$cos_lambda) * ($cos_u1*$sin_u2-$sin_u1*$cos_u2*$cos_lambda)); $cos_sigma = $sin_u1*$sin_u2 + $cos_u1*$cos_u2*$cos_lambda; $sigma = atan2($sin_sigma, $cos_sigma); my $alpha = asin($cos_u1 * $cos_u2 * $sin_lambda / $sin_sigma); $cos_sq_alpha = cos($alpha) * cos($alpha); $cos2sigma_m = $cos_sigma - 2*$sin_u1*$sin_u2/$cos_sq_alpha; my $cc = $f/16*$cos_sq_alpha*(4+$f*(4-3*$cos_sq_alpha)); $lambda_pi = $lambda; $lambda = $l + (1-$cc) * $f * sin($alpha) * ($sigma + $cc*$sin_sigma*($cos2sigma_m+$cc*$cos_sigma*(-1+2*$cos2sigma_m*$cos2sigma_m))); } undef if( $iter_limit==0 ); my $usq = $cos_sq_alpha*($a*$a-$b*$b)/($b*$b); my $aa = 1 + $usq/16384*(4096+$usq*(-768+$usq*(320-175*$usq))); my $bb = $usq/1024 * (256+$usq*(-128+$usq*(74-47*$usq))); my $delta_sigma = $bb*$sin_sigma*($cos2sigma_m+$bb/4*($cos_sigma*(-1+2*$cos2sigma_m*$cos2sigma_m)- $bb/6*$cos2sigma_m*(-3+4*$sin_sigma*$sin_sigma)*(-3+4*$cos2sigma_m*$cos2sigma_m))); $c = ( $b*$aa*($sigma-$delta_sigma) ) / $self->{units}->{meter}; } else{ croak('Unkown distance formula "'.$self->{formula}.'"'); } return $unit * $c; } sub closest { my $self = shift; my %args = @_; # Set defaults and prepare. my $dbh = $args{dbh} || croak('You must supply a database handle'); $dbh->isa('DBI::db') || croak('The dbh must be a DBI database handle'); my $table = $args{table} || croak('You must supply a table name'); my $lon = $args{lon} || croak('You must supply a longitude'); my $lat = $args{lat} || croak('You must supply a latitude'); my $distance = $args{distance} || croak('You must supply a distance'); my $unit = $args{unit} || croak('You must specify a unit type'); my $unit_size = $self->{units}->{$unit} || croak('This unit type is not known'); my $degrees = $distance / ( $DEG_RATIO * $unit_size ); my $lon_field = $args{lon_field} || 'lon'; my $lat_field = $args{lat_field} || 'lat'; my $fields = $args{fields} || []; unshift @$fields, $lon_field, $lat_field; $fields = join( ',', @$fields ); my $count = $args{count} || 0; my $sort = $args{sort} || ( $count ? 1 : 0 ); my $where = qq{$lon_field >= ? AND $lat_field >= ? AND $lon_field <= ? AND $lat_field <= ?}; $where .= ( $args{where} ? " AND ($args{where})" : '' ); my @bind = ( $lon-$degrees, $lat-$degrees, $lon+$degrees, $lat+$degrees, ( $args{bind} ? @{$args{bind}} : () ) ); # Retrieve locations. my $sth = $dbh->prepare(qq{ SELECT $fields FROM $table WHERE $where }); $sth->execute( @bind ); my $locations = []; while(my $location = $sth->fetchrow_hashref){ push @$locations, $location; } # Calculate distances. my $closest = []; foreach my $location (@$locations){ $location->{distance} = $self->distance( $unit, $lon, $lat, $location->{$lon_field}, $location->{$lat_field} ); if( $location->{distance} <= $distance ){ push @$closest, $location; } } $locations = $closest; # Sort. if( $sort ){ @$locations = sort { $a->{distance} <=> $b->{distance} } @$locations; } # Split for count. if( $count and $count < @$locations ){ splice @$locations, $count; } return $locations; } sub reg_unit { my $self = shift; my $units = $self->{units}; my($count1,$key1,$count2,$key2); $count1 = shift; if($count1=~/[^\.0-9]/ or !@_){ $key1=$count1; $count1=1; } else{ $key1 = shift; } if(!@_){ $units->{$key1} = $count1; }else{ $count2 = shift; if($count2=~/[^\.0-9]/ or !@_){ $key2=$count2; $count2=1; } else{ $key2 = shift; } ($key1,$key2) = ($key2,$key1) if( defined $units->{$key1} ); $units->{$key1} = ($units->{$key2}*$count1) / $count2; } } 1; __END__ =encoding utf8 =head1 NAME Geo::Distance - Calculate distances and closest locations. (DEPRECATED) =head1 SYNOPSIS use Geo::Distance; my $geo = new Geo::Distance; $geo->formula('hsin'); $geo->reg_unit( 'toad_hop', 200120 ); $geo->reg_unit( 'frog_hop' => 6 => 'toad_hop' ); my $distance = $geo->distance( 'unit_type', $lon1,$lat1 => $lon2,$lat2 ); my $locations = $geo->closest( dbh => $dbh, table => $table, lon => $lon, lat => $lat, unit => $unit_type, distance => $dist_in_unit ); =head1 DESCRIPTION This perl library aims to provide as many tools to make it as simple as possible to calculate distances between geographic points, and anything that can be derived from that. Currently there is support for finding the closest locations within a specified distance, to find the closest number of points to a specified point, and to do basic point-to-point distance calculations. =head1 DEPRECATED This module has been gutted and is now a wrapper around L, please use that module instead. When switching from this module to L make sure you reverse the coordinates when passing them to L. GIS::Distance takes lat/lon pairs while Geo::Distance takes lon/lat pairs. =head1 ARGUMENTS =head2 no_units Set this to disable the loading of the default units as described in L. =head1 ACCESSORS =head2 formula if ($geo->formula() eq 'hsin') { ... } $geo->formula('cos'); Set and get the formula that is currently being used to calculate distances. See the available L. C is the default. =head1 METHODS =head2 distance my $distance = $geo->distance( 'unit_type', $lon1,$lat1 => $lon2,$lat2 ); Calculates the distance between two lon/lat points. =head2 closest my $locations = $geo->closest( dbh => $dbh, table => $table, lon => $lon, lat => $lat, unit => $unit_type, distance => $dist_in_unit ); This method finds the closest locations within a certain distance and returns an array reference with a hash for each location matched. The closest method requires the following arguments: dbh - a DBI database handle table - a table within dbh that contains the locations to search lon - the longitude of the center point lat - the latitude of the center point unit - the unit of measurement to use, such as "meter" distance - the distance, in units, from the center point to find locations The following arguments are optional: lon_field - the name of the field in the table that contains the longitude, defaults to "lon" lat_field - the name of the field in the table that contains the latitude, defaults to "lat" fields - an array reference of extra field names that you would like returned with each location where - additional rules for the where clause of the sql bind - an array reference of bind variables to go with the placeholders in where sort - whether to sort the locations by their distance, making the closest location the first returned count - return at most these number of locations (implies sort => 1) This method uses some very simplistic calculations to SQL select out of the dbh. This means that the SQL should work fine on almost any database (only tested on MySQL and SQLite so far) and this also means that it is fast. Once this sub set of locations has been retrieved then more precise calculations are made to narrow down the result set. Remember, though, that the farther out your distance is, and the more locations in the table, the slower your searches will be. =head2 reg_unit $geo->reg_unit( $radius, $key ); $geo->reg_unit( $key1 => $key2 ); $geo->reg_unit( $count1, $key1 => $key2 ); $geo->reg_unit( $key1 => $count2, $key2 ); $geo->reg_unit( $count1, $key1 => $count2, $key2 ); This method is used to create custom unit types. There are several ways of calling it, depending on if you are defining the unit from scratch, or if you are basing it off of an existing unit (such as saying 12 inches = 1 foot ). When defining a unit from scratch you pass the name and rho (radius of the earth in that unit) value. So, if you wanted to do your calculations in human adult steps you would have to have an average human adult walk from the crust of the earth to the core (ignore the fact that this is impossible). So, assuming we did this and we came up with 43,200 steps, you'd do something like the following. # Define adult step unit. $geo->reg_unit( 43200, 'adult step' ); # This can be read as "It takes 43,200 adult_steps to walk the radius of the earth". Now, if you also wanted to do distances in baby steps you might think "well, now I gotta get a baby to walk to the center of the earth". But, you don't have to! If you do some research you'll find (no research was actually conducted) that there are, on average, 4.7 baby steps in each adult step. # Define baby step unit. $geo->reg_unit( 4.7, 'baby step' => 'adult step' ); # This can be read as "4.7 baby steps is the same as one adult step". And if we were doing this in reverse and already had the baby step unit but not the adult step, you would still use the exact same syntax as above. =head1 FORMULAS =over =item * C - See L. =item * C - See L. =item * C - See L. =item * C - See L. =item * C - See L. =item * C - See L. =item * C - See L. =item * C - See L. =back =head1 LATITUDE AND LONGITUDE When a function needs a longitude and latitude, they must always be in decimal degree format. Here is some sample code for converting from other formats to decimal: # DMS to Decimal my $decimal = $degrees + ($minutes/60) + ($seconds/3600); # Precision Six Integer to Decimal my $decimal = $integer * .000001; If you want to convert from decimal radians to degrees you can use Math::Trig's rad2deg function. =head1 UNITS The L and L functions take an argument containing the name of a registered unit, such as C, to do the computation of distance with. By default a useful set of units are registered and custom units may be added with L. The default set of units are: kilometer, kilometre, meter, metre, centimeter, centimetre, millimeter, millimetre, yard, foot, inch, light second, mile, nautical mile, poppy seed, barleycorn, rod, pole, perch, chain, furlong, league, fathom The L argument may be set to disable the default units from being registered. =head1 STABILITY The interface to Geo::Distance is fairly stable nowadays. If this changes it will be noted here. =over =item * C<0.21> - All distance calculations are now handled by L. =item * C<0.10> - The closest() method has a changed argument syntax and no longer supports array searches. =item * C<0.09> - Changed the behavior of the reg_unit function. =item * C<0.07> - OO only, and other changes all over. =back =head1 SUPPORT Please submit bugs and feature requests to the Geo-Distance GitHub issue tracker: L Note that, due to the L nature of this distribution, new features and such may be denied. =head1 AUTHORS Aran Clary Deltac gray Anirvan Chatterjee Ævar Arnfjörð Bjarmason Niko Tyni =head1 LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut minil.toml100644001750001750 16614005175655 15010 0ustar00aranaran000000000000Geo-Distance-0.25name = "Geo-Distance" authority="cpan:BLUEFEET" markdown_maker = "Pod::Markdown::Github" [Metadata] x_deprecated = 1 basic.t100755001750001750 46614005175655 14522 0ustar00aranaran000000000000Geo-Distance-0.25/t#!/usr/bin/env perl use 5.008001; use strict; use warnings; use Test2::V0; BEGIN { $ENV{GIS_DISTANCE_PP} = 1 } use Geo::Distance; my $geo = Geo::Distance->new(); my $dist = $geo->distance( 'mile', "-81.044","35.244", "-80.8272","35.1935" ); is( int($dist), 12, 'measure a distance by mile' ); done_testing; closest.t100755001750001750 642314005175655 15134 0ustar00aranaran000000000000Geo-Distance-0.25/t#!/usr/bin/env perl use 5.008001; use strict; use warnings; use Test2::V0; use Test2::Require::Module 'DBD::SQLite'; BEGIN { $ENV{GIS_DISTANCE_PP} = 1 } use Geo::Distance; my $geo = Geo::Distance->new(); my $dbh = DBI->connect( 'dbi:SQLite:dbname=:memory:', '', '', { RaiseError=>1, AutoCommit=>1 }, ); load_zips( $dbh ); $geo->closest( dbh=>$dbh, table=>'zips', lon=>'-80.7881', lat=>'35.22', unit=>'mile', distance=>'5' ); my $locations; $locations = $geo->closest( dbh=>$dbh, table=>'zips', lon=>'-80.7881', lat=>'35.22', unit=>'mile', distance=>'5' ); is( (@$locations+0), 11, 'found correct number of locations by mile' ); $locations = $geo->closest( dbh=>$dbh, table=>'zips', lon=>'-80.8577', lat=>'35.1316', unit=>'kilometer', distance=>'5' ); is( (@$locations+0), 2, 'found correct number of locations by kilometer' ); $locations = $geo->closest( dbh=>$dbh, table=>'zips', lon=>'-80.8577', lat=>'35.1316', unit=>'mile', distance=>'5', count=>3 ); is( (@$locations+0), 3, 'found correct number of locations limited by count' ); cmp_ok( $locations->[0]->{distance}, '<', $locations->[1]->{distance}, 'correctly sorted the locations, part 1', ); cmp_ok( $locations->[1]->{distance}, '<', $locations->[2]->{distance}, 'correctly sorted the locations, part 2', ); done_testing; sub load_zips { my $dbh = shift; $dbh->do(q{ CREATE TABLE zips ( zip CHAR(5), lon DECIMAL(13,3), lat DECIMAL(13,3) ) }); my $sth = $dbh->prepare(q{ INSERT INTO zips (lon,lat,zip) VALUES (?,?,?) }); $sth->execute("-81.044","35.244","28012"); $sth->execute("-81.0306","35.3119","28120"); $sth->execute("-81.0079","35.0972","28217"); $sth->execute("-80.9604","35.1467","28278"); $sth->execute("-80.9586","35.026","29715"); $sth->execute("-80.9571","35.2731","28214"); $sth->execute("-80.8967","35.1596","28273"); $sth->execute("-80.8964","35.2358","28208"); $sth->execute("-80.8858","35.0709","28134"); $sth->execute("-80.8702","35.2834","28216"); $sth->execute("-80.8647","35.422","28078"); $sth->execute("-80.8583","35.2081","28203"); $sth->execute("-80.8577","35.1316","28210"); $sth->execute("-80.8559","35.1796","28209"); $sth->execute("-80.8419","35.229","28202"); $sth->execute("-80.8272","35.1935","28207"); $sth->execute("-80.8265","35.2522","28206"); $sth->execute("-80.8232","35.2132","28204"); $sth->execute("-80.8209","35.2886","28269"); $sth->execute("-80.8167","35.0869","28226"); $sth->execute("-80.8002","35.1345","28277"); $sth->execute("-80.7932","35.1677","28211"); $sth->execute("-80.7881","35.22","28205"); $sth->execute("-80.776","35.2725","28262"); $sth->execute("-80.7669","35.1355","28270"); $sth->execute("-80.7501","35.3179","28213"); $sth->execute("-80.7448","35.1908","28212"); $sth->execute("-80.7387","35.244","28215"); $sth->execute("-80.7279","34.9553","28173"); $sth->execute("-80.7136","35.1219","28105"); $sth->execute("-80.6846","35.1936","28227"); $sth->execute("-80.6597","35.0831","28079"); $sth->execute("-80.6594","35.3247","28075"); $sth->execute("-80.6162","35.4141","28027"); $sth->execute("-80.5319","35.2477","28107"); $sth->execute("-80.53","35.3716","28025"); } issue-github-2.t100755001750001750 172214005175655 16224 0ustar00aranaran000000000000Geo-Distance-0.25/t#!/usr/bin/env perl use 5.008001; use strict; use warnings; use Test2::V0; use Geo::Distance; use Math::Trig qw( asin ); my $geo = Geo::Distance->new(); $geo->formula('gcd'); my $new_value = $geo->distance( 'mile', "-81.044","35.244", "-80.8272","35.1935" ); my $old_value = old_gcd( $geo, 'mile', "-81.044","35.244", "-80.8272","35.1935" ); $geo->formula('hsin'); my $control_value = $geo->distance( 'mile', "-81.044","35.244", "-80.8272","35.1935" ); cmp_ok( abs($new_value - $control_value), '<', 0.00000000001, 'gcd now produces same result as hsin', ); cmp_ok( abs($old_value - $control_value), '>', 0.00000000001, 'old gcd did not produce same result as hsin', ); done_testing; sub old_gcd { my($geo,$unit,$lon1,$lat1,$lon2,$lat2) = @_; $unit = $geo->{units}->{$unit}; my $c = 2*asin( sqrt( ( sin(($lat1-$lat2)/2) )^2 + cos($lat1) * cos($lat2) * ( sin(($lon1-$lon2)/2) )^2 ) ); return $unit * $c; } issue-github-3.t100755001750001750 35414005175655 16205 0ustar00aranaran000000000000Geo-Distance-0.25/t#!/usr/bin/env perl use 5.008001; use strict; use warnings; use Test2::V0; use Geo::Distance; my $geo = Geo::Distance->new(); is( dies { $geo->distance('mile', 175, 12, -5, -12) }, undef, 'did not die', ); done_testing; META.yml100644001750001750 233014005175655 14267 0ustar00aranaran000000000000Geo-Distance-0.25--- abstract: 'Calculate distances and closest locations. (DEPRECATED)' author: - 'Aran Clary Deltac ' build_requires: Test2::V0: '0.000094' configure_requires: Module::Build::Tiny: '0.035' dynamic_config: 0 generated_by: 'Minilla/v3.1.11, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Geo-Distance no_index: directory: - t - xt - inc - share - eg - examples - author - builder provides: Geo::Distance: file: lib/Geo/Distance.pm version: '0.25' requires: Carp: '0' Const::Fast: '0.014' GIS::Distance: '0.14' GIS::Distance::Constants: '0.14' perl: '5.008001' resources: bugtracker: https://github.com/bluefeet/Geo-Distance/issues homepage: https://github.com/bluefeet/Geo-Distance repository: git://github.com/bluefeet/Geo-Distance.git version: '0.25' x_authority: cpan:BLUEFEET x_contributors: - 'Anirvan Chatterjee ' - 'Niko Tyni ' - 'gray ' - 'Ævar Arnfjörð Bjarmason ' x_deprecated: 1 x_serialization_backend: 'CPAN::Meta::YAML version 0.018' x_static_install: 1 MANIFEST100644001750001750 24214005175655 14127 0ustar00aranaran000000000000Geo-Distance-0.25Build.PL Changes LICENSE META.json README.md cpanfile lib/Geo/Distance.pm minil.toml t/basic.t t/closest.t t/issue-github-2.t t/issue-github-3.t META.yml MANIFEST