Skip to content

Commit

Permalink
Merge pull request #802 from pierotofy/cogeoutm
Browse files Browse the repository at this point in the history
Keep COGEOs in original CRS, do not lose resolution
  • Loading branch information
pierotofy authored Jan 29, 2020
2 parents 21962bb + a86cf02 commit e0cb509
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/cogeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def assure_cogeo(src_path):

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

if os.path.isfile(tmpfile):
shutil.move(src_path, swapfile) # Move to swap location
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "WebODM",
"version": "1.3.0",
"version": "1.3.1",
"description": "User-friendly, extendable application and API for processing aerial imagery.",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 9 additions & 2 deletions plugins/measure/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from rest_framework import serializers
from rest_framework import status
from rest_framework.response import Response
import rasterio

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

cols = output.split(':')
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
# https://gis.stackexchange.com/questions/93332/calculating-distance-scale-factor-by-latitude-for-mercator#93335
latitude = task.dsm_extent.centroid[1]
scale_factor = math.cos(math.radians(latitude)) ** 2
scale_factor = 1.0
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)
return str(volume)
Expand Down

0 comments on commit e0cb509

Please sign in to comment.