go ahead... be a heretic | |
PerlMonks |
Re: CSV Cross Referencingby KurtSchwind (Chaplain) |
on Dec 03, 2014 at 14:55 UTC ( [id://1109121]=note: print w/replies, xml ) | Need Help?? |
So, it looks like you have some nice answers as to how to do a lookup/join across two delimited files. So I won't enter that part of the discussion. Instead let's focus on the next part. That is that instead of a straight join, it appears you really need a distance function. Depending on how many entries, you could solve this in a number of ways. The brute-force method is to use the following formula. sqrt((lat1-lat2)^2 + (long1-long2)^2). That'll give you a course distance. (Course, the earth is round, not flat, and there are better forumlas, but I think that this will be good enough for our discussion. So you'll want to compare the distance to each entry. Pick the smallest distance (note that an exact match would equal 0). Compare that distance to some $threshold value and see if it's "close enough". You'll notice that this method is very different than joining or doing lookups per-se. And it's possible you could sort/store your file in a way that it could easily filter out a lot of GPS locations immediately because they are so far off.
-- I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.
In Section
Seekers of Perl Wisdom
|
|