BimFileBO.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. namespace App\BO;
  3. use App\Models\Enums\BimFileModelType;
  4. use Ramsey\Uuid\Uuid;
  5. class BimFileBO
  6. {
  7. public string $name;
  8. public string $initiatingUser;
  9. public string $extension;
  10. public bool $isCAD;
  11. public string $uniqueCode;
  12. public int $priority;
  13. public string $modelDownloadUrl;
  14. public array $pointCloudConfigJson;
  15. public string $modelType;
  16. public string $gisType;
  17. public array $configJson; //轻量化配置
  18. public function __construct(
  19. string $extension,
  20. string $name,
  21. string $initiatingUser = '',
  22. string $gisType = '',
  23. int $priority = 205,
  24. string $modelDownloadUrl = ''
  25. ) {
  26. $this->extension = $extension;
  27. $this->name = $name;
  28. $this->initiatingUser = $initiatingUser;
  29. $this->isCAD = in_array($this->extension, ['dwg', 'dwf', 'dws', 'dwt']);
  30. $this->uniqueCode = Uuid::uuid4();
  31. $this->priority = $priority;
  32. $this->modelDownloadUrl = $modelDownloadUrl;
  33. $this->gisType = $gisType;
  34. $this->configJson = [];
  35. $this->modelType = $this->guessModelType();
  36. }
  37. private function guessModelType(): string
  38. {
  39. if ($this->isCAD) {
  40. return BimFileModelType::CAD->value;
  41. }
  42. if (in_array($this->extension, config('bim.extensions'))) {
  43. return BimFileModelType::BIM->value;
  44. }
  45. if (in_array($this->extension, config('bim.gis_extensions')) || !empty($this->gisType)) {
  46. return BimFileModelType::GIS->value;
  47. }
  48. return '';
  49. }
  50. /**
  51. * 设置点云GIS相关信息
  52. * @param array $pointCloudConfig
  53. * @return void
  54. */
  55. public function setPointCloudConfigJson(array $pointCloudConfig)
  56. {
  57. // epsg代码,指定空间参考,格式如:"EPSG:3857"
  58. if (isset($pointCloudConfig['srs'])) {
  59. $this->pointCloudConfigJson['srs'] = $pointCloudConfig['srs'];
  60. }
  61. // 指定数据原点相对空间参考的偏移量,分为xyz三个方向,单位米,默认为不偏移[0,0,0],设置此值可以让数据往相应的方向偏移
  62. if (isset($pointCloudConfig['origin'])) {
  63. $this->pointCloudConfigJson['origin'] = $pointCloudConfig['origin'];
  64. }
  65. // 经度 弧度制
  66. if (isset($pointCloudConfig['longitude'])) {
  67. $this->pointCloudConfigJson['longitude'] = $pointCloudConfig['longitude'];
  68. }
  69. // 纬度 弧度制
  70. if (isset($pointCloudConfig['latitude'])) {
  71. $this->pointCloudConfigJson['latitude'] = $pointCloudConfig['latitude'];
  72. }
  73. // 高度​
  74. if (isset($pointCloudConfig['height'])) {
  75. $this->pointCloudConfigJson['height'] = $pointCloudConfig['height'];
  76. }
  77. }
  78. public function setConfigJson($config)
  79. {
  80. if (empty($config)) {
  81. return;
  82. }
  83. $fields = array_keys(self::configJsonRules());
  84. foreach ($config as $key => $value) {
  85. if (in_array($key, $fields)) {
  86. $this->configJson[$key] = $config[$key];
  87. }
  88. }
  89. }
  90. public static function configJsonRules()
  91. {
  92. return [
  93. "style" => 'in:0,1', //轻量化模式 0:着色模式 1:真实模式 仅适用于 revit 格式的模型
  94. "zGrid" => 'in:0,1', //轴网设置 0:不导出轴网 1:导出轴网 仅适用于 revit 格式的模型
  95. "viewStyle" => 'in:0,1', //多视图设置 0:不导出多个视图 1:导出多视图 仅适用于 revit 格式的模型
  96. "drawing" => 'in:0,1', //模型图纸 0:不导出图纸 1:导出图纸 (需要授权二三维等功能)仅适用于 revit 和 tekla 格式的模型
  97. "accuracy" => 'in:1,2,3,4,5,6,7,8,9,10',//轻量化精度 值越大转出模型越精细,范围1~10; 默认值为5; 仅适用于 revit 和 bentley 格式的模型
  98. // "locationType" => 'in:0,1,3',//定位方式 0:内部原点到内部原点;1:通过共享坐标;3:项目基点到项目基点 默认为3,仅适用于 revit 格式的模型
  99. // "materialType" => 'in:0,1',//默认值0,表示轻量化用PBR材质还是普通材质,1表示(普通材质)云渲染版引擎需将materialType设置为0
  100. "isLod" => 'in:0,1',//是否启用Lod轻量化 0:不启用LOD,1:启用LOD
  101. "srs" => '',//坐标系对应EPSG代号
  102. "type" => 'in:2,4',//模型坐标偏移类型: 2:将模型中心点偏移为0点。 4:根据偏移量(offsetX,offsetY,offsetZ)偏移模型坐标。默认值为2
  103. "offsetX" => 'numeric',
  104. "offsetY" => 'numeric',
  105. "offsetZ" => 'numeric',
  106. 'srsOrigin' => 'array'
  107. ];
  108. }
  109. }