Skip to content

Commit e0cb509

Browse files
authored
Merge pull request #802 from pierotofy/cogeoutm
Keep COGEOs in original CRS, do not lose resolution
2 parents 21962bb + a86cf02 commit e0cb509

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

app/cogeo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def assure_cogeo(src_path):
6262

6363
cog_translate(dst, tmpfile, output_profile, nodata=nodata,
6464
config=config, in_memory=False,
65-
quiet=True, web_optimized=True)
65+
quiet=True, web_optimized=False)
66+
# web_optimized reduces the dimension of the raster, as well as reprojecting to EPSG:3857
67+
# we want to keep resolution and projection at the tradeoff of slightly slower tile render speed
6668

6769
if os.path.isfile(tmpfile):
6870
shutil.move(src_path, swapfile) # Move to swap location

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "WebODM",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "User-friendly, extendable application and API for processing aerial imagery.",
55
"main": "index.js",
66
"scripts": {

plugins/measure/api.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from rest_framework import serializers
55
from rest_framework import status
66
from rest_framework.response import Response
7+
import rasterio
78

89
from app.api.workers import GetTaskResult, TaskResultOutputError, CheckTask
910
from app.models import Task
@@ -61,10 +62,16 @@ def handle_output(self, output, result, task):
6162

6263
cols = output.split(':')
6364
if len(cols) == 7:
65+
# Legacy: we had rasters in EPSG:3857 for a while
66+
# This could be removed at some point in the future
6467
# Correct scale measurement for web mercator
6568
# https://gis.stackexchange.com/questions/93332/calculating-distance-scale-factor-by-latitude-for-mercator#93335
66-
latitude = task.dsm_extent.centroid[1]
67-
scale_factor = math.cos(math.radians(latitude)) ** 2
69+
scale_factor = 1.0
70+
dsm = os.path.abspath(task.get_asset_download_path("dsm.tif"))
71+
with rasterio.open(dsm) as dst:
72+
if str(dst.crs) == 'EPSG:3857':
73+
latitude = task.dsm_extent.centroid[1]
74+
scale_factor = math.cos(math.radians(latitude)) ** 2
6875

6976
volume = abs(float(cols[6]) * scale_factor)
7077
return str(volume)

0 commit comments

Comments
 (0)