<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Steve and Giuseppe,</div><div class=""><br class=""></div><div class="">thank you for these leads that seem both very interesting.  I will try them now.</div><div class=""><br class=""></div><div class="">Didier</div><br class=""><div><blockquote type="cite" class=""><div class="">Le 5 févr. 2018 à 23:16, Giuseppe Broccolo <<a href="mailto:g.broccolo.7@gmail.com" class="">g.broccolo.7@gmail.com</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Didier,<br class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2018-02-05 16:08 GMT+01:00 didier peeters <span dir="ltr" class=""><<a href="mailto:dpeeter1@ulb.ac.be" target="_blank" class="">dpeeter1@ulb.ac.be</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br class="">
<br class="">
Here’s the problem that puzzles me:<br class="">
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 class="">
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 class=""></div><div class="gmail_extra">PostGIS allow you to get the angular distance between two objects in the Earth ellipsoid:<br class=""></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 class=""><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 class=""><br class=""></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 class=""></div><div class="gmail_extra">as reported in liblwgeom.h:<br class=""><pre class="gmail-lang-sql gmail-prettyprint gmail-prettyprinted"><code class=""><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 class=""><br class=""></div><div class="gmail_extra">Giuseppe.<br class=""></div></div></div>
_______________________________________________<br class="">postgis-users mailing list<br class=""><a href="mailto:postgis-users@lists.osgeo.org" class="">postgis-users@lists.osgeo.org</a><br class="">https://lists.osgeo.org/mailman/listinfo/postgis-users</div></blockquote></div><br class=""></body></html>