123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- namespace App\BO;
- use App\Models\Enums\BimFileModelType;
- use Ramsey\Uuid\Uuid;
- class BimFileBO
- {
- public string $name;
- public string $initiatingUser;
- public string $extension;
- public bool $isCAD;
- public string $uniqueCode;
- public int $priority;
- public string $modelDownloadUrl;
- public array $pointCloudConfigJson;
- public string $modelType;
- public string $gisType;
- public array $configJson;
- public function __construct(
- string $extension,
- string $name,
- string $initiatingUser = '',
- string $gisType = '',
- int $priority = 205,
- string $modelDownloadUrl = ''
- ) {
- $this->extension = $extension;
- $this->name = $name;
- $this->initiatingUser = $initiatingUser;
- $this->isCAD = in_array($this->extension, ['dwg', 'dwf', 'dws', 'dwt']);
- $this->uniqueCode = Uuid::uuid4();
- $this->priority = $priority;
- $this->modelDownloadUrl = $modelDownloadUrl;
- $this->gisType = $gisType;
- $this->configJson = [];
-
- $this->modelType = $this->guessModelType();
- }
- private function guessModelType(): string
- {
- if ($this->isCAD) {
- return BimFileModelType::CAD->value;
- }
- if (in_array($this->extension, config('bim.extensions'))) {
- return BimFileModelType::BIM->value;
- }
- if (in_array($this->extension, config('bim.gis_extensions')) || !empty($this->gisType)) {
- return BimFileModelType::GIS->value;
- }
- return '';
- }
-
- public function setPointCloudConfigJson(array $pointCloudConfig)
- {
-
- if (isset($pointCloudConfig['srs'])) {
- $this->pointCloudConfigJson['srs'] = $pointCloudConfig['srs'];
- }
-
- if (isset($pointCloudConfig['origin'])) {
- $this->pointCloudConfigJson['origin'] = $pointCloudConfig['origin'];
- }
-
- if (isset($pointCloudConfig['longitude'])) {
- $this->pointCloudConfigJson['longitude'] = $pointCloudConfig['longitude'];
- }
-
- if (isset($pointCloudConfig['latitude'])) {
- $this->pointCloudConfigJson['latitude'] = $pointCloudConfig['latitude'];
- }
-
- if (isset($pointCloudConfig['height'])) {
- $this->pointCloudConfigJson['height'] = $pointCloudConfig['height'];
- }
- }
- public function setConfigJson($config)
- {
- if (empty($config)) {
- return;
- }
- $fields = array_keys(self::configJsonRules());
- foreach ($config as $key => $value) {
- if (in_array($key, $fields)) {
- $this->configJson[$key] = $config[$key];
- }
- }
- }
- public static function configJsonRules()
- {
- return [
- "style" => 'in:0,1',
- "zGrid" => 'in:0,1',
- "viewStyle" => 'in:0,1',
- "drawing" => 'in:0,1',
- "accuracy" => 'in:1,2,3,4,5,6,7,8,9,10',
-
-
- "isLod" => 'in:0,1',
- "srs" => '',
- "type" => 'in:2,4',
- "offsetX" => 'numeric',
- "offsetY" => 'numeric',
- "offsetZ" => 'numeric',
- ];
- }
- }
|