Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Zipcode Proximity script

by tall_man (Parson)
on Mar 31, 2003 at 16:18 UTC ( #246975=note: print w/ replies, xml ) Need Help??


in reply to Zipcode Proximity script

If your C code is slow, a perl implementation will be even slower. What you need is a better data structure so you don't have to do a linear search over all codes, for example a quad tree. The module Tree::M might help.

Update: I notice that your perl code uses a flat-geometric distance rather than a curved-earth great circle distance. That's probably good enough for typical geometric queries (like "50 miles from my house"). But you could do the same thing in the C program. You could also search using the distance squared and avoid all those square roots.

my $xdelta = $x1-$x2; my $ydelta = $y1-$y2; my $distance_squared = $xdelta*$xdelta + $ydelta*$ydelta;


Comment on Re: Zipcode Proximity script
Download Code
Re: Zipcode Proximity script
by hacker (Priest) on Mar 31, 2003 at 16:25 UTC
    It gets better than that. The reason I need them in CSV format in two columns of origin,destination like that, is because I have to import them into... wait for it... a Microsoft Access .mdb file, so an ASP page can query it. The import only happens rarely, but often enough to want to optimize the tool that is doing the conversion.

    I'm slowly converting the system (carbon-based and silicon-based) to perl/mysql/php, depending on the needs, but for now, it has to remain in ADO/.mdb format during the transition.

    I'll take a peek at Tree::M though and see what that can do for me. Thanks.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-12-21 18:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls