Commit 7fb65f0e authored by Peter Kettig's avatar Peter Kettig

Initial commit of WASP v1.0

parents
# Install build folders
install*/
build*/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
.idea/
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
.static_storage/
.media/
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Eclipse project settings
.settings
.cproject
.project
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
# SonarQube
.scannerwork/
# Project specific
OUTPUTS/
project(NewTemporalSynthesis)
cmake_minimum_required(VERSION 2.8)
include(CTest)
find_package(OTB REQUIRED)
find_program(BASH_Program bash)
include(${OTB_USE_FILE})
include(FindPythonInterp)
# Set a default build type if none was specified
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wno-missing-field-initializers")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
find_package(Boost REQUIRED COMPONENTS unit_test_framework filesystem)
add_definitions(-DBOOST_TEST_DYN_LINK)
message("Project binary folder:" ${PROJECT_BINARY_DIR})
add_definitions(-DVCL_CAN_STATIC_CONST_INIT_FLOAT=0)
add_subdirectory(Common)
add_subdirectory(MuscateMetadata)
add_subdirectory(CompositePreprocessing)
add_subdirectory(WeightCalculation)
add_subdirectory(UpdateSynthesis)
add_subdirectory(ProductFormatter)
add_subdirectory(PythonScripts)
install(FILES ./Scripts/WASP PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_EXECUTE DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
# first we can indicate the documentation build as an option and set it to ON by default
option(BUILD_DOC "Build documentation" ON)
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
message("Installing WASP to: " ${CMAKE_INSTALL_PREFIX})
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Weighted Average Synthesis Processor (WASP)
Upstream-Contact: CNES <peter.kettig@cnes.fr>, CESBIO <olivier.hagolle@cnes.fr>
Files: *
Copyright: <2018-2019> Centre national d'études spatiales (CNES), France
Comment: WASP project, initialy named TemporalSynthesis, for MUSCATE/THEIA
License: GPL-3+
Files: Common/include/GlobalDefs.h
Common/include/ImageResampler.h
Common/include/MetadataAngles.h
Common/include/MetadataHelperFactory.h
Common/include/MetadataHelper.h
Common/include/ResamplingBandExtractor.h
Common/src/MetadataHelper.cpp
Common/src/MetadataHelperFactory.cpp
CompositePreprocessing/include/ComputeNDVI.h
CompositePreprocessing/include/CreateS2AnglesRaster.h
CompositePreprocessing/include/DirectionalCorrectionFilter.h
CompositePreprocessing/include/DirectionalCorrectionFunctor.h
CompositePreprocessing/include/DirectionalCorrection.h
CompositePreprocessing/include/DirectionalModel.h
CompositePreprocessing/include/MaskExtractorFilter.h
CompositePreprocessing/src/ComputeNDVI.cpp
CompositePreprocessing/src/CreateS2AnglesRaster.cpp
CompositePreprocessing/src/DirectionalCorrection.cpp
CompositePreprocessing/src/DirectionalCorrectionFunctor.txx
CompositePreprocessing/src/DirectionalModel.cpp
CompositePreprocessing/src/MaskExtractorFilter.txx
MuscateMetadata/include/FluentXML.hpp
MuscateMetadata/include/MetadataUtil.hpp
MuscateMetadata/include/string_utils.hpp
MuscateMetadata/include/tinyxml_utils.hpp
MuscateMetadata/include/ViewingAngles.hpp
MuscateMetadata/src/FluentXML.cpp
MuscateMetadata/src/MetadataUtil.cpp
MuscateMetadata/src/string_utils.cpp
MuscateMetadata/src/tinyxml_utils.cpp
MuscateMetadata/src/ViewingAngles.cpp
ProductFormatter/src/ProductFormatter.cpp
UpdateSynthesis/include/BandsDefs.h
UpdateSynthesis/include/UpdateSynthesisFunctor.h
UpdateSynthesis/src/UpdateSynthesis.cpp
UpdateSynthesis/src/UpdateSynthesisFunctor.txx
WeightCalculation/TotalWeight/include/TotalWeightComputation.h
WeightCalculation/TotalWeight/src/TotalWeightComputation.cpp
WeightCalculation/TotalWeight/src/TotalWeight.cpp
WeightCalculation/WeightAOT/include/WeightAOTComputation.h
WeightCalculation/WeightAOT/src/WeightAOTComputation.cpp
WeightCalculation/WeightAOT/src/WeightAOT.cpp
WeightCalculation/WeightOnClouds/include/CloudMaskBinarization.h
WeightCalculation/WeightOnClouds/include/CloudsInterpolation.h
WeightCalculation/WeightOnClouds/include/CloudWeightComputation.h
WeightCalculation/WeightOnClouds/include/CuttingImageFilter.h
WeightCalculation/WeightOnClouds/include/GaussianFilter.h
WeightCalculation/WeightOnClouds/include/PaddingImageHandler.h
WeightCalculation/WeightOnClouds/src/WeightOnClouds.cpp
Copyright: <2014-2018> CS-Romania SA, Romania
<2018-2019> Centre national d'études spatiales (CNES), France
Comment: Initial work funded by ESA during the ESA DUE Sentinel-2 For
Agriculture Project. Modified for WASP project
License: GPL-3+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
set(MetadataHelper_HEADERS
include/MuscateMetadataHelper.h
include/MetadataHelperFactory.h
include/MetadataHelper.h
include/MetadataBands.h
include/MetadataAngles.h
include/GlobalDefs.h
include/ResamplingBandExtractor.h
include/ImageResampler.h
include/TestImageCreator.h
)
set(MetadataHelper_SOURCES
src/MuscateMetadataHelper.cpp
src/GlobalDefs.cpp
src/MetadataHelper.cpp
src/MetadataBands.cpp
src/MetadataHelperFactory.cpp
)
add_library(MetadataHelper SHARED ${MetadataHelper_HEADERS} ${MetadataHelper_SOURCES})
target_link_libraries(MetadataHelper MuscateMetadata
"${Boost_LIBRARIES}"
"${OTBCommon_LIBRARIES}"
"${OTBITK_LIBRARIES}")
target_include_directories(MetadataHelper PUBLIC include)
install(TARGETS MetadataHelper DESTINATION lib/)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
/*
* Copyright (C) 2018-2019, Centre National d'Etudes Spatiales (CNES)
* All rights reserved
*
* This file is part of Weighted Average Synthesis Processor (WASP)
*
* Authors:
* - Peter KETTIG <peter.kettig@cnes.fr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* See the LICENSE.md file for more details.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef COMMON_INCLUDE_BASEIMAGETYPES_H_
#define COMMON_INCLUDE_BASEIMAGETYPES_H_
#include "itkLightObject.h"
#include "otbImage.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbObjectList.h"
#include "otbImageList.h"
#include "otbWrapperApplication.h"
/**
* @brief The TemporalSynthesis namespace, covering all needed functions to execute this processing chain
*/
namespace ts {
/**
* @brief Stores all base typedefs used in the processing chain
*/
class BaseImageTypes{
public:
typedef unsigned char BytePixelType;
typedef otb::Image<BytePixelType, 2> ByteImageType;
typedef otb::ImageFileReader<ByteImageType> ByteImageReaderType;
typedef otb::ObjectList<ByteImageReaderType> ByteImageReaderListType;
typedef otb::ImageList<ByteImageType> ByteImageListType;
typedef short ShortPixelType;
typedef otb::Image<ShortPixelType, 2> ShortImageType;
typedef otb::ImageFileReader<ShortImageType> ShortImageReaderType;
typedef otb::ObjectList<ShortImageReaderType> ShortImageReaderListType;
typedef otb::ImageList<ShortImageType> ShortImageListType;
typedef otb::Wrapper::Int16VectorImageType ShortVectorImageType;
typedef otb::ImageFileReader<ShortVectorImageType> ShortVectorImageReaderType;
typedef otb::ObjectList<ShortVectorImageReaderType> ShortVectorImageReaderListType;
typedef otb::ImageList<ShortVectorImageType> ShortVectorImageListType;
typedef float FloatPixelType;
typedef otb::Image<FloatPixelType, 2> FloatImageType;
typedef otb::ImageFileReader<FloatImageType> FloatImageReaderType;
typedef otb::ObjectList<FloatImageReaderType> FloatImageReaderListType;
typedef otb::ImageList<FloatImageType> FloatImageListType;
typedef otb::Wrapper::FloatVectorImageType FloatVectorImageType;
typedef otb::ImageFileReader<FloatVectorImageType> FloatVectorImageReaderType;
typedef otb::ObjectList<FloatVectorImageReaderType> FloatVectorImageReaderListType;
typedef otb::ImageList<FloatVectorImageType> FloatVectorImageListType;
};
} // namespace ts
#endif /* COMMON_INCLUDE_BASEIMAGETYPES_H_ */
/*
* Copyright (C) 2015-2016, CS Romania <office@c-s.ro>
* Copyright (C) 2018-2019, Centre National d'Etudes Spatiales (CNES)
* All rights reversed
*
* This file is part of:
* - Sen2agri-Processors (initial work)
* - Weighted Average Synthesis Processor (WASP)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef GLOBALDEFS_H
#define GLOBALDEFS_H
#include <string>
#include <vector>
/**
* @brief The TemporalSynthesis namespace, covering all needed functions to execute this processing chain
*/
namespace ts {
/* The product return Type used for all products */
using productReturnType = std::vector<std::string>;
#define DEFAULT_QUANTIFICATION_VALUE 1000
#define NO_DATA_VALUE -10000
#define WEIGHT_NO_DATA_VALUE -10000
#define EPSILON 0.0001f
#define TIF_EXTENSION ".tif"
#define JPEG_EXTENSION ".jpg"
#define XML_EXTENSION ".xml"
#define COMPOSITE_REFLECTANCE_SUFFIX "FRC"
#define REFLECTANCE_SUFFIX "SRE"
#define FLAT_REFLECTANCE_SUFFIX "FRE"
#define QUICKLOOK_SUFFIX "QKL_ALL"
#define COMPOSITE_WEIGHTS_SUFFIX "WGT"
#define COMPOSITE_DATES_SUFFIX "DTS"
#define COMPOSITE_FLAGS_SUFFIX "FLG"
#define METADATA_CATEG "MTD_ALL"
#define IPP_DATA_SUFFIX "IPP_ALL"
#define NO_DATA_VALUE_STR "-10000"
#define DATA_FOLDER_NAME "DATA"
#define MASKS_FOLDER_NAME "MASKS"
#define SENTINEL_MISSION_STR "SENTINEL"
#define VENUS_MISSION_STR "VENUS"
#define LANDSAT8 "LANDSAT8"
#define SENTINEL2X "SENTINEL2X"
#define SENTINEL2A "SENTINEL2A"
#define SENTINEL2B "SENTINEL2B"
#define MULTISAT "S2AS2BL8"
#define VENUS VENUS_MISSION_STR
#define NONE_STRING "None"
#define MAIN_RESOLUTION_INDEX 0
#define N_RESOLUTIONS_SENTINEL 2
/**
* @brief Output Flag-mask definitions
*/
typedef enum {
IMG_FLG_NO_DATA=0, //!< IMG_FLG_NO_DATA
IMG_FLG_CLOUD=1, //!< IMG_FLG_CLOUD
IMG_FLG_SNOW=2, //!< IMG_FLG_SNOW
IMG_FLG_WATER=3, //!< IMG_FLG_WATER
IMG_FLG_LAND=4, //!< IMG_FLG_LAND
IMG_FLG_CLOUD_SHADOW=5,//!< IMG_FLG_CLOUD_SHADOW
IMG_FLG_SATURATION=6 //!< IMG_FLG_SATURATION
} FlagType;
/**
* @brief Interpolator types
*/
typedef enum
{
Interpolator_NNeighbor,//!< Interpolator_NNeighbor
Interpolator_Linear, //!< Interpolator_Linear
Interpolator_BCO //!< Interpolator_BCO
} Interpolator_Type;
/**
* @brief Used to determine whether the underlying structure has a size()-method or not.
* @note Used in the ShortToFloat- and FloatToShort-TranslationFunctors
*/
template<typename T>
struct HasSizeMethod
{
template<typename U, unsigned int (U::*)() const> struct SFINAE {};
template<typename U> static char Test(SFINAE<U, &U::Size>*);
template<typename U> static int Test(...);
static const bool Has = sizeof(Test<T>(0)) == sizeof(char);
};
/////////////////////////
/// GLOBAL FUNCTIONS ///
///////////////////////
/**
* @brief Returns the base name in a string
* @param path Reference to the input string
* @return string containing the base name
*/
std::string getDirname(const std::string &path);
/**
*@brief Returns the directory name in a string
*@param path Reference to the input string
*@return string containing the directory name
*/
std::string getBasename(const std::string &path);
/**
* @brief get Environment Variable by key name
* @param key The name of the key, e.g. PATH
* @return The value of the variable, if existing
*/
std::string getEnvVar( std::string const & key );
} // namespace ts
#endif //GLOBALDEFS_H
/*
* Copyright (C) 2015-2016, CS Romania <office@c-s.ro>
* Copyright (C) 2018-2019, Centre National d'Etudes Spatiales (CNES)
* All rights reversed
*
* This file is part of:
* - Sen2agri-Processors (initial work)
* - Weighted Average Synthesis Processor (WASP)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef IMAGE_RESAMPLER_H
#define IMAGE_RESAMPLER_H
#include "otbWrapperTypes.h"
#include "otbStreamingResampleImageFilter.h"
#include "otbImage.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbImageListToVectorImageFilter.h"
#include "libgen.h"
//Transform
#include "itkScalableAffineTransform.h"
#include "GlobalDefs.h"
/**
* @brief The TemporalSynthesis namespace, covering all needed functions to execute this processing chain
*/
namespace ts {
/**
* @brief Resample an image to either a given size or a given scale
* @note Can use the following interpolators: BCO, NearestNeighbor and Linear
*/
template <class TInput, class TOutput>
class ImageResampler
{
public:
typedef otb::StreamingResampleImageFilter<TInput, TOutput, double> ResampleFilterType;
typedef otb::ObjectList<ResampleFilterType> ResampleFilterListType;
typedef itk::NearestNeighborInterpolateImageFunction<TOutput, double> NearestNeighborInterpolationType;
typedef itk::LinearInterpolateImageFunction<TOutput, double> LinearInterpolationType;
typedef otb::BCOInterpolateImageFunction<TOutput> BCOInterpolationType;
typedef itk::IdentityTransform<double, TOutput::ImageDimension> IdentityTransformType;
typedef itk::ScalableAffineTransform<double, TOutput::ImageDimension> ScalableTransformType;
typedef typename ScalableTransformType::OutputVectorType OutputVectorType;
typedef typename NearestNeighborInterpolationType::Pointer NearestNeighborInterpolationTypePtr;
typedef typename LinearInterpolationType::Pointer LinearInterpolationTypePtr;
typedef typename IdentityTransformType::Pointer IdentityTransformTypePtr;