MCPcopy Index your code
hub / github.com/WebODM/WebODM / post

Method post

coreplugins/contours/api.py:117–146  ·  view source on GitHub ↗
(self, request, pk=None)

Source from the content-addressed store, hash-verified

115
116class TaskContoursGenerate(TaskView):
117 def post(self, request, pk=None):
118 task = self.get_and_check_task(request, pk)
119
120 layer = request.data.get('layer', None)
121 if layer == 'DSM' and task.dsm_extent is None:
122 return Response({'error': _('No DSM layer is available.')})
123 elif layer == 'DTM' and task.dtm_extent is None:
124 return Response({'error': _('No DTM layer is available.')})
125
126 try:
127 if layer == 'DSM':
128 dem = os.path.abspath(task.get_asset_download_path("dsm.tif"))
129 elif layer == 'DTM':
130 dem = os.path.abspath(task.get_asset_download_path("dtm.tif"))
131 else:
132 raise ContoursException('{} is not a valid layer.'.format(layer))
133
134 epsg = int(request.data.get('epsg', '3857'))
135 interval = float(request.data.get('interval', 1))
136 format = request.data.get('format', 'GPKG')
137 supported_formats = ['GPKG', 'ESRI Shapefile', 'DXF', 'GeoJSON']
138 if not format in supported_formats:
139 raise ContoursException("Invalid format {} (must be one of: {})".format(format, ",".join(supported_formats)))
140 simplify = float(request.data.get('simplify', 0.01))
141 zfactor = float(request.data.get('zfactor', 1))
142
143 celery_task_id = run_function_async(calc_contours, dem, epsg, interval, format, simplify, zfactor, task.crop.wkt if task.crop is not None else None, task.name).task_id
144 return Response({'celery_task_id': celery_task_id}, status=status.HTTP_200_OK)
145 except ContoursException as e:
146 return Response({'error': str(e)}, status=status.HTTP_200_OK)
147
148
149class TaskContoursDownload(GetTaskResult):

Callers

nothing calls this directly

Calls 7

run_function_asyncFunction · 0.90
ContoursExceptionClass · 0.85
get_and_check_taskMethod · 0.80
_Function · 0.50
getMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected