Drawing a bézier curve over the equator

Viewed 64

I'm attempting to draw a very long line from one point to another. ST_Project seems to give me the correct point to draw to, but when I use ST_MakeLine the line doesn't move east immediately from my starting point, and as such doesn't create the bézier curve I'd be expecting, but rather an arch.

In Google Maps if you draw a line using their measuring tool travelling 90° from the starting point, then it creates the expected bézier curve:

Measuring

Whereas if I export my line to KML and import it into Google Maps, the line is more of an arch:

KML

I'm using the following SQL to create my points and draw the two lines:

SELECT
ST_AsKML(
    ST_Transform(
        ST_Segmentize(
            ST_MakeLine(
                ST_Transform(
                    ST_SetSRID(ST_MakePoint(-0.3856949, 51.6443612), 4326),
                    953027
                ),
                ST_Transform(
                    ST_SetSRID(
                        ST_AsText(
                            ST_Project(
                                ST_MakePoint(-0.3856949, 51.6443612),
                                2.00151e+07,
                                radians(90.0)
                            )
                        ),
                        4326
                    ),
                    953027
                )
            ),
            100000
        ),
        4326
    )
);
1 Answers

I think I've answered my own question by using explicit geometry types and NOT using ST_Segmentize as that function exists to create great circle arcs, which in this case is not what I wanted. As far as I understand it, great circle arcs are the shortest distances, such as aviation routes.

Using the below code I can create the bézier curves seen on Google Maps measuring tool:

SELECT
    name,
    ST_Distance(
        ST_SetSRID(ST_MakePoint(0.1278, 51.5074), 4326),
        area
    ) AS distance
FROM
    countries
WHERE
    (
        ST_Intersects(
            area,
            ST_SetSRID(
                ST_MakeLine(
                    ST_SetSRID(ST_MakePoint(0.1278, 51.5074), 4326) :: geometry,
                    ST_Project(
                        ST_SetSRID(ST_MakePoint(0.1278, 51.5074), 4326) :: geometry,
                        2.00151e+07,
                        pi() * 90 / 180.0
                    ) :: geometry
                ),
                4326
            )
        )
    )
ORDER BY
    ST_Distance(
        ST_SetSRID(ST_MakePoint(0.1278, 51.5074), 4326),
        area
    );
Related