文件
chengduzhongchuliang/application/common/library/GranaryScreen.php

33 行
1.3 KiB
PHP

<?php
namespace app\common\library;
/** 建筑位置独立于仓号,修改仓号不会移动大屏标记。 */
class GranaryScreen
{
public static function extraPositions()
{
return [
'center_upper_left' => ['x' => 46.8, 'y' => 28.4],
'center_lower_right' => ['x' => 58.8, 'y' => 34.1],
];
}
public static function resolve($item, $coords)
{
$content = is_array($item['content']) ? $item['content'] : json_decode($item['content'], true);
$position = isset($content['screenPosition']) ? $content['screenPosition'] : '';
$extra = self::extraPositions();
if (isset($extra[$position])) {
return $extra[$position];
}
// 历史记录按数据库 id 锚定原建筑,避免改号后套用另一栋仓库的位置。
$originalNumbers = [27 => 30, 29 => 31, 30 => 32, 31 => 10, 33 => 42,
34 => 33, 36 => 35, 37 => 36, 38 => 12, 39 => 39, 40 => 40,
42 => 41, 43 => 14, 44 => 37, 45 => 15, 46 => 44, 47 => 16,
48 => 17, 49 => 18, 50 => 38, 51 => 43];
$num = isset($originalNumbers[$item['id']]) ? $originalNumbers[$item['id']] : null;
return $num !== null && isset($coords[$num]) ? $coords[$num] : null;
}
}