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

ENH: Added length and perimeter implementation #77

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

JoelJaeschke
Copy link
Contributor

No description provided.

Copy link
Collaborator

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks!

What's broken about the perimeter?

@JoelJaeschke
Copy link
Contributor Author

I am still getting used to thinking in spherical geometries. The test case I wrote for the perimeter function used a polygon that was rectangular in my head, so I expected its perimeter to be $4\pi / 180°$. However, not only this assumption was wrong (as angular distances between two points with the same latitude at higher latitudes are smaller than those near the equator), but I also did not take into account that all points at the poles are actually coincident, so my result was $3\pi/180°$ which I assumed to be some sort of bug.

Sorry for the confusion, everything was fine from the start!

@JoelJaeschke JoelJaeschke marked this pull request as ready for review November 19, 2024 21:37
@JoelJaeschke JoelJaeschke changed the title Added length and (broken) perimeter implementation ENH: Added length and perimeter implementation Nov 19, 2024
Copy link
Collaborator

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Looks good!

Do you just want to add it to api.rst as well?

Copy link
Owner

@benbovy benbovy left a comment

Choose a reason for hiding this comment

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

Thanks @JoelJaeschke!

One question about the API: should we follow BigQuery's API or shapely's API? Or a mix of both? Some options:

  1. Expose separate length and perimeter functions, with value zero returned for "incompatible" geography (like BigQuery, currently implemented in this PR)
  2. Expose a unique length function (like Shapely)
  3. Expose length and perimeter functions where length also returns the perimeter for an input Polygon.

@benbovy
Copy link
Owner

benbovy commented Nov 25, 2024

One question about the API: should we follow BigQuery's API or shapely's API? Or a mix of both?

Any thoughts on this @jorisvandenbossche?

@jorisvandenbossche
Copy link
Collaborator

I think I like option 3: we provide a length that can handle both, and then still a perimeter for discoverability for people familiar with other systems like bigquery or postgis (and also perimeter is a more descriptive name in case of polygons).

(we should maybe consider adding a perimeter() in shapely as well)

I am also fine with leaving that for a follow-up, though, either way is fine.

@JoelJaeschke
Copy link
Contributor Author

I would be happy to change the PR accordingly if option 3 is the way forward!

Copy link
Owner

@benbovy benbovy left a comment

Choose a reason for hiding this comment

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

Let's choose the easy way and leave length and perimeter as it is in this PR for now.

Thanks @JoelJaeschke !

@benbovy benbovy merged commit 8e2d481 into benbovy:main Nov 26, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants