<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7648591157602257133</id><updated>2024-09-09T07:23:16.582-07:00</updated><category term="Ruby"/><title type='text'>Coding and Web Stuff</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codingandweb.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7648591157602257133/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://codingandweb.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anders</name><uri>http://www.blogger.com/profile/08409330630989692326</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7648591157602257133.post-3915133602073940188</id><published>2012-04-11T16:45:00.000-07:00</published><updated>2012-04-12T01:44:56.320-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ruby"/><title type='text'>Calculating distance between two points in Ruby with the Haversine formula</title><content type='html'>I recently needed to calculate the distance between two points (lat/long) in Ruby (reading a .gpx file, and finding the distance between each point).&lt;br /&gt;
&lt;div&gt;
After a quick search on stackoverflow.com I found the following post&amp;nbsp;&lt;a href=&quot;http://stackoverflow.com/questions/569980/how-to-calculate-distance-from-a-gpx-file&quot;&gt;http://stackoverflow.com/questions/569980/how-to-calculate-distance-from-a-gpx-file&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Below is my Ruby version of the formula shown in the second post:&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/2363499.js&quot;&gt; &lt;/script&gt;
&lt;br /&gt;
This will calculate in meters. To get KM, remove &quot;*1000&quot; on line 3. To get miles, change line 3 to &quot;r = 3959&quot;. I&#39;ll post the whole GPX parse code in a few days.&lt;/div&gt;
&lt;script src=&quot;https://raw.github.com/moski/gist-Blogger/master/public/gistLoader.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://codingandweb.blogspot.com/feeds/3915133602073940188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codingandweb.blogspot.com/2012/04/calculating-distance-between-two-points.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7648591157602257133/posts/default/3915133602073940188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7648591157602257133/posts/default/3915133602073940188'/><link rel='alternate' type='text/html' href='http://codingandweb.blogspot.com/2012/04/calculating-distance-between-two-points.html' title='Calculating distance between two points in Ruby with the Haversine formula'/><author><name>Anders</name><uri>http://www.blogger.com/profile/08409330630989692326</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry></feed>