[postgis-users] drawing a line tangent to earth ?

Giuseppe Broccolo g.broccolo.7 at gmail.com
Mon Feb 5 14:16:17 PST 2018


Hi Didier,

2018-02-05 16:08 GMT+01:00 didier peeters <dpeeter1 at ulb.ac.be>:

> Hi,
>
> Here’s the problem that puzzles me:
> 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 … ) .
> 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.


PostGIS allow you to get the angular distance between two objects in the
Earth ellipsoid:

SELECT ST_Distance(ST_GeomFromText('objectA',4326),
ST_GeomFromText('objectB', 4326));

The height (h) of the object B over the ellipsoid is visible from the
object A if

SELECT R_A > (R_B + h) *
cos(ST_Distance(ST_GeomFromText('objectA',4326),
ST_GeomFromText('objectB',4326)));

where R_A and R_B are the radius of the ellipsoid corresponding to objectA
and objectB, respectively.

You can obtain the ellipsoid radius as a function of position over the
ellipsoid knowing the values of the axes
as reported in liblwgeom.h:

#define WGS84_MAJOR_AXIS 6378137.0#define WGS84_INVERSE_FLATTENING
298.257223563#define WGS84_MINOR_AXIS (WGS84_MAJOR_AXIS -
WGS84_MAJOR_AXIS / WGS84_INVERSE_FLATTENING)#define WGS84_RADIUS ((2.0
* WGS84_MAJOR_AXIS + WGS84_MINOR_AXIS ) / 3.0)

That is still an approximation, but more accurate than assimilating the
Earth as a simple trigonometric circle.

Giuseppe.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20180205/e23c003a/attachment.html>


More information about the postgis-users mailing list