public function scanRegion($region_id, $category = false) { if (!$region_id) { // die('Please provide region id'); return false; } if ($category) { $this->active_category = $category; } $Region = \Model_Tracking_Region::find($region_id); if (!$Region) { // die('Region not found'); return false; } // get all tracking points of this location $Points = \Model_Tracking_Point::query()->where('region_id', $region_id)->where('scanned', '!=', 1)->limit(300)->get(); $this->debugMessage('Loaded ' . count($Points) . ' tracking points for region "' . $Region->name . '" from database.'); foreach ($Points as $Point) { // this script is not for updating, just first time adding points, so just skip if scanned once. if ($Point->scanned) { $this->debugMessage('Skipped ' . $Point->lat . ',' . $Point->lng); continue; } $this->searchForLocations($Point->lat, $Point->lng, 200, '', $region_id); // scan complete.. $Point->scanned = 1; $Point->save(); } return true; }
public function post_save_tracking_points() { $locations = \Input::post('locations'); $region_name = \Input::post('region'); $Tracking_Region = \Model_Tracking_Region::query()->where('name', $region_name)->get_one(); if (!$Tracking_Region) { $Tracking_Region = new \Model_Tracking_Region(); $Tracking_Region->lat = $locations[0]['lat']; $Tracking_Region->lng = $locations[0]['lng']; $Tracking_Region->radius = 1; $Tracking_Region->name = $region_name; $Tracking_Region->save(); } foreach ($locations as $location) { $Tracking_Point = new \Model_Tracking_Point(); $Tracking_Point->lat = $location['lat']; $Tracking_Point->lng = $location['lng']; $Tracking_Point->region_id = $Tracking_Region->id; $Tracking_Point->scanned = 0; $Tracking_Point->save(); } return $this->response(array('success' => 1)); }