Browse Source

Merge pull request 'staging' (#138) from staging into master

Reviewed-on: ordo/adw-backend#138
pull/3/head
ibnu 1 year ago
parent
commit
d4d1f88115
  1. 11
      app/Http/Controllers/PresenceController.php

11
app/Http/Controllers/PresenceController.php

@ -263,11 +263,10 @@ class PresenceController extends Controller
foreach($geom as $dataGeom){
$valGeom = json_decode($dataGeom->geom);
if($params->clock_in_out['type']=="out"){
if($valGeom->type == "FeatureCollection"){
// return count($valGeom->features);
if($valGeom->type == "FeatureCollection"){
$multiArea = $valGeom->features;
foreach($multiArea as $area){
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'),
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary"));
if($check[0]->boundary){
break;
@ -278,8 +277,7 @@ class PresenceController extends Controller
ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary"));
}
}else{
if($valGeom->type == "FeatureCollection"){
// return count($valGeom->features);
if($valGeom->type == "FeatureCollection"){
$multiArea = $valGeom->features;
foreach($multiArea as $area){
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'),
@ -338,6 +336,7 @@ class PresenceController extends Controller
->whereDate("ma.end_date", ">=", $params->time)
->get();
$temp = [];
// return json_encode($geom);
if (count($geom) > 0) {
foreach($geom as $dataGeom){
$valGeom = json_decode($dataGeom->geom);
@ -346,7 +345,7 @@ class PresenceController extends Controller
// return count($valGeom->features);
$multiArea = $valGeom->features;
foreach($multiArea as $area){
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'),
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary"));
if($check[0]->boundary){
break;

Loading…
Cancel
Save