app/Containers/Geo/Tasks/CreatePolygonTask.php
/**
     * @param GeometryInterface $polygon
     * @return mixed
     * @throws Exception
     */
@param GeometryInterface $polygon
@return mixed
@throws Exception
@param GeometryInterface $polygon @return mixed @throws Exception
public function run(GeometryInterface $polygon)
    {
        try {
            if ($polygon instanceof Polygon) $polygon = new MultiPolygon([$polygon]);
            if ($polygon instanceof MultiPolygon) {
                $entity = $this->repository->create([
                    'polygon' => $polygon,
                ]);
                $model = $this->repository->model();
                $polygon = $model::find($entity->id);
                $polygon->update([
                    'area_m2' => $polygon->calculated_area,
                ]);
                return $polygon;
            }
            else throw new Exception("Geometry must be instance of Polygon or Multipolygon.");
        }
        catch (Exception $exception) {
            throw $exception;
        }
    }
public function run ( GeometryInterface $ polygon ) { try { if ( $ polygon instanceof Polygon ) $ polygon = new MultiPolygon ( [ $ polygon ] ) ; if ( $ polygon instanceof MultiPolygon ) { $ entity = $ this -> repository -> create ( [ 'polygon' => $ polygon , ] ) ; $ model = $ this -> repository -> model ( ) ; $ polygon = $ model :: find ( $ entity -> id ) ; $ polygon -> update ( [ 'area_m2' => $ polygon -> calculated_area , ] ) ; return $ polygon ; } else throw new Exception ( " Geometry must be instance of Polygon or Multipolygon. " ) ; } catch ( Exception $ exception ) { throw $ exception ; } }
@param GeometryInterface $polygon
 @return mixed
 @throws Exception
@param GeometryInterface $polygon @return mixed @throws Exception
//area