clickbar / laravel-magellan

A modern PostGIS toolbox for Laravel
MIT License
203 stars 12 forks source link

Error when using ST::transform(): could not parse proj string '4326' #91

Open saibotk opened 3 months ago

saibotk commented 3 months ago

Discussed in https://github.com/clickbar/laravel-magellan/discussions/90

Originally posted by **BezBIS** June 17, 2024 I am getting an error when trying to pass a srid to `ST::transform()` as part of a select statement. A minimal example is: ``` $geom = Site::stSelect(ST::transform('geom', 4326))->first(); ``` and the error is ``` SQLSTATE[XX000]: Internal error: 7 ERROR: could not parse proj string '4326' CONTEXT: SQL function "st_transform" statement 1 ``` Running the generated query through pgAdmin works correctly, as does using `selectRaw`. I want to avoid selectRaw, however, as I want to get the extent of the transformed geometry as a Box2D: ``` $bounds = Site::stSelect(ST::extent( ST::transform('geom', 4326) )) ->where('id', '=', $search->params['site']) ->first(); ``` As I'm fairly new to the library, it's entirely possible I'm missing something. That being the case, I thought I would ask fr help as a discussion before opening a bug report.

Raw SQL seems to be correct, we need to dive deeper to see what is actually send to the DB etc.