convert Srid 4326 to 3857 #102
Unanswered
DavidGuillerm
asked this question in
Q&A
Replies: 1 comment
-
Sorry for the late reply! ST functions need to be used in a query builder within our st prefixed functions e.g.: $currentShipPosition = Point::makeGeodetic(50.107471773560114, 8.679861151457937);
$portsWithDistance = Port::select()
->stSelect(ST::distanceSphere($currentShipPosition, 'location'), as: 'distance_to_ship')
->stWhere(ST::distanceSphere($currentShipPosition, 'location'), '<=', 50000)
->stOrderBy(ST::distanceSphere($currentShipPosition, 'location'))
->get(); Either you do so on a model or if you do not want to store the data, you can still leverage the DB to transform the Point: $point4326 = Point::make($x, $y, 4326);
$wkbParser = App::make(WKBParser::class);
$result = DB::query()
->stSelect(ST::transform($point, 3857))
->first()->transform;
$point3857 = $wkbParser->parse($result); |
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.
-
Hi All,
I'm using an accessor function in laravel which goal is to return coordinates in 3857 SRID. My points are stored in database in SRID 4326
I 'm trying a lot of thing, such as
but I didn't success ...
My function should return an object like this :
Any ideas ?
Thanks
Regards
David
Beta Was this translation helpful? Give feedback.
All reactions