<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "SQL to calculate the closest Locations. It is correct?"]]></title>
		<link>http://forum.geonames.org/gforum/posts/list/4.page</link>
		<description><![CDATA[Latest messages posted in the topic "SQL to calculate the closest Locations. It is correct?"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>SQL to calculate the closest Locations. It is correct?</title>
				<description><![CDATA[ Hi,

I need to calculate the closest locations, but I don't know if the database query is OK. It seems that some Locations are incorrect, but could be invalid dat in the database.

<span class="genmed"><b>Code:</b></span><br>
		<div style="overflow: auto; width: 100%;">
		<pre>
select gn1.name as nome_local, gn1.latitude, gn1.longitude, cr.geonames_name as Distrito,
ACOS&#40;SIN&#40;38.66667&#41;*SIN&#40;gn1.latitude&#41;+COS&#40;38.66667&#41;*COS&#40;gn1.latitude&#41;*COS&#40;gn1.longitude-&#40;-9.06667&#41;&#41;&#41;*6371 as D
from geoname gn1
join country_regions cr on cr.code = gn1.country || '.' || gn1.admin1
where
gn1.country = 'PT'
--and lower&#40;gn1.name&#41; = 'moita'
and ACOS&#40;SIN&#40;38.66667&#41;*SIN&#40;gn1.latitude&#41;+COS&#40;38.66667&#41;*COS&#40;gn1.latitude&#41;*COS&#40;gn1.longitude-&#40;-9.06667&#41;&#41;&#41;*6371 &lt; 300
order by D
</pre>
		</div>

The 300 is mt, kms or other?

Sorry for my bad english.]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/list/2000.page#8129</guid>
				<link>http://forum.geonames.org/gforum/posts/list/2000.page#8129</link>
				<pubDate><![CDATA[Wed, 28 Jul 2010 16:22:22]]> GMT</pubDate>
				<author><![CDATA[ lopes_andre]]></author>
			</item>
	</channel>
</rss>