<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Calculating distances from latitude and longitude (PHP)</title>
	<atom:link href="http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/feed" rel="self" type="application/rss+xml" />
	<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php</link>
	<description>Design &#38; Technology Observations</description>
	<lastBuildDate>Sun, 18 Jul 2010 17:26:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: nik</title>
		<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/comment-page-1#comment-788</link>
		<dc:creator>nik</dc:creator>
		<pubDate>Thu, 29 Sep 2005 07:40:14 +0000</pubDate>
		<guid isPermaLink="false">http://sniptools.com/cms/?p=23#comment-788</guid>
		<description>postcode data and sql file at the attached url

&lt;a href=&quot;http://www.easypeasy.com/guides/article.php?article=64&quot; rel=&quot;nofollow&quot;&gt;http://www.easypeasy.com/guides/article.php?article=64&lt;/a&gt;
</description>
		<content:encoded><![CDATA[<p>postcode data and sql file at the attached url</p>
<p><a href="http://www.easypeasy.com/guides/article.php?article=64" rel="nofollow">http://www.easypeasy.com/guides/article.php?article=64</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Waterhouse</title>
		<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/comment-page-1#comment-787</link>
		<dc:creator>Mark Waterhouse</dc:creator>
		<pubDate>Sun, 14 Aug 2005 03:29:27 +0000</pubDate>
		<guid isPermaLink="false">http://sniptools.com/cms/?p=23#comment-787</guid>
		<description>Hi
Does anyone have a copy of the postcode sql database? Its no longer available at the URL above.

Thanks
Mark
</description>
		<content:encoded><![CDATA[<p>Hi<br />
Does anyone have a copy of the postcode sql database? Its no longer available at the URL above.</p>
<p>Thanks<br />
Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Karran</title>
		<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/comment-page-1#comment-786</link>
		<dc:creator>Dan Karran</dc:creator>
		<pubDate>Tue, 05 Jul 2005 13:50:12 +0000</pubDate>
		<guid isPermaLink="false">http://sniptools.com/cms/?p=23#comment-786</guid>
		<description>Thanks. I found your page via Google and implemented the code in SQL (before realising someone else had done the work for me in your comments). I&#039;m using it to calculate the distance between places I&#039;ve taken photographs, and displaying the distances alongside a map using the new Google Maps API interface.

&lt;a href=&quot;http://www.dankarran.com/photography/map/?town=castletown&quot; rel=&quot;nofollow&quot;&gt;http://www.dankarran.com/photography/map/?town=castletown&lt;/a&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks. I found your page via Google and implemented the code in SQL (before realising someone else had done the work for me in your comments). I&#8217;m using it to calculate the distance between places I&#8217;ve taken photographs, and displaying the distances alongside a map using the new Google Maps API interface.</p>
<p><a href="http://www.dankarran.com/photography/map/?town=castletown" rel="nofollow">http://www.dankarran.com/photography/map/?town=castletown</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Fox</title>
		<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/comment-page-1#comment-785</link>
		<dc:creator>Tony Fox</dc:creator>
		<pubDate>Thu, 20 Jan 2005 02:57:55 +0000</pubDate>
		<guid isPermaLink="false">http://sniptools.com/cms/?p=23#comment-785</guid>
		<description>The end of the script will not show because of the less than symbol

add at the end &quot;less than&quot; 120)
</description>
		<content:encoded><![CDATA[<p>The end of the script will not show because of the less than symbol</p>
<p>add at the end &#8220;less than&#8221; 120)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Fox</title>
		<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/comment-page-1#comment-784</link>
		<dc:creator>Tony Fox</dc:creator>
		<pubDate>Thu, 20 Jan 2005 01:26:36 +0000</pubDate>
		<guid isPermaLink="false">http://sniptools.com/cms/?p=23#comment-784</guid>
		<description>Looks like the end of the script has been missed off. Try This:-

SELECT a.Town,a.Postcode,b.lat_dec AS lat1,b.long_dec AS long1,c.lat_dec AS lat2,c.long_dec AS long2,round(degrees(acos(sin(radians(b.lat_dec))* sin(radians(c.lat_dec))+cos(radians(b.lat_dec))* cos(radians(c.lat_dec))*cos(radians(b.long_dec - c.long_dec))))*69, 2) AS distance FROM postcode_names a,postcode_data b,postcode_data c WHERE c.Postcode = &#039;NR32&#039; AND a.Postcode = b.Postcode AND round(degrees(acos(sin(radians(b.lat_dec)) * sin(radians(c.lat_dec)) + cos(radians(b.lat_dec)) * cos(radians(c.lat_dec)) * cos(radians(b.long_dec - c.long_dec))))*69, 2) HAVING (distance
</description>
		<content:encoded><![CDATA[<p>Looks like the end of the script has been missed off. Try This:-</p>
<p>SELECT a.Town,a.Postcode,b.lat_dec AS lat1,b.long_dec AS long1,c.lat_dec AS lat2,c.long_dec AS long2,round(degrees(acos(sin(radians(b.lat_dec))* sin(radians(c.lat_dec))+cos(radians(b.lat_dec))* cos(radians(c.lat_dec))*cos(radians(b.long_dec &#8211; c.long_dec))))*69, 2) AS distance FROM postcode_names a,postcode_data b,postcode_data c WHERE c.Postcode = &#8216;NR32&#8242; AND a.Postcode = b.Postcode AND round(degrees(acos(sin(radians(b.lat_dec)) * sin(radians(c.lat_dec)) + cos(radians(b.lat_dec)) * cos(radians(c.lat_dec)) * cos(radians(b.long_dec &#8211; c.long_dec))))*69, 2) HAVING (distance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: win</title>
		<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/comment-page-1#comment-783</link>
		<dc:creator>win</dc:creator>
		<pubDate>Mon, 05 Jul 2004 18:57:37 +0000</pubDate>
		<guid isPermaLink="false">http://sniptools.com/cms/?p=23#comment-783</guid>
		<description>How do you modify above script, if I want to display distance from 1 city to another. Not all.

Having clause is missing from previous post.
I&#039;m having same thing happening. Shows all results, and if I use limit 1 it shows first record info.


</description>
		<content:encoded><![CDATA[<p>How do you modify above script, if I want to display distance from 1 city to another. Not all.</p>
<p>Having clause is missing from previous post.<br />
I&#8217;m having same thing happening. Shows all results, and if I use limit 1 it shows first record info.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stew</title>
		<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/comment-page-1#comment-782</link>
		<dc:creator>Stew</dc:creator>
		<pubDate>Wed, 21 Apr 2004 01:24:11 +0000</pubDate>
		<guid isPermaLink="false">http://sniptools.com/cms/?p=23#comment-782</guid>
		<description>Thats very nice but when I ran the query I got every postcode returned.

I found adding a &#039;HAVING&#039; clause to the query did the trick - viz...

SELECT
a.Town,
a.Postcode,
b.lat_dec AS lat1, b.long_dec AS long1,
c.lat_dec AS lat2, c.long_dec AS long2,
round(degrees(acos(sin(radians(b.lat_dec))
* sin(radians(c.lat_dec))
+ cos(radians(b.lat_dec))
* cos(radians(c.lat_dec))
* cos(radians(b.long_dec - c.long_dec))))*69, 2) AS distance
FROM
postcode_names a, postcode_data b, postcode_data c
WHERE
c.Postcode = &#039;NR32&#039;
AND
a.Postcode = b.Postcode
AND
round(degrees(acos(sin(radians(b.lat_dec))
* sin(radians(c.lat_dec))
+ cos(radians(b.lat_dec))
* cos(radians(c.lat_dec))
* cos(radians(b.long_dec - c.long_dec))))*69, 2)
HAVING (distance
</description>
		<content:encoded><![CDATA[<p>Thats very nice but when I ran the query I got every postcode returned.</p>
<p>I found adding a &#8216;HAVING&#8217; clause to the query did the trick &#8211; viz&#8230;</p>
<p>SELECT<br />
a.Town,<br />
a.Postcode,<br />
b.lat_dec AS lat1, b.long_dec AS long1,<br />
c.lat_dec AS lat2, c.long_dec AS long2,<br />
round(degrees(acos(sin(radians(b.lat_dec))<br />
* sin(radians(c.lat_dec))<br />
+ cos(radians(b.lat_dec))<br />
* cos(radians(c.lat_dec))<br />
* cos(radians(b.long_dec &#8211; c.long_dec))))*69, 2) AS distance<br />
FROM<br />
postcode_names a, postcode_data b, postcode_data c<br />
WHERE<br />
c.Postcode = &#8216;NR32&#8242;<br />
AND<br />
a.Postcode = b.Postcode<br />
AND<br />
round(degrees(acos(sin(radians(b.lat_dec))<br />
* sin(radians(c.lat_dec))<br />
+ cos(radians(b.lat_dec))<br />
* cos(radians(c.lat_dec))<br />
* cos(radians(b.long_dec &#8211; c.long_dec))))*69, 2)<br />
HAVING (distance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wyldie</title>
		<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/comment-page-1#comment-781</link>
		<dc:creator>wyldie</dc:creator>
		<pubDate>Mon, 12 Apr 2004 13:25:25 +0000</pubDate>
		<guid isPermaLink="false">http://sniptools.com/cms/?p=23#comment-781</guid>
		<description>To pull distances from one UK postcode to another use the following SQL dump:-
&lt;a href=&quot;http://www.good-stuff.co.uk/useful/pcodedb.sql.gz&quot; rel=&quot;nofollow&quot;&gt;http://www.good-stuff.co.uk/useful/pcodedb.sql.gz&lt;/a&gt;

Now, presuming you&#039;re using MySQL, use the following converted code to have MySQL do all the math on your behalf.

SELECT
a.Town,
a.Postcode,
b.lat_dec AS lat1,  b.long_dec AS long1,
c.lat_dec AS lat2,  c.long_dec AS long2,
round(degrees(acos(sin(radians(b.lat_dec))
* sin(radians(c.lat_dec))
+ cos(radians(b.lat_dec))
* cos(radians(c.lat_dec))
* cos(radians(b.long_dec - c.long_dec))))*69, 2) AS distance
FROM
postcode_names a, postcode_data b, postcode_data c
WHERE
c.Postcode = &#039;NR32&#039;
AND
a.Postcode = b.Postcode
AND
round(degrees(acos(sin(radians(b.lat_dec))
* sin(radians(c.lat_dec))
+ cos(radians(b.lat_dec))
* cos(radians(c.lat_dec))
* cos(radians(b.long_dec - c.long_dec))))*69, 2)
</description>
		<content:encoded><![CDATA[<p>To pull distances from one UK postcode to another use the following SQL dump:-<br />
<a href="http://www.good-stuff.co.uk/useful/pcodedb.sql.gz" rel="nofollow">http://www.good-stuff.co.uk/useful/pcodedb.sql.gz</a></p>
<p>Now, presuming you&#8217;re using MySQL, use the following converted code to have MySQL do all the math on your behalf.</p>
<p>SELECT<br />
a.Town,<br />
a.Postcode,<br />
b.lat_dec AS lat1,  b.long_dec AS long1,<br />
c.lat_dec AS lat2,  c.long_dec AS long2,<br />
round(degrees(acos(sin(radians(b.lat_dec))<br />
* sin(radians(c.lat_dec))<br />
+ cos(radians(b.lat_dec))<br />
* cos(radians(c.lat_dec))<br />
* cos(radians(b.long_dec &#8211; c.long_dec))))*69, 2) AS distance<br />
FROM<br />
postcode_names a, postcode_data b, postcode_data c<br />
WHERE<br />
c.Postcode = &#8216;NR32&#8242;<br />
AND<br />
a.Postcode = b.Postcode<br />
AND<br />
round(degrees(acos(sin(radians(b.lat_dec))<br />
* sin(radians(c.lat_dec))<br />
+ cos(radians(b.lat_dec))<br />
* cos(radians(c.lat_dec))<br />
* cos(radians(b.long_dec &#8211; c.long_dec))))*69, 2)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sniptools</title>
		<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/comment-page-1#comment-780</link>
		<dc:creator>sniptools</dc:creator>
		<pubDate>Wed, 24 Mar 2004 07:03:45 +0000</pubDate>
		<guid isPermaLink="false">http://sniptools.com/cms/?p=23#comment-780</guid>
		<description>Hi William,

Pls send me your code through email. When PHP throws a last line error, it is usually because a semicolon is missing from somewhere in your code, or perhaps a closing bracket (the &quot;}&quot; character i.e.) for some loop in your code etc.

HTH,
Shanx
</description>
		<content:encoded><![CDATA[<p>Hi William,</p>
<p>Pls send me your code through email. When PHP throws a last line error, it is usually because a semicolon is missing from somewhere in your code, or perhaps a closing bracket (the &#8220;}&#8221; character i.e.) for some loop in your code etc.</p>
<p>HTH,<br />
Shanx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: william</title>
		<link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/comment-page-1#comment-779</link>
		<dc:creator>william</dc:creator>
		<pubDate>Tue, 23 Mar 2004 13:34:49 +0000</pubDate>
		<guid isPermaLink="false">http://sniptools.com/cms/?p=23#comment-779</guid>
		<description>thank you kindly for the code! i&#039;m having a hell of a time making it work though. do you have the full page-code (php included) posted? i used the php from the text field, but somewhere between the variables being sent, and the calculation i get a &quot;parse error&quot; on the last line, which can&#039;t be accurate since the last line is .

thank you,
-Confused
</description>
		<content:encoded><![CDATA[<p>thank you kindly for the code! i&#8217;m having a hell of a time making it work though. do you have the full page-code (php included) posted? i used the php from the text field, but somewhere between the variables being sent, and the calculation i get a &#8220;parse error&#8221; on the last line, which can&#8217;t be accurate since the last line is .</p>
<p>thank you,<br />
-Confused</p>
]]></content:encoded>
	</item>
</channel>
</rss>
