kopia lustrzana https://github.com/OpenDroneMap/WebODM
Scale fix for 16bit orthophoto TIFFs
rodzic
f56451234b
commit
07a3ca3f2a
|
@ -6,7 +6,8 @@ from django.http import HttpResponse
|
|||
from rio_tiler.errors import TileOutsideBounds
|
||||
from rio_tiler.mercator import get_zooms
|
||||
from rio_tiler import main
|
||||
from rio_tiler.utils import array_to_image, get_colormap, expression, linear_rescale, _chunks, _apply_discrete_colormap, has_alpha_band
|
||||
from rio_tiler.utils import array_to_image, get_colormap, expression, linear_rescale, _chunks, _apply_discrete_colormap, has_alpha_band, \
|
||||
non_alpha_indexes
|
||||
from rio_tiler.profiles import img_profiles
|
||||
|
||||
import numpy as np
|
||||
|
@ -73,6 +74,7 @@ def rescale_tile(tile, mask, rescale = None):
|
|||
rescale_arr = list(_chunks(rescale_arr, 2))
|
||||
if len(rescale_arr) != tile.shape[0]:
|
||||
rescale_arr = ((rescale_arr[0]),) * tile.shape[0]
|
||||
|
||||
for bdx in range(tile.shape[0]):
|
||||
if mask is not None:
|
||||
tile[bdx] = np.where(
|
||||
|
@ -320,8 +322,8 @@ class Tiles(TaskNestedView):
|
|||
if z < minzoom - ZOOM_EXTRA_LEVELS or z > maxzoom + ZOOM_EXTRA_LEVELS:
|
||||
raise exceptions.NotFound()
|
||||
|
||||
# Handle N-bands datasets
|
||||
if tile_type == 'orthophoto':
|
||||
# Handle N-bands datasets for orthophotos (not plant health)
|
||||
if tile_type == 'orthophoto' and expr is None:
|
||||
ci = src.colorinterp
|
||||
|
||||
# More than 4 bands?
|
||||
|
@ -335,9 +337,12 @@ class Tiles(TaskNestedView):
|
|||
ci.index(ColorInterp.blue) + 1,)
|
||||
# TODO: adding alpha band should fix black backgrounds
|
||||
# but the tiles disappear. Probable bug in rasterio/GDAL
|
||||
|
||||
else:
|
||||
# Fallback to first four
|
||||
indexes = (1, 2, 3, ) # , 4, )
|
||||
elif has_alpha:
|
||||
indexes = non_alpha_indexes(src)
|
||||
|
||||
resampling="nearest"
|
||||
padding=0
|
||||
|
@ -357,10 +362,6 @@ class Tiles(TaskNestedView):
|
|||
except TileOutsideBounds:
|
||||
raise exceptions.NotFound("Outside of bounds")
|
||||
|
||||
# Use alpha channel for transparency, don't use the mask if one is provided (redundant)
|
||||
if has_alpha and expr is None:
|
||||
mask = None
|
||||
|
||||
if color_map:
|
||||
try:
|
||||
color_map = get_colormap(color_map, format="gdal")
|
||||
|
|
|
@ -33,7 +33,9 @@ export default {
|
|||
let paramsRaw = (location.search.replace("?", "").match(/([^&=]+)=?([^&]*)/g) || []);
|
||||
for (let i in paramsRaw){
|
||||
let parts = paramsRaw[i].split("=");
|
||||
params[parts[0]] = parts[1];
|
||||
if (parts[1] !== undefined){
|
||||
params[parts[0]] = parts[1];
|
||||
}
|
||||
}
|
||||
return params;
|
||||
},
|
||||
|
|
|
@ -109,9 +109,9 @@ class Map extends React.Component {
|
|||
|
||||
// Build URL
|
||||
let tileUrl = mres.tiles[0];
|
||||
|
||||
// Certain types need the rescale parameter
|
||||
if (["plant", "dsm", "dtm"].indexOf(type) !== -1 && statistics){
|
||||
|
||||
// Set rescale
|
||||
if (statistics){
|
||||
const params = Utils.queryParams({search: tileUrl.slice(tileUrl.indexOf("?"))});
|
||||
if (statistics["1"]){
|
||||
// Add rescale
|
||||
|
|
Ładowanie…
Reference in New Issue