Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: Alternatives To Geo::Distance

by Limbic~Region (Chancellor)
on Oct 22, 2010 at 02:58 UTC ( [id://866713]=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^5: Alternatives To Geo::Distance (order)
by tye (Sage) on Oct 22, 2010 at 04:52 UTC

    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://866713]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-19 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found