MCPcopy
hub / github.com/WebODM/WebODM / post

Method post

coreplugins/cesiumion/api_views.py:219–276  ·  view source on GitHub ↗
(self, request, pk=None)

Source from the content-addressed store, hash-verified

217 return Response({"items": assets}, status=status.HTTP_200_OK)
218
219 def post(self, request, pk=None):
220 from app.plugins import logger
221 task = self.get_and_check_task(request, pk)
222 serializer = UploadSerializer(data=request.data)
223 serializer.is_valid(raise_exception=True)
224
225 token, asset_type, name, description, attribution, options = pluck(
226 serializer.validated_data,
227 "token",
228 "asset_type",
229 "name",
230 "description",
231 "attribution",
232 "options",
233 )
234 asset_path = task.get_asset_download_path(ASSET_TO_FILE[asset_type])
235
236 # Skip already processing tasks
237 if asset_type not in get_processing_assets(task.id):
238 if asset_type == AssetType.TEXTURED_MODEL and "position" not in options:
239 value = task.ASSETS_MAP[ASSET_TO_FILE[asset_type]]
240 if isinstance(value, dict):
241 if 'deferred_compress_dir' in value:
242 odm_path = value['deferred_compress_dir']
243 asset_path = task.generate_deferred_asset(asset_path, odm_path, False)
244 logger.info(f"generate_deferred_asset at {asset_path}")
245
246 extent = None
247 if task.dsm_extent is not None:
248 extent = task.dsm_extent.extent
249 if task.dtm_extent is not None:
250 extent = task.dtm_extent.extent
251 if extent is None:
252 print(f"Unable to find task boundary: {task}")
253 else:
254 lng, lat = extent[0], extent[1]
255 # height is set to zero as model is already offset
256 options["position"] = [lng, lat, 0]
257
258 del_asset_info(task.id, asset_type)
259 asset_info = get_asset_info(task.id, asset_type)
260 asset_info["upload"]["active"] = True
261 set_asset_info(task.id, asset_type, asset_info)
262
263 run_function_async(upload_to_ion,
264 task.id,
265 asset_type,
266 token,
267 asset_path,
268 name,
269 description,
270 attribution,
271 options,
272 )
273 else:
274 print(f"Ignore running ion task {task.id} {str(asset_type)}")
275
276 return Response(status=status.HTTP_200_OK)

Callers 1

upload_to_ionFunction · 0.45

Calls 9

run_function_asyncFunction · 0.90
UploadSerializerClass · 0.85
get_processing_assetsFunction · 0.85
del_asset_infoFunction · 0.85
get_asset_infoFunction · 0.85
set_asset_infoFunction · 0.85
get_and_check_taskMethod · 0.80

Tested by

no test coverage detected