Skip to content

Locations within bounds #51

Answered by ahawlitschek
RizaHKhan asked this question in Q&A
Discussion options

You must be logged in to vote

We just released a new update which allows using Box2D and Box3D as params for MagellanExpressions.
So you can now do the following:

Address::stWhere(ST::contains(Box2D::make(1,1,1,1), 'geometry'))->get();

Depending on the SRID set in the Database, this can lead to an Database Error.
e.g.

If your point in the database has SRID=4326:
Internal error: 7 ERROR: contains: Operation on mixed SRID geometries (Point, 0) != (Point, 4326)

This can be avoided by setting an SRID:

Address::stWhere(
   ST::contains(
      ST::setSRID(Box2D::make(1, 1, 1, 1), 4326),
      'geometry'
   )
)->get();

Note
In your case using contains is totally fine, because you just want to check if a point is fully insi…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@saibotk
Comment options

Comment options

You must be logged in to vote
1 reply
@RizaHKhan
Comment options

Answer selected by saibotk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants