Find which Polygon a Point belongs to #131
Unanswered
codemountain
asked this question in
Q&A
Replies: 1 comment
-
Hey sorry this took so long. Yes you can use ST_Contains for this. See https://postgis.net/docs/ST_Contains.html Something along the lines of ServiceArea::stWhere(ST::contains('area_colum_name', $userLocationPoint))->first(); Does that solve your question? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, starting to test the package and very cool.
We have areas (polygon GeoJson data) stored in a ServiceArea model.
When someone submits a form, we get there GeoLocation from which i can create a Point.
I'm not sure how to proceed to write the query that would find which ServiceArea record that Point would be in. No plans to have overlapping ServiceArea if that is a concern.
I think there must be a query that is more efficient then looping thru all records one by one in a foreach loop and check if point is in that polygon/area ?
Thank you for any insight.
Beta Was this translation helpful? Give feedback.
All reactions