grimzy/laravel-mysql-spatial

Numeric value out of range

joppx25 opened this issue · 1 comments

Having problem inserting LineString with createMany method. Model already used spatialTrait and also set the spatialFields property with the target geometry column(locations). Below are the sample codes on how I prepare the data and also insert it.

$boatLocations = [];
        foreach ($requestData as $boatLocationData) {
            if (count($boatLocationData['locations']) > 1) {
                $points = [];
                foreach ($boatLocationData['locations'] as $location) {
                    list($lat, $long) = $location;
                    $points[] = new Point($lat, $long, config('app.srid'));
                }
                $location = new LineString($points, config('app.srid'));
            } else {
                list($lat, $long) = $boatLocationData['locations'];
                $location = new Point($lat, $long, config('app.srid'));
            }

            $boatLocations[] = [
                'reservation_id' => $reservationId,
                'locations'      => $location,
                'speeds'         => json_encode($boatLocationData['speeds']),
                'times'          => json_encode($boatLocationData['times']),
                'created_at'     => Carbon::now()->toDateTimeString(),
            ];
        }

Insertion:

$model->relationModel()->createMany($boatLocations);
// relationModel have the spatialTrait and spatialFields property

hi! have you solved this problem?