Skip to content

Instantly share code, notes, and snippets.

@fernandolopes
Created September 21, 2011 18:49
Show Gist options
  • Select an option

  • Save fernandolopes/1232959 to your computer and use it in GitHub Desktop.

Select an option

Save fernandolopes/1232959 to your computer and use it in GitHub Desktop.
SELECT imoveis.id, imoveis.latitude, imoveis.longitude,
imoveis.area_privativa, imoveis.area_terreno,
imovel_naturezas.descricao AS imovel_natureza,
tipo_operacoes.descricao AS tipo_operacao
FROM imoveis
JOIN imovel_naturezas ON imovel_naturezas.id = imoveis.imovel_natureza_id
JOIN tipo_operacoes ON tipo_operacoes.id = imoveis.tipo_operacao_id
WHERE
ACOS( COS( RADIANS( latitude ) ) *
COS( RADIANS( $lat )) *
COS( RADIANS( longitude ) -
RADIANS( $lng )) +
SIN( RADIANS( latitude ) ) *
SIN( RADIANS( $lat ) ) ) *
6380 < 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment