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.
Code:
select gn1.name as nome_local, gn1.latitude, gn1.longitude, cr.geonames_name as Distrito,
ACOS(SIN(38.66667)*SIN(gn1.latitude)+COS(38.66667)*COS(gn1.latitude)*COS(gn1.longitude-(-9.06667)))*6371 as D
from geoname gn1
join country_regions cr on cr.code = gn1.country || '.' || gn1.admin1
where
gn1.country = 'PT'
--and lower(gn1.name) = 'moita'
and ACOS(SIN(38.66667)*SIN(gn1.latitude)+COS(38.66667)*COS(gn1.latitude)*COS(gn1.longitude-(-9.06667)))*6371 < 300
order by D
The 300 is mt, kms or other?
Sorry for my bad english.