BimFileBO.php 4.5 KB

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