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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Zipcode Proximity script
by hacker (Priest) on Mar 31, 2003 at 16:25 UTC |
In Section
Seekers of Perl Wisdom