Geographic coordinates in PostgreSQL query
<p>There are two fields in the database table, <strong>latitude</strong> and <strong>longitude</strong>. (Other fields too, but they are not important now.)</p>

<p>I have a function, where are three parameters: <strong>latitude</strong>, <strong>longitude</strong> and <strong>max_distance</strong> (km).</p>

<p>Is there any way to construct raw PostgreSQL query that returns only the rows that represent location which is within that <strong>max_distance</strong> (km) measured from given latitude and longitude?</p>

<p>Example parameters latitude=59.9138699, longitude=10.7522451, max_distance=10</p>