| 1076 | plugin_signals.task_completed.send_robust(sender=self.__class__, task_id=self.id) |
| 1077 | |
| 1078 | def check_ept(self, threads=1): |
| 1079 | # Make sure that the entwine_pointcloud/ept.json file exists |
| 1080 | # and generate it otherwise |
| 1081 | ept_file = self.assets_path("entwine_pointcloud", "ept.json") |
| 1082 | if os.path.isfile(ept_file): |
| 1083 | return |
| 1084 | |
| 1085 | point_cloud = self.get_point_cloud() |
| 1086 | if point_cloud is None: |
| 1087 | return |
| 1088 | |
| 1089 | # We have the point cloud, but no EPT. Generate EPT. |
| 1090 | entwine = shutil.which('entwine') |
| 1091 | if not entwine: |
| 1092 | logger.warning("Cannot create EPT, entwine program is missing") |
| 1093 | return None |
| 1094 | |
| 1095 | ept_dir = self.assets_path("entwine_pointcloud") |
| 1096 | try: |
| 1097 | if not os.path.exists(settings.MEDIA_TMP): |
| 1098 | os.makedirs(settings.MEDIA_TMP) |
| 1099 | |
| 1100 | tmp_ept_path = tempfile.mkdtemp('_ept', dir=settings.MEDIA_TMP) |
| 1101 | params = [entwine, "build", "--threads", str(threads), |
| 1102 | "--tmp", quote(tmp_ept_path), |
| 1103 | "-i", quote(point_cloud), |
| 1104 | "-o", quote(ept_dir)] |
| 1105 | |
| 1106 | subprocess.run(params, timeout=12*60*60) |
| 1107 | |
| 1108 | if os.path.isdir(tmp_ept_path): |
| 1109 | shutil.rmtree(tmp_ept_path) |
| 1110 | return True |
| 1111 | except Exception as e: |
| 1112 | logger.warning("Cannot create EPT for %s (%s). 3D point cloud will not display properly." % (point_cloud, str(e))) |
| 1113 | |
| 1114 | |
| 1115 | def get_extent_fields(self): |