Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Let SpatialExpression implement the toWkt() method#135

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
vpratfr wants to merge1 commit intogrimzy:master
base:master
Choose a base branch
Loading
fromvpratfr:patch-1

Conversation

vpratfr
Copy link

@vpratfrvpratfr commentedApr 6, 2020
edited
Loading

This avoids that most spatial query functions fail when invoked from observer methods.

E.g.

Test setup

    $incomingMessage = new RawMessage();    $incomingMessage->beacon_id = $boat->beacon_id;    $incomingMessage->boat_id = $boat->id;    $incomingMessage->timestamp = CarbonImmutable::now();    $incomingMessage->type = MessageType::LOCATION_UPDATE();    $incomingMessage->location_precision = 5;    $incomingMessage->coordinates = new Point(5, 5);    $incomingMessage->save();

Observer on RawMessage created() event

    $weatherAlerts = WeatherAlert::ongoing()        ->atLocation($rawMessage->coordinates)        ->get();

Crash

Error : Call to undefined method Grimzy\LaravelMysqlSpatial\Eloquent\SpatialExpression::toWkt()

Basically, in the observer, when doing->atLocation($rawMessage->coordinates), the coordinates getter returns a SpatialExpression and not the original Point

This PR simply implements the toWkt method, in a harmless and perfectly safe way as it does the same thing as the existing getSpatialValue method

Fixes#115

YannickYayo, limenet, and BrandonSurowiec reacted with thumbs up emoji
@vpratfr
Copy link
Author

I did not add any test as SpatialExpression does not have any of them and the code is very straightforward.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Getting things to work in eloquent observer methods?
1 participant
@vpratfr

[8]ページ先頭

©2009-2025 Movatter.jp