21 lines
		
	
	
		
			716 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			716 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
use SokoWeb\Database\Query\Modify;
 | 
						|
use SokoWeb\Database\Query\Select;
 | 
						|
use SokoWeb\Interfaces\Database\IResultSet;
 | 
						|
use MapGuesser\Util\Geo\Bounds;
 | 
						|
 | 
						|
$select = new Select(\Container::$dbConnection, 'maps');
 | 
						|
$select->columns(['id', 'bound_south_lat', 'bound_west_lng', 'bound_north_lat', 'bound_east_lng']);
 | 
						|
 | 
						|
$result = $select->execute();
 | 
						|
 | 
						|
while ($map = $result->fetch(IResultSet::FETCH_ASSOC)) {
 | 
						|
    $bounds = Bounds::createDirectly($map['bound_south_lat'], $map['bound_west_lng'], $map['bound_north_lat'], $map['bound_east_lng']);
 | 
						|
 | 
						|
    $modify = new Modify(\Container::$dbConnection, 'maps');
 | 
						|
    $modify->setId($map['id']);
 | 
						|
    $modify->set('area', $bounds->calculateApproximateArea());
 | 
						|
    $modify->save();
 | 
						|
}
 |