kopia lustrzana https://github.com/OpenDroneMap/WebODM
Handle volume measurements in legacy web mercator
rodzic
8b2c3cf964
commit
a86cf02a80
|
@ -4,6 +4,7 @@ import math
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
import rasterio
|
||||||
|
|
||||||
from app.api.workers import GetTaskResult, TaskResultOutputError, CheckTask
|
from app.api.workers import GetTaskResult, TaskResultOutputError, CheckTask
|
||||||
from app.models import Task
|
from app.models import Task
|
||||||
|
@ -61,10 +62,16 @@ class TaskVolumeResult(GetTaskResult):
|
||||||
|
|
||||||
cols = output.split(':')
|
cols = output.split(':')
|
||||||
if len(cols) == 7:
|
if len(cols) == 7:
|
||||||
|
# Legacy: we had rasters in EPSG:3857 for a while
|
||||||
|
# This could be removed at some point in the future
|
||||||
# Correct scale measurement for web mercator
|
# Correct scale measurement for web mercator
|
||||||
# https://gis.stackexchange.com/questions/93332/calculating-distance-scale-factor-by-latitude-for-mercator#93335
|
# https://gis.stackexchange.com/questions/93332/calculating-distance-scale-factor-by-latitude-for-mercator#93335
|
||||||
latitude = task.dsm_extent.centroid[1]
|
scale_factor = 1.0
|
||||||
scale_factor = math.cos(math.radians(latitude)) ** 2
|
dsm = os.path.abspath(task.get_asset_download_path("dsm.tif"))
|
||||||
|
with rasterio.open(dsm) as dst:
|
||||||
|
if str(dst.crs) == 'EPSG:3857':
|
||||||
|
latitude = task.dsm_extent.centroid[1]
|
||||||
|
scale_factor = math.cos(math.radians(latitude)) ** 2
|
||||||
|
|
||||||
volume = abs(float(cols[6]) * scale_factor)
|
volume = abs(float(cols[6]) * scale_factor)
|
||||||
return str(volume)
|
return str(volume)
|
||||||
|
|
Ładowanie…
Reference in New Issue