Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Alternatives To Geo::Distance

by gray (Beadle)
on Oct 22, 2010 at 02:32 UTC ( [id://866703]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Alternatives To Geo::Distance
in thread Alternatives To Geo::Distance

Regarding your benchmark. First, I suspect you didn't "You can stick with the pure Perl version by setting the GEO_DISTANCE_PP environment variable before using this module" This is because Geo::Distance gave the correct answer which it I know it doesn't (the point of this thread).

$ENV{GEO_DISTANCE_PP} just triggers Geo::Distance::XS->unimport(), which my benchmark script calls directly. I also checked the results by hiding Geo::Distance::XS with Test-Without-Module and they were consistent. Note also the results for the 'gcd' formula- both Geo::Distance and GIS::Distance::Fast failed, whereas Geo::Distance::XS produced a reasonable result. Perhaps if you posted your test script we could dig further.

Replies are listed 'Best First'.
Re^4: Alternatives To Geo::Distance
by Limbic~Region (Chancellor) on Oct 22, 2010 at 02:58 UTC
    gray,
    Perhaps if you posted your test script we could dig further.

    Without Geo::Distance::XS present.

    #!/usr/bin/perl use strict; use warnings; use Geo::Distance; my $geo = Geo::Distance->new; for (qw/tv hsin polar cos gcd mt/) { $geo->formula($_); print $_, " ", $geo->distance('mile', 39.175555,-76.671388 => 33.9 +42222,-118.407222), "\n"; } __DATA__ tv 9537.71241222878 hsin 2881.23714304656 polar 3114.47526297555 cos 2881.23714304656 gcd 12438.0476860875-9076.08896733252i mt 2881.23714304656

    Geo::Distance::XS
    use strict; use warnings; use Geo::Distance::XS; my $geo = Geo::Distance->new; for (qw/tv hsin polar cos gcd mt/) { $geo->formula($_); print $_, " ", $geo->distance('mile', 39.175555,-76.671388 => 33.9 +42222,-118.407222), "\n"; } __DATA__ tv 9538.66771882495 hsin 2881.23714304656 polar 3114.47526297555 cos 2881.23714304656 gcd 2881.23714304656 mt 2881.23714304656
    Update: Ok, I am a freaking idiot who should not write code while up late at night. I swapped long/lat. This was further complicated by tye's method having in the same order as I was using which produces the correct result. I need to have my JAPH card revoked. Please forgive my gigantic stupidity.

    Cheers - L~R

      The module takes "long, lat"?! Well, I wouldn't call you the idiot. ;)

      A Google fight shows:

      • "lat long": 5.6 million hits
      • "long lat": 0.36 million hits

      And the first page of hits for "long lat" all have titles that include "latitude longitude" in that order.

      On such an interface, I'd probably require the tagging of the passed-in data with 'N' and 'E' to help avoid reversing the two numbers or getting a sign wrong.

      - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://866703]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-23 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found