Skip to content

Is pole point inside - #510

Merged
philipc2 merged 16 commits into
UXARRAY:mainfrom
hongyuchen1030:is_pole_point_inside
Oct 17, 2023
Merged

philipc2 merged 16 commits into
UXARRAY:mainfrom
hongyuchen1030:is_pole_point_inside

Conversation

@hongyuchen1030

@hongyuchen1030 hongyuchen1030 commented Oct 12, 2023 •

Copy link
Copy Markdown
Contributor

Closes #486

Overview

  • Added a new utility function _is_pole_point_inside_polygon to determine if a pole point is inside a polygon.
  • The function raises a ValueError if the pole is neither 'North' nor 'South'.
  • This function works for any face as long as it's within a hemisphere
  • A warning is issued : To use this function, the given face cannot reach out the other hemisphere. For example, if you
    want to check if the North pole is inside a polygon, the polygon should not reach the south hemisphere.

Expected Usage

# This function is part of the internal API, so it's primarily for internal use within the library.

# Example of how the function might be used:

pole = 'North'
face_edge_cart = ... # some numpy array representation
result = _is_pole_point_inside_polygon(pole, face_edge_cart)

PR Checklist

General

  • An issue is linked created and linked
  • Add appropriate labels
  • Filled out Overview and Expected Usage (if applicable) sections

Testing

  • Adequate tests are created if there is new functionality
  • Tests cover all possible logical paths in your function
  • Tests are not too basic (such as simply calling a function and nothing else)

Documentation

  • Docstrings have been added to all new functions
  • Docstrings have updated with any function changes
  • Internal functions have a preceding underscore (_) and have been added to docs/internal_api/index.rst
  • User functions have been added to docs/user_api/index.rst

@hongyuchen1030 hongyuchen1030 added the new feature New user-facing functionality label Oct 12, 2023
@hongyuchen1030 hongyuchen1030 added this to the Lat Lon Box Bounding milestone Oct 12, 2023
@hongyuchen1030 hongyuchen1030 self-assigned this Oct 12, 2023
Comment thread uxarray/grid/geometry.py Resolved
Comment thread uxarray/grid/geometry.py Resolved
@philipc2

Copy link
Copy Markdown
Member

For this implementation, do we consider the case where one of the corners of our face is either pole point?

@hongyuchen1030

Copy link
Copy Markdown
Contributor Author

For this implementation, do we consider the case where one of the corners of our face is either pole point?

Good catch. So technically "one of the corners of our face is pole point" means the pole point is not inside the polygon. But for our next step, we do want to specify this issue. So I am not so sure about how to handle this case.

We have two choices

  1. Let this function be strictly "if pole point inside", and for the next step we will manually check if one corner of the face is the pole point

  2. Make this function a little bit "relax", if the query point, in our case, the pole point is on the edge, we still consider it as "inside" the polygon.

I wonder what's your opinion about it.

@hongyuchen1030

Copy link
Copy Markdown
Contributor Author

For this implementation, do we consider the case where one of the corners of our face is either pole point?

Good catch. So technically "one of the corners of our face is pole point" means the pole point is not inside the polygon. But for our next step, we do want to specify this issue. So I am not so sure about how to handle this case.

We have two choices

  1. Let this function be strictly "if pole point inside", and for the next step we will manually check if one corner of the face is the pole point
  2. Make this function a little bit "relax", if the query point, in our case, the pole point is on the edge, we still consider it as "inside" the polygon.

I wonder what's your opinion about it.

After thinking about it, probably the second "relax" solution is more suitable

@philipc2

Copy link
Copy Markdown
Member

For this implementation, do we consider the case where one of the corners of our face is either pole point?

Good catch. So technically "one of the corners of our face is pole point" means the pole point is not inside the polygon. But for our next step, we do want to specify this issue. So I am not so sure about how to handle this case.
We have two choices

  1. Let this function be strictly "if pole point inside", and for the next step we will manually check if one corner of the face is the pole point
  2. Make this function a little bit "relax", if the query point, in our case, the pole point is on the edge, we still consider it as "inside" the polygon.

I wonder what's your opinion about it.

After thinking about it, probably the second "relax" solution is more suitable

I'm fine with either approach, we could add a parameter that switches between having the point strictly within or to include the case where it's one of the edge nodes.

@philipc2 philipc2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A couple small suggestions! looking good!

Comment thread uxarray/grid/geometry.py Resolved
Comment thread uxarray/grid/geometry.py Resolved
@hongyuchen1030
hongyuchen1030 marked this pull request as draft October 14, 2023 01:47
@hongyuchen1030
hongyuchen1030 marked this pull request as ready for review October 17, 2023 03:52

@philipc2 philipc2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looking good, once we get the tests passing I think it should be ready to merge.

Comment thread uxarray/grid/geometry.py Resolved
Comment thread uxarray/grid/geometry.py Resolved
@philipc2
philipc2 merged commit 61a6095 into UXARRAY:main Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New user-facing functionality

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Detect if the pole point is inside a polygon that's in a hemisphere

3 participants