Merge pull request #793 from pierotofy/multispec

Add multispectral preset
pull/801/head
Piero Toffanin 2020-01-22 12:52:17 -06:00 zatwierdzone przez GitHub
commit 576afe9501
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
9 zmienionych plików z 27 dodań i 21 usunięć

Wyświetl plik

@ -9,6 +9,6 @@ services:
install:
- docker-compose -f docker-compose.yml -f docker-compose.build.yml up --build -d
- sleep 50
- while sleep 5; do docker ps -a; if [[ -n "`docker ps | grep webapp | grep ' Up '`" ]]; then break; fi; done
script: docker-compose exec webapp /bin/bash -c "/webodm/webodm.sh test"

Wyświetl plik

@ -9,7 +9,7 @@ ENV PROJ_LIB=/usr/share/proj
RUN mkdir /webodm
WORKDIR /webodm
RUN curl --silent --location https://deb.nodesource.com/setup_8.x | bash -
RUN curl --silent --location https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get -qq install -y nodejs
# Configure use of testing branch of Debian

Wyświetl plik

@ -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?
@ -329,15 +331,16 @@ class Tiles(TaskNestedView):
# Try to find RGBA band order
if ColorInterp.red in ci and \
ColorInterp.green in ci and \
ColorInterp.blue in ci: # and ColorInterp.alpha in ci:
ColorInterp.blue in ci:
indexes = (ci.index(ColorInterp.red) + 1,
ci.index(ColorInterp.green) + 1,
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, )
# Fallback to first three
indexes = (1, 2, 3, )
elif has_alpha:
indexes = non_alpha_indexes(src)
resampling="nearest"
padding=0
@ -357,10 +360,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")

Wyświetl plik

@ -96,6 +96,10 @@ def boot():
def add_default_presets():
try:
Preset.objects.update_or_create(name='Multispectral', system=True,
defaults={'options': [{'name': 'texturing-skip-global-seam-leveling', 'value': True},
{'name': 'texturing-data-term', 'value': 'area'},
]})
Preset.objects.update_or_create(name='Volume Analysis', system=True,
defaults={'options': [{'name': 'dsm', 'value': True},
{'name': 'dem-resolution', 'value': '2'},

Wyświetl plik

@ -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;
},

Wyświetl plik

@ -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

Wyświetl plik

@ -28,6 +28,7 @@ class TestApiPreset(BootTestCase):
self.assertTrue(Preset.objects.filter(name="Buildings", system=True).exists())
self.assertTrue(Preset.objects.filter(name="3D Model", system=True).exists())
self.assertTrue(Preset.objects.filter(name="Point of Interest", system=True).exists())
self.assertTrue(Preset.objects.filter(name="Multispectral", system=True).exists())
def test_preset(self):
client = APIClient()
@ -57,7 +58,7 @@ class TestApiPreset(BootTestCase):
self.assertTrue(res.status_code == status.HTTP_200_OK)
# Only ours and global presets are available
self.assertTrue(len(res.data) == 12)
self.assertTrue(len(res.data) == 13)
self.assertTrue('My Local Preset' in [preset['name'] for preset in res.data])
self.assertTrue('High Resolution' in [preset['name'] for preset in res.data])
self.assertTrue('Global Preset #1' in [preset['name'] for preset in res.data])

Wyświetl plik

@ -56,4 +56,4 @@ webcolors==1.5
rasterio==1.1.0
-e git://github.com/OpenDroneMap/rio-tiler.git#egg=rio-tiler
rio-color==1.0.0
rio-cogeo==1.1.7
rio-cogeo==1.1.8

Wyświetl plik

@ -28,7 +28,7 @@ if [ $? -ne 0 ]; then
fi
# Check GDAL version
python -c "import sys;import re;import subprocess;version = subprocess.Popen([\"gdalinfo\", \"--version\"], stdout=subprocess.PIPE).communicate()[0].decode().rstrip();ret = 0 if re.compile('^GDAL [2-9]\.[1-9]+').match(version) else 1; print('Checking GDAL version... ' + ('{}, excellent!'.format(version) if ret == 0 else version));sys.exit(ret);"
python -c "import sys;import re;import subprocess;version = subprocess.Popen([\"gdalinfo\", \"--version\"], stdout=subprocess.PIPE).communicate()[0].decode().rstrip();ret = 0 if re.compile('^GDAL [2-9]\.[0-9]+').match(version) else 1; print('Checking GDAL version... ' + ('{}, excellent!'.format(version) if ret == 0 else version));sys.exit(ret);"
if [ $? -ne 0 ]; then
almost_there
echo -e "\033[33mYour system is currently using a version of GDAL that is too old, or GDAL is not installed. You need to install or configure your system to use GDAL 2.1 or higher. If you have installed multiple versions of GDAL, make sure the newer one takes priority in your PATH environment variable.\033[39m"