Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SEDONA-281] Support geodesic / geography functions #835

Merged
merged 7 commits into from
May 20, 2023

Conversation

jiayuasu
Copy link
Member

@jiayuasu jiayuasu commented May 20, 2023

Did you read the Contributor Guide?

Is this PR related to a JIRA ticket?

What changes were proposed in this PR?

ST_AreaSpheroid

Return the geodesic area of A using WGS84 spheroid. Unit is square meter. Works better for large geometries (country level) compared to ST_Area + ST_Transform. It is equivalent to PostGIS ST_Area(geography, use_spheroid=true) function and produces nearly identical results.

ST_LengthSpheroid

Return the geodesic perimeter of A using WGS84 spheroid. Unit is meter. Works better for large geometries (country level) compared to ST_Length + ST_Transform. It is equivalent to PostGIS ST_Length(geography, use_spheroid=true) and ST_LengthSpheroid function and produces nearly identical results.

ST_DistanceSphere

Return the haversine / great-circle distance of A using a given earth radius (default radius: 6378137.0). Unit is meter. Works better for large geometries (country level) compared to ST_Distance + ST_Transform. It is equivalent to PostGIS ST_Distance(geography, use_spheroid=false) and ST_DistanceSphere function and produces nearly identical results. It provides faster but less accurate result compared to ST_DistanceSpheroid.

ST_DistanceSpheroid

Return the geodesic distance of A using WGS84 spheroid. Unit is meter. Works better for large geometries (country level) compared to ST_Distance + ST_Transform. It is equivalent to PostGIS ST_Distance(geography, use_spheroid=true) and ST_DistanceSpheroid function and produces nearly identical results. It provides slower but more accurate result compared to ST_DistanceSphere.

How was this patch tested?

Added many unit tests.

Did this PR include necessary documentation updates?

@jiayuasu jiayuasu merged commit 23f1b80 into master May 20, 2023
39 checks passed
@jiayuasu jiayuasu deleted the geodestic-distance branch May 20, 2023 16:35
// The radius of the earth is 6371.0 km
public static double distance(Geometry geom1, Geometry geom2)
{
return distance(geom1, geom2, 6378137.0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using 6371008 as the default radius according to PostGIS ST_DistanceSphere and https://en.wikipedia.org/wiki/Earth_radius

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants