<div dir="ltr">Hi Didier,<br><div><div class="gmail_extra"><br><div class="gmail_quote">2018-02-05 16:08 GMT+01:00 didier peeters <span dir="ltr"><<a href="mailto:dpeeter1@ulb.ac.be" target="_blank">dpeeter1@ulb.ac.be</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Here’s the problem that puzzles me:<br>
I would like to determine if an object (a building,  an antenna, …) can be seen from a specific point ‘somewhere'.  I have to deal with distances ranging from a few meters to about 200 km or so.  I have the coordinates of the viewing point XYZ and the XYZ coordinates of the object to check as well as its height, and I should find what part of the object is viewable above the horizon, i.e. how many meters of it can be seen (considering that the earth is not flat … ) .<br>
I thought of assimilating the earth to a trigonometric circle but I fear that the precision would not be good enough for evaluating the height of an antenna above the radius of the planet.</blockquote></div><br></div><div class="gmail_extra">PostGIS allow you to get the angular distance between two objects in the Earth ellipsoid:<br></div><div class="gmail_extra"><pre class="gmail-programlisting">SELECT ST_Distance(ST_GeomFromText('objectA',4326), ST_GeomFromText('objectB', 4326));</pre>The height (h) of the object B over the ellipsoid is visible from the object A if<br><pre class="gmail-programlisting">SELECT R_A > (R_B + h) * cos(ST_Distance(ST_GeomFromText('objectA',4326), ST_GeomFromText('objectB',4326)));</pre>where R_A and R_B are the radius of the ellipsoid corresponding to objectA and objectB, respectively.<br><br></div><div class="gmail_extra">You can obtain the ellipsoid radius as a function of position over the ellipsoid knowing the values of the axes<br></div><div class="gmail_extra">as reported in liblwgeom.h:<br><pre class="gmail-lang-sql gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pun">#</span><span class="gmail-pln">define WGS84_MAJOR_AXIS </span><span class="gmail-lit">6378137.0</span><span class="gmail-pln">
</span><span class="gmail-pun">#</span><span class="gmail-pln">define WGS84_INVERSE_FLATTENING </span><span class="gmail-lit">298.257223563</span><span class="gmail-pln">
</span><span class="gmail-pun">#</span><span class="gmail-pln">define WGS84_MINOR_AXIS </span><span class="gmail-pun">(</span><span class="gmail-pln">WGS84_MAJOR_AXIS </span><span class="gmail-pun">-</span><span class="gmail-pln"> WGS84_MAJOR_AXIS </span><span class="gmail-pun">/</span><span class="gmail-pln"> WGS84_INVERSE_FLATTENING</span><span class="gmail-pun">)</span><span class="gmail-pln">
</span><span class="gmail-pun">#</span><span class="gmail-pln">define WGS84_RADIUS </span><span class="gmail-pun">((</span><span class="gmail-lit">2.0</span><span class="gmail-pln"> </span><span class="gmail-pun">*</span><span class="gmail-pln"> WGS84_MAJOR_AXIS </span><span class="gmail-pun">+</span><span class="gmail-pln"> WGS84_MINOR_AXIS </span><span class="gmail-pun">)</span><span class="gmail-pln"> </span><span class="gmail-pun">/</span><span class="gmail-pln"> </span><span class="gmail-lit">3.0</span><span class="gmail-pun">)</span></code></pre>That is still an approximation, but more accurate than assimilating the Earth as a simple trigonometric circle.<br><br></div><div class="gmail_extra">Giuseppe.<br></div></div></div>