diff --git a/CMake/CTestCustom.cmake.in b/CMake/CTestCustom.cmake.in index 612027d6e5c8fd494e34aea7afede597568d6d00..a2416c69f341f60e37c060ce71168ad0adfa2051 100644 --- a/CMake/CTestCustom.cmake.in +++ b/CMake/CTestCustom.cmake.in @@ -38,9 +38,11 @@ #---------------------------------------------------------------------- set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000) -set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 300) set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50) +if(NOT DEFINED CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS) + set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 300) +endif() set(CTEST_CUSTOM_COVERAGE_EXCLUDE ${CTEST_CUSTOM_COVERAGE_EXCLUDE} @@ -86,6 +88,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION # Ignore clang's summary warning, assuming prior text has matched some # other warning expression: "[0-9,]+ warnings? generated." + "cl...Command.line.warning.D9025" ".*include.opencv2.*warning.*" ".*include.opencv2.*note.*" ".*include.kml.*warning.*" diff --git a/CMake/FindShark.cmake b/CMake/FindShark.cmake index 9e1e973d59fe617fa0e2c1bc3ba73bef75a2a418..7dced6bb432c256b17cafd6bd3394bea97bac4e8 100644 --- a/CMake/FindShark.cmake +++ b/CMake/FindShark.cmake @@ -41,9 +41,11 @@ if(Shark_DIR) endif() #if(Shark_DIR) -find_path( SHARK_INCLUDE_DIR shark/Core/Shark.h +find_path( SHARK_INCLUDE_DIR + NAMES shark/Core/Shark.h PATHS "${SHARK_SEARCH_PATH}" - PATH_SUFFIXES include include/shark shark) + PATH_SUFFIXES include include/shark shark + ) find_library( SHARK_LIBRARY NAMES shark shark_debug @@ -51,22 +53,37 @@ find_library( SHARK_LIBRARY PATH_SUFFIXES lib ) -mark_as_advanced( SHARK_INCLUDE_DIR - SHARK_LIBRARY ) -find_package( - Boost 1.48.0 REQUIRED QUIET COMPONENTS +mark_as_advanced( SHARK_INCLUDE_DIR SHARK_LIBRARY ) + +find_package( Boost 1.48.0 REQUIRED QUIET COMPONENTS system date_time filesystem program_options serialization thread unit_test_framework -) + ) if(NOT Boost_FOUND) message(FATAL_ERROR "Please make sure Boost 1.48.0 is installed on your system") endif() +if(NOT SHARK_LIBRARY) + message(FATAL_ERROR "Cannot find SHARK_LIBRARY. set it with cmake -DSHARK_LIBRARY=") + return() +endif() + +if(NOT SHARK_INCLUDE_DIR) + message(FATAL_ERROR "Cannot find SHARK_INCLUDE_DIR. Set it with cmake -DSHARK_INCLUDE_DIR=") + return() +endif() + +get_filename_component(SHARK_INSTALLDIR ${SHARK_LIBRARY} PATH) +get_filename_component(SHARK_INSTALLDIR ${SHARK_INSTALLDIR} PATH) + if(NOT SHARK_CONFIG_FILE) - find_file(SHARK_CONFIG_FILE SharkConfig.cmake PATH_SUFFIXES lib/cmake/Shark share/Shark) + find_file(SHARK_CONFIG_FILE SharkConfig.cmake + PATHS ${SHARK_INSTALLDIR} + PATH_SUFFIXES lib/cmake/Shark share/Shark cmake/Shark) endif() + if(SHARK_CONFIG_FILE) file(STRINGS "${SHARK_CONFIG_FILE}" SHARK_CONFIG_FILE_CONTENTS) string(REGEX REPLACE @@ -81,13 +98,42 @@ if(SHARK_CONFIG_FILE) set(SHARK_VERSION_STRING "${SHARK_VERSION_MAJOR}.${SHARK_VERSION_MINOR}.${SHARK_VERSION_PATCH}") +endif() + +set(SHARK_USE_OPENMP_matched) +#define SHARK_USE_OPENMP +file(STRINGS "${SHARK_INCLUDE_DIR}/shark/Core/Shark.h" SHARK_H_CONTENTS) +string(REGEX MATCH + "#define.SHARK_USE_OPENMP" + SHARK_USE_OPENMP_matched "${SHARK_H_CONTENTS}") +#this variable is added in cache but not used now +# you can use it to see if shark installation has openMP +# later if needed in other places.. +set(SHARK_USE_OPENMP FALSE CACHE BOOL "shark is built with OpenMP") +if(SHARK_USE_OPENMP_matched) + set(SHARK_USE_OPENMP TRUE CACHE BOOL "shark is built with OpenMP" FORCE) endif() +if(SHARK_USE_OPENMP) + message(STATUS "Shark is built with OpenMP: SHARK_USE_OPENMP = TRUE") + find_package(OpenMP REQUIRED QUIET) + if(OPENMP_FOUND) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + else() + message(FATAL_ERROR "Your shark libraries are compiled with it OpenMP") + set(SHARK_FOUND FALSE) + endif() +else() + message(STATUS "Shark is built without OpenMP: SHARK_USE_OPENMP = FALSE") +endif() INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Shark - REQUIRED_VARS SHARK_LIBRARY SHARK_INCLUDE_DIR - VERSION_VAR SHARK_VERSION_STRING) + REQUIRED_VARS SHARK_LIBRARY SHARK_INCLUDE_DIR + VERSION_VAR SHARK_VERSION_STRING) + if(SHARK_FOUND) set(SHARK_INCLUDE_DIRS ${SHARK_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ) set(SHARK_LIBRARIES ${SHARK_LIBRARY} ${Boost_LIBRARIES} ) diff --git a/Documentation/Cookbook/rst/recipes/stereo.rst b/Documentation/Cookbook/rst/recipes/stereo.rst index 0100dff9b6dcb9602353021217f2c57c0e2cf69f..2c868a753698214beaec22e8a1836b381647f890 100644 --- a/Documentation/Cookbook/rst/recipes/stereo.rst +++ b/Documentation/Cookbook/rst/recipes/stereo.rst @@ -21,50 +21,51 @@ Let’s go to the third dimension! Estimate epipolar geometry transformation ----------------------------------------- -The aim of this application is to generate resampled grids to transform -images in epipolar geometry. `Epipolar geometry <http://en.wikipedia.org/wiki/Epipolar_geometry>`_ is the geometry of stereo -vision. +The aim of this step is to generate resampled grids to transform +images into epipolar geometry. +`Epipolar geometry <http://en.wikipedia.org/wiki/Epipolar_geometry>`_ is the +geometry of stereo vision. The operation of stereo rectification determines transformations to apply to each image such that pairs of conjugate epipolar lines become collinear, parallel to one of the image axes and aligned. In this geometry, the objects present on a given row of the left image are also -located on the same line in the right image. +located on the same row in the right image. Applying this transformation reduces the problem of elevation (or stereo -correspondences determination) to a 1-D problem. We have two images -image1 and image2 over the same area (the stereo pair) and we assume -that we know the localization functions (forward and inverse) associated -for each of these images. +correspondences determination) to a 1-D problem. We have two sensor images +:math:`image1` and :math:`image2` over the same area (the stereo pair) and we +assume that we know the localization functions (forward and inverse) associated +with each images. The forward function allows to go from the image referential to the -geographic referential: +geographic referential. For the first image, this function will be noted: -.. math:: (long,lat) = f^{forward}_{image1}(i,j,h) +.. math:: (long,lat) = f_{1}(i,j,h) -where h is the elevation hypothesis, :math:`(i,j)` are the pixel -coordinates in image1 and (long,lat) are geographic coordinates. As you +where :math:`h` is the elevation hypothesis, :math:`(i,j)` are the pixel +coordinates in image 1 and :math:`(long,lat)` are geographic coordinates. As you can imagine, the inverse function allows to go from geographic coordinates to the image geometry. For the second image, in that case, the expression of the inverse function is: -.. math:: (long,lat,h) = f^{inverse}_{image2}(i,j) +.. math:: (i,j) = f^{Inv}_{2}(long,lat,h) Using jointly the forward and inverse functions from the image pair, we can construct a co-localization function -:math:`f_{image1 \rightarrow image2}` between the position of a pixel in +:math:`g_{1 \rightarrow 2}` between the position of a pixel in the first and its position in the second one: -.. math:: (i_{image2},j_{image2}) = f_{image1 \rightarrow image2} (i_{image1} , j_{image1} , h) +.. math:: (i_{2},j_{2}) = g_{1 \rightarrow 2} (i_{1} , j_{1} , h) The expression of this function is: -.. math:: f_{image1 \rightarrow image2} (i_{image1} , j_{image1} , h) = f^{inverse}_{image2} f^{forward}_{image1}((i_{image1} , j_{image1}), h) +.. math:: g_{1 \rightarrow 2} (i_{1} , j_{1} , h) = f^{Inv}_{2} [ f_{1}(i_{1} , j_{1}, h) ] -The expression is not really important, what we need to understand is -that if we are able to determine for a given pixel in image1 the -corresponding pixel in image2, as we know the expression of the +The expression is not really important, what you need to understand is +that if we are able to determine for a given pixel in image 1 the +corresponding pixel in image 2, as we know the expression of the co-localization function between both images, we can determine by identification the information about the elevation (variable h in the equation)! @@ -74,11 +75,12 @@ be extracted by examination of the relative positions of objects in the two 2-D epipolar images. The construction of the two epipolar grids is a little bit more -complicated in the case of VHR optical images.That is because most of +complicated in the case of VHR optical images. That is because most of passive remote sensing from space use a push-broom sensor, which corresponds to a line of sensors arranged perpendicularly to the flight direction of the spacecraft. This acquisition configuration implies a -slightly different strategy for stereo-rectification (`see here <http://en.wikipedia.org/wiki/Epipolar_geometry#Epipolar_geometry_of_pushbroom_sensor>`_ ). +slightly different strategy for stereo-rectification +(`see here <http://en.wikipedia.org/wiki/Epipolar_geometry#Epipolar_geometry_of_pushbroom_sensor>`_ ). We will now explain how to use the *StereoRectificationGridGenerator* application to produce two images which are **deformation grids** to @@ -88,13 +90,13 @@ resample the two images in epipolar geometry. otbcli_StereoRectificationGridGenerator -io.inleft image1.tif -io.inright image2.tif - -epi.elevation.avg.value 50 - -epi.step 5 - -io.outimage1 outimage1_grid.tif - -io.outright outimage1_grid.tif + -epi.elevation.default 50 + -epi.step 10 + -io.outleft grid_image1.tif + -io.outright grid_image2.tif The application estimates the displacement to apply to each pixel in -both input images to obtain epipolar geometry.The application accept a +both input images to obtain epipolar geometry. The application accepts a ‘step’ parameter to estimate displacements on a coarser grid. Here we estimate the displacements every 10 pixels. This is because in most cases with a pair of VHR and a small angle between the two images, this @@ -115,13 +117,18 @@ In our case, we have: epi.rectsizey: 2951 epi.baseline: 0.2094 -The epi.baseline parameter provides the mean value (in -:math:`pixels.meters^{-1}`) of the baseline to sensor altitude ratio. It -can be used to convert disparities to physical elevation, since a -disparity of this value will correspond to an elevation offset of one -meter with respect to the mean elevation. +The *epi.baseline* parameter provides the mean value (in pixels per meters) of +the baseline to sensor altitude ratio (also called B/H in the litterature). +It can be used to do an approximate conversion of disparities to physical +elevation : -we can now move forward to the resampling in epipolar geometry. +.. math:: h = h_{REF} + \frac{d}{B/H} + +where :math:`h_{REF}` is the reference altitude used to generate the epipolar +grids (here: 50m), and :math:`d` is a disparity value (in pixels) for a given +object between images 1 and 2. + +We can now move forward to the resampling in epipolar geometry. Resample images in epipolar geometry ------------------------------------ @@ -130,30 +137,31 @@ The former application generates two grids of displacements. The *GridBasedImageResampling* allows to resample the two input images in the epipolar geometry using these grids. These grids are intermediary results not really useful on their own in most cases. This second step -*only* consists in applying the transformation and resample both images. -This application can obviously be used in lot of other contexts. +*only* consists in applying the transformation to resample both images. +This application can obviously be used in a lot of other contexts. The two commands to generate epipolar images are: :: otbcli_GridBasedImageResampling -io.in image1.tif - -io.out image1_epipolar.tif - -grid.in outimage1_grid.tif + -io.out epi_image1.tif + -grid.in grid_image1.tif -out.sizex 4462 -out.sizey 2951 :: otbcli_GridBasedImageResampling -io.in image2.tif - -io.out image2_epipolar.tif - -grid.in outimage2_grid.tif + -io.out epi_image2.tif + -grid.in grid_image2.tif -out.sizex 4462 -out.sizey 2951 As you can see, we set *sizex* and *sizey* parameters using output values given by the *StereoRectificationGridGenerator* application to -set the size of the output epipolar images. +set the size of the output epipolar images. The two epipolar images should have +the same size. .. figure:: ../Art/MonteverdiImages/stereo_image1_epipolar.png @@ -183,10 +191,10 @@ what is even more important is that the disparities along the lines, i.e. the offset along the lines measured by the block-matching process can be directly linked to the local elevation -An almost complete spectrum of stereo correspondence algorithms has been -published and it is still augmented at a significant rate! See for -example `. <http://en.wikipedia.org/wiki/Block-matching_algorithm>`_ -The **Orfeo Toolbox** implements different strategies for block +An almost complete spectrum of `stereo correspondence algorithms +<http://vision.middlebury.edu/stereo/eval3/>`_ has been +published and it is still augmented at a significant rate! +The **Orfeo Toolbox** implements different local strategies for block matching: - Sum of Square Distances block-matching (SSD) @@ -209,43 +217,49 @@ these parameters are mandatory for the application and as a consequence we need to estimate them manually. This is pretty simple using the two epipolar images. -In our case, we take one point on a *flat* area. The image coordinate in -:math:`image_{1}` is :math:`[1970,1525]` and in :math:`image_{2}` is -:math:`[1970,1526]`. We then select a second point on a higher region +In our case, we choose one point on a *flat* area. Its coordinates are +:math:`[1525, 1970]` in epipolar image 1 and :math:`[1526, 1970]` in +epipolar image 2. We then select a second point on a higher region (in our case a point near the top of the Pyramid of Cheops!). The image -coordinate of this pixel in :math:`image_{1}` is :math:`[1661,1299]` and -in :math:`image_{2}` is :math:`[1633,1300]`. So you see for the -horizontal exploration, we must set the minimum value lower than -:math:`-30` (the convention for the sign of the disparity range is from -image1 to image2). - -Note that this estimation can be simplified using an external DEM in the -*StereoRectificationGridGenerator* application. Regarding the vertical -disparity, in the first step we said that we reduced the problem of 3-D -extraction to a 1-D problem, but this is not completely true in general -cases. There might be small disparities in the vertical direction which +coordinates of this pixel are :math:`[1661,1299]` in image 1 and +:math:`[1633,1300]` in image 2. We check the difference between column +coordinates in images 1 and 2 in order to derive the useful disparity interval +for horizontal exploration. In our case, this interval is at least +:math:`[-28,1]` (the convention for the sign of the disparity range is from +image 1 to image 2). + +Note that this exploration interval can be reduced using an external DEM in the +*StereoRectificationGridGenerator* application. Indeed, the disparities measured +between the epipolar images are relative to the reference altitude used when +computing epipolar grids (hence, defining the epipolar geometry). Using an +external DEM should produce epipolar images where altitude deviations from the +reference are smaller, and as a consequence, disparities closer to 0. + +Regarding the vertical disparity, in the first step we said that we reduced the +problem of 2D exploration to a 1D problem, but this is not completely true in +general cases. There might be small disparities in the vertical direction which are due to parallax errors (i.e. epipolar lines exhibit a small shift in the vertical direction, around 1 pixel). In fact, the exploration is -typically smaller along the vertical direction of disparities than along +typically smaller along the vertical direction than along the horizontal one. You can also estimate them on the epipolar pair (in our case we use a range of :math:`-1` to :math:`1`). -One more time, take care of the sign of this minimum and this maximum -for disparities (always from image1 to image2). +One more time, take care of the sign for minimum and maximum disparities +(always from image1 to image2). The command line for the *BlockMatching* application is: :: - otbcli_BlockMatching -io.inleft image1_epipolar.tif - -io.inright image2_epipolar.tif + otbcli_BlockMatching -io.inleft epi_image1.tif + -io.inright epi_image2.tif -io.out disparity_map_ncc.tif -bm.minhd -45 -bm.maxhd 5 - -bm.minvd 1 + -bm.minvd -1 -bm.maxvd 1 - -mask.inleft image1_epipolar_mask.tif - -mask.inright image2_epipolar_mask.tif + -mask.inleft epi_mask_image1.tif + -mask.inright epi_mask_image2.tif -io.outmetric 1 -bm.metric ncc -bm.subpixel dichotomy @@ -260,43 +274,41 @@ functionalities to improve the quality of the output disparity map. Here are a few of these functionalities: -- -io.outmetric: if the optimal metric values image is activated, it +- **io.outmetric**: if the optimal metric values image is activated, it will be concatenated to the output image (which will then have three bands: horizontal disparity, vertical disparity and metric value) -- -bm.subpixel: Perform sub-pixel estimation of disparities +- **bm.subpixel**: Perform sub-pixel estimation of disparities -- -mask.inleft and -mask.inright: you can specify a no-data value which +- **mask.inleft** and **mask.inright**: you can specify a no-data value which will discard pixels with this value (for example the epipolar - geometry can generate large part of images with black pixels) This + geometry can generate large part of images with black pixels). This mask can be easily generated using the *BandMath* application: :: - otbcli_BandMath -il image1_epipolar.tif - -out image1_epipolar_mask.tif + otbcli_BandMath -il epi_image1.tif + -out epi_mask_image1.tif -exp "im1b1<=0 ? 0 : 255" :: - otbcli_BandMath -il image2_epipolar.tif - -out image2_epipolar_mask.tif + otbcli_BandMath -il epi_image2.tif + -out epi_mask_image2.tif -exp "im1b1<=0 ? 0 : 255" -- -mask.variancet: The block matching algorithm has difficulties to +- **mask.variancet**: The block matching algorithm has difficulties to find matches on uniform areas. We can use the variance threshold to discard those regions and speed-up computation time. -- -bm.medianfilter.radius 5 and -bm.medianfilter.incoherence 2.0: +- **bm.medianfilter.radius** and **bm.medianfilter.incoherence**: Applies a median filter to the disparity map. The median filter belongs to the family of nonlinear filters. It is used to smooth an image without being biased by outliers or shot noise. The radius corresponds to the neighbourhood where the median value is computed. A detection of incoherence between the input disparity map and the - median-filtered one is performed (a pixel corresponds to an - incoherence if the absolute value of the difference between the pixel - value in the disparity map and in the median image is higher than the - incoherence threshold, whose default value is 1). Both parameters + median-filtered one is performed (cases where the absolute difference is + greater than the threshold, whose default value is 1). Both parameters must be defined in the application to activate the filter. Of course all these parameters can be combined to improve the disparity @@ -309,18 +321,17 @@ map. Figure 2: Horizontal disparity and optimal metric map - - From disparity to Digital Surface Model --------------------------------------- -Using the previous application, we evaluated disparities between images. +Using the previous application, we evaluated disparities between epipolar images. The next (and last!) step is now to transform the disparity map into an elevation information to produce an elevation map. It uses as input the disparity maps (horizontal and vertical) to produce a Digital Surface -Model (DSM) with a regular sampling. The elevation values is computed -from the triangulation of the “left-right†pairs of matched pixels. When -several elevations are available on a DSM cell, the highest one is kept. +Model (DSM) with a regular sampling. The elevation values are computed +from the triangulation of the “left-right†lines of sight for each matched +pixels. When several elevations are available on a DSM cell, the highest one +is kept. First, an important point is that it is often a good idea to rework the disparity map given by the *BlockMatching* application to only keep @@ -329,7 +340,7 @@ metric image and filter disparities with respect to this value. For example, if we used Normalized Cross-Correlation (NCC), we can keep only disparities where optimal metric value is superior to :math:`0.9`. -Disparities below this value can be consider as inaccurate and will not +Disparities below this value can be considered as inaccurate and will not be used to compute elevation information (the *-io.mask* parameter can be used for this purpose). @@ -341,17 +352,9 @@ to their optimal metric value: :: otbcli_BandMath -il disparity_map_ncc.tif - -out thres_hdisparity.tif uint8 + -out thres_disparity.tif uint8 -exp "im1b3>0.9 ? 255 : 0" -Then, we concatenate thresholded disparities using the -*ConcatenateImages*: - -:: - - otbcli_ConcatenateImages -il thres_hdisparity.tif thres_vdisparity.tif - -out thres_hvdisparity.tif - Now, we can use the *DisparityMapToElevationMap* application to compute the elevation map from the filtered disparity maps. @@ -360,10 +363,10 @@ the elevation map from the filtered disparity maps. otbcli_DisparityMapToElevationMap -io.in disparity_map_ncc.tif -io.left image1.tif -io.right image2.tif - -io.lgrid outimage1_pyramid.tif - -io.rgrid outimage2_pyramid.tif - -io.mask thres_hdisparity.tif - -io.out disparity_map_ssd_to_elevation.tif + -io.lgrid grid_image1.tif + -io.rgrid grid_image2.tif + -io.mask thres_disparity.tif + -io.out elevation_map.tif -hmin 10 -hmax 400 -elev.default 50 @@ -376,94 +379,88 @@ Pixels values are expressed in meters. Figure 3: Extract of the elevation map over Pyramids of Cheops. -This is it `Figure 3` shows the output DEM from the Cheops pair. +The `Figure 3` shows the output DEM from the Cheops pair. One application to rule them all in multi stereo framework scheme ----------------------------------------------------------------- -An application has been added to fuse one or multiple stereo -reconstruction(s) using all in one approach: *StereoFramework* . It -computes the DSM from one or several stereo pair. First of all the user -have to choose his input data and defines stereo couples using -*-input.co* string parameter. This parameter use the following -formatting convention “ :math:`index_{0}` :math:`index_{1}`, -:math:`index_{2}` :math:`index_{3}`, …â€, which will create a first -couple with image :math:`index_{0}` and :math:`index_{1}`, a second with -image :math:`index_{1}` and :math:`index_{2}`, and so on. If left blank +An application has been created to fuse one or multiple stereo +reconstruction(s) using all-in-one approach: *StereoFramework* . It +computes the DSM from one or several stereo pairs. First of all the user +has to choose his input data and defines stereo couples using +*-input.co* string parameter. Each couple is defined by 2 image indexes "a b" +(starting at 0) separated by a space character. The different pairs are +concatenated with coma. For instance "0 1,0 2" will define the image pairs +"first with second", and "first with third". If left blank, images are processed by pairs (which is equivalent as using “ 0 1,2 3,4 5 †…). In addition to the usual elevation and projection parameters, main parameters have been split in groups detailed below: -Output: - output parameters: DSM resolution, NoData value, Cell Fusion - method, +- **output**: Output parameters (DSM resolution, NoData value, Cell Fusion + method) - Output projection map selection. - Spatial Sampling Distance of the output DSM in meters - - DSM empty cells are filled with this float value (-32768 by - default) + - DSM empty cells are filled with a float value (-32768 by + default) - Choice of fusion strategy in each DSM cell (max, min, mean, - acc) + acc) - Output DSM - - Output DSM extent choice + - Extent of output DSM -Stereorect: - Direct and inverse stereorectification grid subsampling parameters +- **stereorect**: Direct and inverse stereorectification grid subsampling parameters - Step of the direct deformation grid (in pixels) - Sub-sampling of the inverse epipolar grid -BM: - Block Matching parameters. +- **bm**: Block Matching parameters. - Block-matching metric choice (robust SSD, SSD, NCC, Lp Norm) - Radius of blocks for matching filter (in pixels, :math:`2` by - default) + default) - Minimum altitude below the selected elevation source (in - meters, -20.0 by default) + meters, -20.0 by default) - Maximum altitude above the selected elevation source (in - meters, 20.0 by default) + meters, 20.0 by default) -Postproc: - Post-Processing parameters +- **postproc**: Post-Processing parameters - Use bijection consistency. Right to Left correlation is - computed to validate Left to Right disparities. If bijection is - not found pixel is rejected + computed to validate Left to Right disparities. If bijection is + not found, pixel is rejected - Use median disparities filtering (disabled by default) - Use block matching metric output to discard pixels with low - correlation value (disabled by default, float value)"); + correlation value (disabled by default, float value) -Mask: - Compute optional intermediate masks. +- **mask**: Compute optional intermediate masks. - Mask for left input image (must have the same size for all - couples) + couples) - Mask for right input image (must have the same size for all - couples) + couples) - This parameter allows to discard pixels whose local variance is - too small. The size of the neighborhood is given by the radius - parameter. (disabledd by default) + too small. The size of the neighborhood is given by the radius + parameter. (disabled by default) Stereo reconstruction good practices ------------------------------------ -The parameters and are used inside the application to derive the minimum -and maximum horizontal disparity exploration, so they have a critical -impact on computation time. It is advised to choose an elevation source +The parameters for altitude offset are used inside the application to derive +the minimum and maximum horizontal disparity exploration, so they have a +critical impact on computation time. It is advised to choose an elevation source that is not too far from the DSM you want to produce (for instance, an SRTM elevation model). Therefore, the altitude from your elevation source will be already taken into account in the epipolar geometry and @@ -472,9 +469,6 @@ It allows you to use a smaller exploration range along the elevation axis, causing a smaller exploration along horizontal disparities and faster computation. -and have also a deep impact in time consumption, thus they have to be -carefully chosen in case of large image processing. - To reduce time consumption it would be useful to crop all sensor images to the same extent. The easiest way to do that is to choose an image as reference, and then apply *ExtractROI* application on the other sensor @@ -496,9 +490,9 @@ pair - Compute horizontal disparities with a block matching algorithm -- Refing Disparities to sub-pixel precision with a dichotomy algorithm +- Refine disparities to sub-pixel precision with a dichotomy algorithm -- Apply an optional Median filter +- Apply an optional median filter - Filter disparities based on the correlation score (optional) and exploration bounds @@ -507,5 +501,5 @@ pair - Convert disparity map to 3D map -Then fuse all 3D maps to produce DSM with desired geographic or +Then all 3D maps are fused to produce a DSM with desired geographic or cartographic projection and parametrizable extent. diff --git a/Documentation/SoftwareGuide/Latex/Classification.tex b/Documentation/SoftwareGuide/Latex/Classification.tex index fc255644fb110ecb3103750e46838a703649f86e..90e4b41d462b8f717722d811ffcf49a5cd8bad7f 100644 --- a/Documentation/SoftwareGuide/Latex/Classification.tex +++ b/Documentation/SoftwareGuide/Latex/Classification.tex @@ -64,197 +64,116 @@ properties than the image to classify, in order to build a classification model. %to other OTB libraries (edit the \code{TARGET\_LINK\_LIBRARIES} to add them), %for example OTBLearning, OTBMarkov. -\section{Unsupervised classification} - -\subsection{K-Means Classification} -\label{sec:KMeansClassifier} - -\subsubsection{Simple version} -\ifitkFullVersion -\input{ScalarImageKmeansClassifier.tex} -\fi -\ifitkFullVersion -\input{ScalarImageKmeansModelEstimator.tex} -\fi - -\subsubsection{General approach} -\ifitkFullVersion -\input{KMeansImageClassificationExample.tex} -\fi - -\subsubsection{k-d Tree Based k-Means Clustering} -\label{sec:KdTreeBasedKMeansClustering} -\ifitkFullVersion -\input{KdTreeBasedKMeansClustering.tex} -\fi - -\subsection{Kohonen's Self Organizing Map} -\label{sec:SOM} -\input{Kohonen} -%%%1. Construction SOM -\subsubsection{Building a color table} -\label{sec:SOMColorTable} -\input{SOMExample} -\subsubsection{SOM Classification} -\label{sec:SOMClassification} -\input{SOMClassifierExample} - -\subsubsection{Multi-band, streamed classification} - -\ifitkFullVersion -\input{SOMImageClassificationExample.tex} -\fi - -%%%2. Lecture SOM et ensemble de vecteurs autre image pour construire -%%%ActivationMAP - -%\subsection{Bayesian classification} - -\subsection{Bayesian Plug-In Classifier} -\label{sec:BayesianPluginClassifier} - -\ifitkFullVersion -\input{BayesianPluginClassifier.tex} -\fi - - -\subsection{Expectation Maximization Mixture Model Estimation} -\label{sec:ExpectationMaximizationMixtureModelEstimation} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Machine Learning Framework} -\ifitkFullVersion -\input{ExpectationMaximizationMixtureModelEstimator.tex} -\fi - - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\subsection{Statistical Segmentations} -\label{sec:StatisticalSegmentations} - -%\subsection{Markov Random Fields} +\subsection{Machine learning models} +\label{sec:MLGenericFramework} -\subsubsection{Stochastic Expectation Maximization} -\label{sec:SEM} +The OTB classification is implemented as a generic Machine Learning +framework, supporting several possible machine learning libraries as backends. +The base class \doxygen{otb}{MachineLearningModel} defines this framework. +As of now libSVM (the machine learning library historically integrated in OTB), +machine learning methods of OpenCV library (\cite{opencv_library}) and also +Shark machine learning library (\cite{shark_library}) are available. Both +supervised and unsupervised classifiers are supported in the framework. -The Stochastic Expectation Maximization (SEM) approach is a stochastic -version of the EM mixture estimation seen on -section~\ref{sec:ExpectationMaximizationMixtureModelEstimation}. It has been -introduced by \cite{CeDi95} to prevent convergence of the EM approach from -local minima. It avoids the analytical maximization issued by integrating a -stochastic sampling procedure in the estimation process. It induces an almost -sure (a.s.) convergence to the algorithm. +The current list of classifiers available through the same generic interface within the OTB is: -From the initial two step formulation of the EM mixture estimation, the SEM -may be decomposed into 3 steps: -\begin{enumerate} -\item \textbf{E-step}, calculates the expected membership values for each -measurement vector to each classes. -\item \textbf{S-step}, performs a stochastic sampling of the membership vector -to each classes, according to the membership values computed in the E-step. -\item \textbf{M-step}, updates the parameters of the membership probabilities -(parameters to be defined through the class -\subdoxygen{itk}{Statistics}{ModelComponentBase} and its inherited classes). -\end{enumerate} -The implementation of the SEM has been turned to a contextual SEM in the sense -where the evaluation of the membership parameters is conditioned to -membership values of the spatial neighborhood of each pixels. +\begin{itemize} + \item \textbf{LibSVM}: Support Vector Machines classifier based on libSVM. + \item \textbf{SVM}: Support Vector Machines classifier based on OpenCV, itself based on libSVM. + \item \textbf{Bayes}: Normal Bayes classifier based on OpenCV. + \item \textbf{Boost}: Boost classifier based on OpenCV. + \item \textbf{DT}: Decision Tree classifier based on OpenCV. + \item \textbf{RF}: Random Forests classifier based on the Random Trees in OpenCV. + \item \textbf{GBT}: Gradient Boosted Tree classifier based on OpenCV (removed in version 3). + \item \textbf{KNN}: K-Nearest Neighbors classifier based on OpenCV. + \item \textbf{ANN}: Artificial Neural Network classifier based on OpenCV. + \item \textbf{SharkRF} : Random Forests classifier based on Shark. + \item \textbf{SharkKM} : KMeans unsupervised classifier based on Shark. +\end{itemize} -\ifitkFullVersion -\input{SEMModelEstimatorExample.tex} -\fi +These models have a common interface, with the following major functions: +\begin{itemize} + \item \code{SetInputListSample(InputListSampleType *in)} : set the list of input samples + \item \code{SetTargetListSample(TargetListSampleType *in)} : set the list of target samples + \item \code{Train()} : train the model based on input samples + \item \code{Save(...)} : saves the model to file + \item \code{Load(...)} : load a model from file + \item \code{Predict(...)} : predict a target value for an input sample + \item \code{PredictBatch(...)} : prediction on a list of input samples +\end{itemize} +The \code{PredictBatch(...)} function can be multi-threaded when +called either from a multi-threaded filter, or from a single location. In +the later case, it creates several threads using OpenMP. +There is a factory mechanism on top of the model class (see +\doxygen{otb}{MachineLearningModelFactory}). Given an input file, +the static function \code{CreateMachineLearningModel(...)} is able +to instanciate a model of the right type. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +For unsupervised models, the target samples \textbf{still have to be set}. They +won't be used so you can fill a ListSample with zeros. -\subsection{Classification using Markov Random Fields} -\label{sec:MarkovRandomField} +%------------------------------------------------------------------------------- +\subsection{Training a model} -Markov Random Fields are probabilistic models that use the statistical -dependency between -pixels in a neighborhood to infeer the value of a give pixel. +The models are trained from a list of input samples, stored in a +\subdoxygen{itk}{Statistics}{ListSample}. For supervised classifiers, they +also need a list of targets associated to each input sample. Whatever the +source of samples, it has to be converted into a \code{ListSample} before +being fed into the model. -\subsubsection{ITK framework} -\label{sec:MarkovRandomFieldITK} -The -\subdoxygen{itk}{Statistics}{MRFImageFilter} uses the maximum a posteriori (MAP) -estimates for modeling the MRF. The object traverses the data set and uses the -model generated by the Mahalanobis distance classifier to get the the distance -between each pixel in the data set to a set of known classes, updates the -distances by evaluating the influence of its neighboring pixels (based on a MRF -model) and finally, classifies each pixel to the class which has the minimum -distance to that pixel (taking the neighborhood influence under consideration). -The energy function minimization is done using the iterated conditional modes -(ICM) algorithm \cite{Besag1986}. +Then, model-specific parameters can be set. And finally, the \code{Train()} +method starts the learning step. Once the model is trained it can be saved +to file using the function \code{Save()}. The following examples show how +to do that. -\ifitkFullVersion -\input{ScalarImageMarkovRandomField1.tex} -\fi +\input{TrainMachineLearningModelFromSamplesExample.tex} -\subsubsection{OTB framework} -\label{sec:MarkovRandomFieldOTB} -The ITK approach was considered not to be flexible enough for some -remote sensing applications. Therefore, we decided to implement our -own framework. -\index{Markov} +\input{TrainMachineLearningModelFromImagesExample.tex} -\begin{figure}[th] - \centering - \includegraphics[width=0.7\textwidth]{MarkovFramework.eps} - \itkcaption[OTB Markov Framework]{OTB Markov Framework.} - \label{fig:markovFramework} -\end{figure} +%------------------------------------------------------------------------------- +\subsection{Prediction of a model} -\index{Markov!Classification} -\ifitkFullVersion -\input{MarkovClassification1Example.tex} -\fi +For the prediction step, the usual process is to: +\begin{itemize} +\item Load an existing model from a file. +\item Convert the data to predict into a \code{ListSample}. +\item Run the \code{PredictBatch(...)} function. +\end{itemize} -\index{Markov!Classification} -\ifitkFullVersion -\input{MarkovClassification2Example.tex} -\fi +There is an image filter that perform this step on a whole image, supporting +streaming and multi-threading: \doxygen{otb}{ImageClassificationFilter}. -\index{Markov!Classification} \ifitkFullVersion -\input{MarkovClassification3Example.tex} -\fi +\input{SupervisedImageClassificationExample.tex} +\fi -\index{Markov!Regularization} -\ifitkFullVersion -\input{MarkovRegularizationExample.tex} -\fi +%------------------------------------------------------------------------------- +\subsection{Integration in applications} +The classifiers are integrated in several OTB Applications. There is a base +class that provides an easy access to all the classifiers: +\subdoxygen{otb}{Wrapper}{LearningApplicationBase}. As each machine learning +model has a specific set of parameters, the base class +\code{LearningApplicationBase} knows how to expose each type of classifier with +its dedicated parameters (a task that is a bit tedious so we want to implement +it only once). The \code{DoInit()} method creates a choice parameter named +\code{classifier} which contains the different supported classifiers along +with their parameters. +The function \code{Train(...)} provide an easy way to train the selected +classifier, with the corresponding parameters, and save the model to file. +On the other hand, the function \code{Classify(...)} allows to load a model +from file and apply it on a list of samples. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Supervised classification} -\subsection{Generic machine learning framework} -\label{sec:MLGenericFramework} - -The OTB supervised classification is implemented as a generic Machine Learning -framework, supporting several possible machine learning libraries as backends. -As of now libSVM (the machine learning library historically integrated in OTB), -machine learning methods of OpenCV library (\cite{opencv_library}) and also -Shark machine learning library (\cite{shark_library}) are available. - -The current list of classifiers available through the same generic interface within the OTB is: - -\begin{itemize} - \item \textbf{LibSVM}: Support Vector Machines classifier based on libSVM. - \item \textbf{SVM}: Support Vector Machines classifier based on OpenCV, itself based on libSVM. - \item \textbf{Bayes}: Normal Bayes classifier based on OpenCV. - \item \textbf{Boost}: Boost classifier based on OpenCV. - \item \textbf{DT}: Decision Tree classifier based on OpenCV. - \item \textbf{RF}: Random Forests classifier based on the Random Trees in OpenCV. - \item \textbf{GBT}: Gradient Boosted Tree classifier based on OpenCV. - \item \textbf{KNN}: K-Nearest Neighbors classifier based on OpenCV. - \item \textbf{ANN}: Artificial Neural Network classifier based on OpenCV. -\end{itemize} - - -\subsection{An example of supervised classification method: Support Vector Machines} +\subsection{Support Vector Machines} \label{sec:SupportVectorMachines} \subsubsection{SVM general description} @@ -371,33 +290,35 @@ is the one that we use, the final decision is taken by choosing the class which is most often selected by the whole set of SVM. +%------------------------------------------------------------------------------- +\subsection{Shark Random Forests} -\subsection{Learning from samples} -\label{ssec:LearningFromSamples} -\input{TrainMachineLearningModelFromSamplesExample.tex} - -\subsection{Learning from images} -\label{ssec:LearningFromImages} -\input{TrainMachineLearningModelFromImagesExample.tex} - -%\subsection{Image Classification} -%\label{sec:ImageClassification} -%\input{SVMImageEstimatorClassificationMultiExample} - - -\subsection{Multi-band, streamed classification} - -\ifitkFullVersion -\input{SupervisedImageClassificationExample.tex} -\fi - +The Random Forests algorithm is also available in OTB machine learning +framework. This model builds a set of decision trees. Each tree may not give +a reliable prediction, but taking them together, they form a robust classifier. +The prediction of this model is the mode of the predictions of individual trees. +There are two implementations: one in OpenCV and the other on in +Shark. The Shark implementation has a noteworthy advantage: the training step +is parallel. It uses the following parameters: +\begin{itemize} +\item The number of trees to train +\item The number of random attributes to investigate at each node +\item The maximum node size to decide a split +\item The ratio of the original training dataset to use as the out of bag sample +\end{itemize} +Except these specific parameter, its usage is exactly the same as the other +machine learning models (such as the SVM model). -\subsection{Generic Kernel SVM} +%------------------------------------------------------------------------------- +\subsection{Generic Kernel SVM (deprecated)} OTB has developed a specific interface for user-defined kernels. However, the -following functions use a deprecated OTB interface. A function -$k(\cdot,\cdot)$ is considered to be a kernel when: +following functions use a deprecated OTB interface. The code source for these +Generic Kernels has been removed from the official repository. It is now +available as a remote module: \href{https://github.com/jmichel-otb/GKSVM}{GKSVM}. + +A function $k(\cdot,\cdot)$ is considered to be a kernel when: \begin{align}\label{eqMercer} \forall g(\cdot) \in {\cal L}^2(\mathbbm{R}^n) \quad & \text{so that} \quad @@ -428,7 +349,7 @@ with: \end{verbatim} This simple example shows that the classical dot product is already implemented -into \subdoxygen{otb}{GenericKernelFunctorBase}{dot()} as a protected +into \code{otb::GenericKernelFunctorBase::dot()} as a protected function. \item The \code{Update()} function which synchronizes local variables and their @@ -438,16 +359,16 @@ the way to use it. Some pre-defined generic kernels have already been implemented in OTB: \begin{itemize} -\item \doxygen{otb}{MixturePolyRBFKernelFunctor} which implements a +\item \code{otb::MixturePolyRBFKernelFunctor} which implements a linear mixture of a polynomial and a RBF kernel; -\item \doxygen{otb}{NonGaussianRBFKernelFunctor} which implements a non +\item \code{otb::NonGaussianRBFKernelFunctor} which implements a non gaussian RBF kernel; -\item \doxygen{otb}{SpectralAngleKernelFunctor}, a kernel that integrates +\item \code{otb::SpectralAngleKernelFunctor}, a kernel that integrates the Spectral Angle, instead of the Euclidean distance, into an inverse multiquadric kernel. This kernel may be appropriated when using multispectral data. -\item \doxygen{otb}{ChangeProfileKernelFunctor}, a kernel which is +\item \code{otb::ChangeProfileKernelFunctor}, a kernel which is dedicated to the supervized classification of the multiscale change profile presented in section \ref{sec:KullbackLeiblerProfile}. \end{itemize} @@ -465,8 +386,185 @@ presented in section \ref{sec:KullbackLeiblerProfile}. \fi +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Unsupervised classification} + +\subsection{K-Means Classification} +\label{sec:KMeansClassifier} + +\subsubsection{Shark version} + +The KMeans algorithm has been implemented in Shark library, and has been +wrapped in the OTB machine learning framework. It is the first unsupervised +algorithm in this framework. It can be used in the same way as other machine +learning models. Remember that even if unsupervised model don't use a label +information on the samples, the target ListSample still has to be set in +\code{MachineLearningModel}. A ListSample filled with zeros can be used. + +This model uses a hard clustering model with the following parameters: +\begin{itemize} +\item The maximum number of iterations +\item The number of centroids (K) +\item An option to normalize input samples +\end{itemize} + +As with Shark Random Forests, the training step is parallel. + +\subsubsection{Simple version} +\ifitkFullVersion +\input{ScalarImageKmeansClassifier.tex} +\fi +\ifitkFullVersion +\input{ScalarImageKmeansModelEstimator.tex} +\fi + +\subsubsection{General approach} +\ifitkFullVersion +\input{KMeansImageClassificationExample.tex} +\fi + +\subsubsection{k-d Tree Based k-Means Clustering} +\label{sec:KdTreeBasedKMeansClustering} +\ifitkFullVersion +\input{KdTreeBasedKMeansClustering.tex} +\fi +%------------------------------------------------------------------------------- +\subsection{Kohonen's Self Organizing Map} +\label{sec:SOM} +\input{Kohonen} +%%%1. Construction SOM +\subsubsection{Building a color table} +\label{sec:SOMColorTable} +\input{SOMExample} +\subsubsection{SOM Classification} +\label{sec:SOMClassification} +\input{SOMClassifierExample} + +\subsubsection{Multi-band, streamed classification} + +\ifitkFullVersion +\input{SOMImageClassificationExample.tex} +\fi + +%%%2. Lecture SOM et ensemble de vecteurs autre image pour construire +%%%ActivationMAP + +%\subsection{Bayesian classification} +%------------------------------------------------------------------------------- +\subsection{Bayesian Plug-In Classifier} +\label{sec:BayesianPluginClassifier} + +\ifitkFullVersion +\input{BayesianPluginClassifier.tex} +\fi + +%------------------------------------------------------------------------------- +\subsection{Expectation Maximization Mixture Model Estimation} +\label{sec:ExpectationMaximizationMixtureModelEstimation} + +\ifitkFullVersion +\input{ExpectationMaximizationMixtureModelEstimator.tex} +\fi + + + +%------------------------------------------------------------------------------- +\subsection{Statistical Segmentations} +\label{sec:StatisticalSegmentations} +%\subsection{Markov Random Fields} + +\subsubsection{Stochastic Expectation Maximization} +\label{sec:SEM} + +The Stochastic Expectation Maximization (SEM) approach is a stochastic +version of the EM mixture estimation seen on +section~\ref{sec:ExpectationMaximizationMixtureModelEstimation}. It has been +introduced by \cite{CeDi95} to prevent convergence of the EM approach from +local minima. It avoids the analytical maximization issued by integrating a +stochastic sampling procedure in the estimation process. It induces an almost +sure (a.s.) convergence to the algorithm. + +From the initial two step formulation of the EM mixture estimation, the SEM +may be decomposed into 3 steps: +\begin{enumerate} +\item \textbf{E-step}, calculates the expected membership values for each +measurement vector to each classes. +\item \textbf{S-step}, performs a stochastic sampling of the membership vector +to each classes, according to the membership values computed in the E-step. +\item \textbf{M-step}, updates the parameters of the membership probabilities +(parameters to be defined through the class +\subdoxygen{itk}{Statistics}{ModelComponentBase} and its inherited classes). +\end{enumerate} +The implementation of the SEM has been turned to a contextual SEM in the sense +where the evaluation of the membership parameters is conditioned to +membership values of the spatial neighborhood of each pixels. + +\ifitkFullVersion +\input{SEMModelEstimatorExample.tex} +\fi + +%------------------------------------------------------------------------------- +\subsection{Classification using Markov Random Fields} +\label{sec:MarkovRandomField} + +Markov Random Fields are probabilistic models that use the statistical +dependency between +pixels in a neighborhood to infeer the value of a give pixel. + +\subsubsection{ITK framework} +\label{sec:MarkovRandomFieldITK} +The +\subdoxygen{itk}{Statistics}{MRFImageFilter} uses the maximum a posteriori (MAP) +estimates for modeling the MRF. The object traverses the data set and uses the +model generated by the Mahalanobis distance classifier to get the the distance +between each pixel in the data set to a set of known classes, updates the +distances by evaluating the influence of its neighboring pixels (based on a MRF +model) and finally, classifies each pixel to the class which has the minimum +distance to that pixel (taking the neighborhood influence under consideration). +The energy function minimization is done using the iterated conditional modes +(ICM) algorithm \cite{Besag1986}. + +\ifitkFullVersion +\input{ScalarImageMarkovRandomField1.tex} +\fi + +\subsubsection{OTB framework} +\label{sec:MarkovRandomFieldOTB} +The ITK approach was considered not to be flexible enough for some +remote sensing applications. Therefore, we decided to implement our +own framework. +\index{Markov} + +\begin{figure}[th] + \centering + \includegraphics[width=0.7\textwidth]{MarkovFramework.eps} + \itkcaption[OTB Markov Framework]{OTB Markov Framework.} + \label{fig:markovFramework} +\end{figure} + +\index{Markov!Classification} +\ifitkFullVersion +\input{MarkovClassification1Example.tex} +\fi + +\index{Markov!Classification} +\ifitkFullVersion +\input{MarkovClassification2Example.tex} +\fi + +\index{Markov!Classification} +\ifitkFullVersion +\input{MarkovClassification3Example.tex} +\fi + +\index{Markov!Regularization} +\ifitkFullVersion +\input{MarkovRegularizationExample.tex} +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Fusion of Classification maps} \subsection{General approach of image fusion} @@ -476,7 +574,7 @@ fuse several classification maps coming from different classification methods classification maps combines them in a more robust and precise one. Two methods are available in the OTB: the majority voting and the Demspter Shafer framework. - +%------------------------------------------------------------------------------- \subsection{Majority voting} \subsubsection{General description} For each input pixel, the Majority Voting method consists in choosing the more @@ -489,7 +587,7 @@ the fused output image. \input{MajorityVotingFusionOfClassificationMapsExample.tex} \fi - +%------------------------------------------------------------------------------- \subsection{Dempster Shafer} \subsubsection{General description} @@ -527,7 +625,7 @@ algorithm is available in the following OTB Wiki page: \fi - +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Classification map regularization} %\subsection{Regularization by neighborhood-based majority voting} diff --git a/Documentation/SoftwareGuide/Latex/ImageRegistration.tex b/Documentation/SoftwareGuide/Latex/ImageRegistration.tex index 16d28a686326fc9d753fef6b56dcd0beb0d432f8..06c0f909466dab79bd10813ca06a140acfe0266c 100644 --- a/Documentation/SoftwareGuide/Latex/ImageRegistration.tex +++ b/Documentation/SoftwareGuide/Latex/ImageRegistration.tex @@ -502,9 +502,9 @@ describe the main characteristics of such transforms. %% The first case can be solved with a closed form solution when we are dealing %% with a Rigid or an Affine Transform~\cite{Horn1987}. This is done in ITK with -%% the class \doxygen{LandmarkBasedTransformInitializer}. If we are interested in +%% the class \doxygen{itk}{LandmarkBasedTransformInitializer}. If we are interested in %% a deformable Transformation then the problem can be solved with the -%% \doxygen{KernelTransform} family of classes, which includes Thin Plate Splines +%% \doxygen{itk}{KernelTransform} family of classes, which includes Thin Plate Splines %% among others~\cite{Rohr2001}. In both circumstances, the availability o f %% correspondences between the points make possible to apply a straight forward %% solution to the problem. diff --git a/Documentation/SoftwareGuide/Latex/Optimizers.tex b/Documentation/SoftwareGuide/Latex/Optimizers.tex index bc59c6845db754d067be0d22ba2a1e8dd2cee31b..eb865a56fb50a7f50b2f72c37e08191e1d007355 100644 --- a/Documentation/SoftwareGuide/Latex/Optimizers.tex +++ b/Documentation/SoftwareGuide/Latex/Optimizers.tex @@ -118,7 +118,7 @@ optimizer in \code{netlib}. Details on this optimizer can be found in~\cite{Byrd1995,Zhu1997} (\doxygen{itk}{LBFGSBOptimizer}). \item \textbf{One Plus One Evolutionary}: Strategy that simulates the -biological evolution of a set of samples in the search space (\doxygen{itk}{OnePlusOneEvolutionaryOptimizer.}). Details on this optimizer can be +biological evolution of a set of samples in the search space (\doxygen{itk}{OnePlusOneEvolutionaryOptimizer}). Details on this optimizer can be found in~\cite{Styner2000}. \item \textbf{Regular Step Gradient Descent}: Advances parameters in the diff --git a/Documentation/SoftwareGuide/Latex/WriteAnApplication.tex b/Documentation/SoftwareGuide/Latex/WriteAnApplication.tex index f019cba0774c7460ea73be2d85277e7296443fc0..b4029d13e7dce361ba0a43fb1e5c4306fd3d3cf0 100644 --- a/Documentation/SoftwareGuide/Latex/WriteAnApplication.tex +++ b/Documentation/SoftwareGuide/Latex/WriteAnApplication.tex @@ -30,7 +30,7 @@ divisions (see section \ref{sec:appParam}). \section{Architecture of the class} \label{sec:appArchitecture} -Every application derive from the class \doxygen{otb}{Wrapper::Application}. An +Every application derive from the class \subdoxygen{otb}{Wrapper}{Application}. An application can't be templated. It must contain the standard class typedefs and a call to the \code{OTB\_APPLICATION\_EXPORT} macro. @@ -53,8 +53,8 @@ contain the following actions: \item Fill the documentation and give an example \item Declare all the parameters \item Define the documentation link: - \item for contrib application use SetDocLink("\textit{docLink}") function defined in \doxygen{otb}{Wrapper::Application} - \item for official application use SetOfficialDocLink() function defined in \doxygen{otb}{Wrapper::Application} + \item for contrib application use SetDocLink("\textit{docLink}") function defined in \subdoxygen{otb}{Wrapper}{Application} + \item for official application use SetOfficialDocLink() function defined in \subdoxygen{otb}{Wrapper}{Application} \end{itemize} @@ -97,7 +97,7 @@ created and updated. \subsection{Parameters selection} \label{sec:appParam} In the new application framework, every input, output or parameter derive from -\doxygen{otb}{Wrapper::Parameter}. The application engine supplies the following +\subdoxygen{otb}{Wrapper}{Parameter}. The application engine supplies the following types of parameters: \begin{itemize} \item \code{ParameterType\_Empty} : parameter without value (can be used to represent @@ -136,7 +136,7 @@ can be used to set a parameter optional or test if the user has modified the par are created in the \code{DoInit()} method, then the framework will set their value (either by parsing the command line or reading the graphical user interface). The \code{DoExecute()} method is called when all mandatory parameters have been given a value, which can be obtained with "Get" methods defined in -\doxygen{otb}{Wrapper::Application}. Parameters are set mandatory (or not) using \code{MandatoryOn(key)} method (\code{MandatoryOff(key)}). +\subdoxygen{otb}{Wrapper}{Application}. Parameters are set mandatory (or not) using \code{MandatoryOn(key)} method (\code{MandatoryOff(key)}). Some functions are specific to numeric parameters, such as \code{SetMinimumParameterIntValue(key,value)} or \code{SetMaximumParameterFloatValue(key,value)}. By default, numeric parameters are treated as inputs. @@ -158,7 +158,7 @@ that you want to chain in order to build a third application C. Rather than writ the code of A and B, you would like to re-use applications A and B. This plain example will be re-used in this section for explanations. -A dedicated class \doxygen{otb}{Wrapper::CompositeApplication} has been added to create such applications. +A dedicated class \subdoxygen{otb}{Wrapper}{CompositeApplication} has been added to create such applications. If you derive this class to implement application C, you will be able to create a composite application. \subsection{Creating internal applications} diff --git a/Documentation/SoftwareGuide/SoftwareGuideConfiguration.tex.in b/Documentation/SoftwareGuide/SoftwareGuideConfiguration.tex.in index 02868b264c65bf63aac1c3cb7c802772b1e72efc..22bd0cb1bad7d83d5e714fd11fbb266630a4a895 100644 --- a/Documentation/SoftwareGuide/SoftwareGuideConfiguration.tex.in +++ b/Documentation/SoftwareGuide/SoftwareGuideConfiguration.tex.in @@ -11,12 +11,17 @@ }{ \href{http://www.orfeo-toolbox.org/doxygen/class#1_1_1#2.html}{\code{#1::#2}} }{ -\href{http://www.itk.org/Doxygen46/html/class#1_1_1#2.html}{\code{#1::#2}} +\href{http://www.itk.org/Doxygen/html/class#1_1_1#2.html}{\code{#1::#2}} }} % Define command to make reference to on-line Doxygen documentation \newcommand{\subdoxygen}[3]{ -\href{http://www.orfeo-toolbox.org/doxygen/class#1_1_1#2_1_1#3.html}{\code{#1::#2::#3}}} +\ifthenelse{ \equal{#1}{otb} +}{ +\href{http://www.orfeo-toolbox.org/doxygen/class#1_1_1#2_1_1#3.html}{\code{#1::#2::#3}} +}{ +\href{http://www.itk.org/Doxygen/html/class#1_1_1#2_1_1#3.html}{\code{#1::#2::#3}} +}} % Define command for the standard comment introducing classes with similar functionalities \newcommand{\relatedClasses}{ diff --git a/Examples/Application/ApplicationExample.cxx b/Examples/Application/ApplicationExample.cxx index 698c7d612219f770edd0e0fb7b533eef1c7a1260..007a204635ef56046dc0aa9fc4e11b2b43100619 100644 --- a/Examples/Application/ApplicationExample.cxx +++ b/Examples/Application/ApplicationExample.cxx @@ -28,7 +28,7 @@ // Software Guide : BeginLatex // This example illustrates the creation of an application. -// A new application is a class, which derives from \doxygen{otb}{Wrapper::Application} class. +// A new application is a class, which derives from \subdoxygen{otb}{Wrapper}{Application} class. // We start by including the needed header files. // // Software Guide : EndLatex @@ -147,7 +147,7 @@ private: // Software Guide : BeginLatex // Application parameters declaration is done using \code{AddParameter()} method. // \code{AddParameter()} requires Parameter type, its name and description. - // \doxygen{otb}{Wrapper::Application} class contains methods to set parameters characteristics. + // \subdoxygen{otb}{Wrapper}{Application} class contains methods to set parameters characteristics. // Software Guide : EndLatex // Software Guide : BeginCodeSnippet diff --git a/Examples/Classification/BayesianPluginClassifier.cxx b/Examples/Classification/BayesianPluginClassifier.cxx index 792b68265f945c49827459db3e2919a47022c286..fa5d0c764af7bb3930a5d89dc867b57f61af03db 100644 --- a/Examples/Classification/BayesianPluginClassifier.cxx +++ b/Examples/Classification/BayesianPluginClassifier.cxx @@ -32,7 +32,7 @@ // all the components of the classifier system and the data flow. This system // differs with the previous k-means clustering algorithms in several // ways. The biggest difference is that this classifier uses the -// \subdoxygen{itk}{Statistics}{itkGaussianMembershipFunction} as membership functions +// \subdoxygen{itk}{Statistics}{GaussianMembershipFunction} as membership functions // instead of the \subdoxygen{itk}{Statistics}{EuclideanDistanceMetric}. Since the // membership function is different, the membership function requires a // different set of parameters, mean vectors and covariance matrices. We diff --git a/Examples/Classification/ExpectationMaximizationMixtureModelEstimator.cxx b/Examples/Classification/ExpectationMaximizationMixtureModelEstimator.cxx index 3d16c589b8d645d41525513399908c83d4262e7b..63067f669fb86903b1f0f6cd3555b3681b24de9d 100644 --- a/Examples/Classification/ExpectationMaximizationMixtureModelEstimator.cxx +++ b/Examples/Classification/ExpectationMaximizationMixtureModelEstimator.cxx @@ -74,7 +74,7 @@ // class assumes that such type of components. // // In the following example we use the \subdoxygen{itk}{Statistics}{ListSample} as -// the sample (test and training). The \subdoxygen{itk}{Vector} is our measurement +// the sample (test and training). The \doxygen{itk}{Vector} is our measurement // vector class. To store measurement vectors into two separate sample // container, we use the \subdoxygen{itk}{Statistics}{Subsample} objects. // diff --git a/Examples/DataRepresentation/Image/ImageListExample.cxx b/Examples/DataRepresentation/Image/ImageListExample.cxx index 81f21bc1f8ca4775d553b0085150d7cb6c682cff..d2f09626c149085c3bb2a39b845ec616d94f5daf 100644 --- a/Examples/DataRepresentation/Image/ImageListExample.cxx +++ b/Examples/DataRepresentation/Image/ImageListExample.cxx @@ -21,7 +21,7 @@ // Software Guide : BeginLatex // -// This example illustrates the use of the \subdoxygen{otb}{ImageList} +// This example illustrates the use of the \doxygen{otb}{ImageList} // class. This class provides the functionnalities needed in order to // integrate image lists as data objects into the OTB // pipeline. Indeed, if a \code{std::list< ImageType >} was used, the @@ -29,10 +29,10 @@ // effects. // // In this example, we will only present the basic operations which -// can be applied on an \subdoxygen{otb}{ImageList} object. +// can be applied on an \doxygen{otb}{ImageList} object. // // The first thing required to read an image from a file is to include -// the header file of the \subdoxygen{otb}{ImageFileReader} class. +// the header file of the \doxygen{otb}{ImageFileReader} class. // // Software Guide : EndLatex @@ -70,7 +70,7 @@ int main(int itkNotUsed(argc), char * argv[]) // Software Guide : BeginLatex // // We can now define the type for the image list. The -// \subdoxygen{otb}{ImageList} class is templated over the type of image +// \doxygen{otb}{ImageList} class is templated over the type of image // contained in it. This means that all images in a list must have the // same type. // @@ -146,7 +146,7 @@ int main(int itkNotUsed(argc), char * argv[]) // // Also, iterator classes are defined in order to have an efficient // mean of moving through the list. Finally, the -// \subdoxygen{otb}{ImageListToImageListFilter} is provided in order +// \doxygen{otb}{ImageListToImageListFilter} is provided in order // to implement filter which operate on image lists and produce image lists. // Software Guide : EndLatex diff --git a/Examples/DisparityMap/FineRegistrationImageFilterExample.cxx b/Examples/DisparityMap/FineRegistrationImageFilterExample.cxx index 7e730b27f26eca50f284d3ece4ff3ddd516a926d..97fb63f85d0dc0fc792d737ffe35ef6c1c7a6d8e 100644 --- a/Examples/DisparityMap/FineRegistrationImageFilterExample.cxx +++ b/Examples/DisparityMap/FineRegistrationImageFilterExample.cxx @@ -125,7 +125,7 @@ int main(int argc, char** argv) // Software Guide : BeginLatex // - // Now, we declare and instantiate the \doxygen{otb}{FineCorrelationImageFilter} which is going to perform the registration: + // Now, we declare and instantiate the \doxygen{otb}{FineRegistrationImageFilter} which is going to perform the registration: // // Software Guide : EndLatex @@ -188,7 +188,7 @@ int main(int argc, char** argv) // Software Guide : BeginLatex // - // The default matching metric used by the \doxygen{FineRegistrationImageFilter} is standard correlation. + // The default matching metric used by the \doxygen{otb}{FineRegistrationImageFilter} is standard correlation. // However, we may also use any other image-to-image metric provided by ITK. For instance, here is how we // would use the \doxygen{itk}{MutualInformationImageToImageMetric} (do not forget to include the proper header). // diff --git a/Examples/FeatureExtraction/ExtractSegmentsExample.cxx b/Examples/FeatureExtraction/ExtractSegmentsExample.cxx index 7fc0b46b094373b680ec6ad2f236e49b105a5b33..4e4a3706a247275de236e6a6ff5b5959094af837 100644 --- a/Examples/FeatureExtraction/ExtractSegmentsExample.cxx +++ b/Examples/FeatureExtraction/ExtractSegmentsExample.cxx @@ -99,7 +99,7 @@ int main(int argc, char * argv[]) // Software Guide : BeginLatex // - // An \doxygen{ImageFileReader} class is also instantiated in order to read + // An \doxygen{otb}{ImageFileReader} class is also instantiated in order to read // image data from a file. // // Software Guide : EndLatex @@ -110,7 +110,7 @@ int main(int argc, char * argv[]) // Software Guide : BeginLatex // - // An \doxygen{ImageFileWriter} is instantiated in order to write the + // An \doxygen{otb}{ImageFileWriter} is instantiated in order to write the // output image to a file. // // Software Guide : EndLatex diff --git a/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx b/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx index c1277a2c47ad86cba315c0b512ffee30ac989528..0cfac191b53c3e14cba9ca8df3dfe8d0dbe1d781 100644 --- a/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx +++ b/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx @@ -156,7 +156,7 @@ int main(int argc, char * argv[]) // // Before calling the \code{Update()} method of the writer in order to // trigger the pipeline execution, we call the - // \doxygen{GenerateOutputInformation()} of the reader, so the LSD + // \code{GenerateOutputInformation()} of the reader, so the LSD // filter gets the information about image size and spacing. // // Software Guide : EndLatex diff --git a/Examples/FeatureExtraction/RightAngleDetectionExample.cxx b/Examples/FeatureExtraction/RightAngleDetectionExample.cxx index 5d7fa92df2b736d780ef931c91bbdc0cc06d468d..04eaaf308ad0151cca3ff9ea8185cd2976fc0689 100644 --- a/Examples/FeatureExtraction/RightAngleDetectionExample.cxx +++ b/Examples/FeatureExtraction/RightAngleDetectionExample.cxx @@ -194,7 +194,7 @@ int main(int argc, char * argv[]) // // Before calling the \code{Update()} method of the writer in order to // trigger the pipeline execution, we call the - // \doxygen{GenerateOutputInformation()} of the reader, so the + // \code{GenerateOutputInformation()} of the reader, so the // filter gets the information about image size and spacing. // // Software Guide : EndLatex diff --git a/Examples/FeatureExtraction/TouziEdgeDetectorExample.cxx b/Examples/FeatureExtraction/TouziEdgeDetectorExample.cxx index df67b6b9b6521668822c85527c028d17240d9ecb..a68817f104594edb28fe69144dcb8d26d05b84dc 100644 --- a/Examples/FeatureExtraction/TouziEdgeDetectorExample.cxx +++ b/Examples/FeatureExtraction/TouziEdgeDetectorExample.cxx @@ -105,7 +105,7 @@ int main(int argc, char * argv[]) // Software Guide : BeginLatex // - // An \doxygen{ImageFileReader} class is also instantiated in order to read + // An \doxygen{otb}{ImageFileReader} class is also instantiated in order to read // image data from a file. // // Software Guide : EndLatex @@ -116,7 +116,7 @@ int main(int argc, char * argv[]) // Software Guide : BeginLatex // - // An \doxygen{ImageFileWriter} is instantiated in order to write the + // An \doxygen{otb}{ImageFileWriter} is instantiated in order to write the // output image to a file. // // Software Guide : EndLatex diff --git a/Examples/Iterators/ImageSliceIteratorWithIndex.cxx b/Examples/Iterators/ImageSliceIteratorWithIndex.cxx index 1e4d4bfce4fb14b7ebb8f4e9a113ba3af8ce8258..1c7976d96f8a0f22e648a9a955d7866a66ba016c 100644 --- a/Examples/Iterators/ImageSliceIteratorWithIndex.cxx +++ b/Examples/Iterators/ImageSliceIteratorWithIndex.cxx @@ -24,8 +24,8 @@ // // \index{Iterators!and image slices} // -// The \doxygen{ImageSliceIteratorWithIndex} class is an extension of -// \doxygen{ImageLinearIteratorWithIndex} from iteration along lines to +// The \doxygen{itk}{ImageSliceIteratorWithIndex} class is an extension of +// \doxygen{itk}{ImageLinearIteratorWithIndex} from iteration along lines to // iteration along both lines \emph{and planes} in an image. // A \emph{slice} is a 2D // plane spanned by two vectors pointing along orthogonal coordinate axes. The diff --git a/Examples/Iterators/NeighborhoodIterators5.cxx b/Examples/Iterators/NeighborhoodIterators5.cxx index f3792036a1c160923ec3ae8823a6606e4d70792b..b182309bf8f2845a57cdcb6ec2fe8429823c8333 100644 --- a/Examples/Iterators/NeighborhoodIterators5.cxx +++ b/Examples/Iterators/NeighborhoodIterators5.cxx @@ -46,9 +46,9 @@ // 2, stride = 3, end = 8)}, that represents the neighborhood offsets $(1, // -1)$, $(1, 0)$, $(1, 1)$ (see Figure~\ref{fig:NeighborhoodIteratorFig2}). If we // pass this slice as an extra argument to the -// \doxygen{NeighborhoodInnerProduct} function, then the inner product is taken +// \doxygen{itk}{NeighborhoodInnerProduct} function, then the inner product is taken // only along that slice. This ``sliced'' inner product with a 1D -// \doxygen{DerivativeOperator} gives the desired derivative. +// \doxygen{itk}{DerivativeOperator} gives the desired derivative. // // The previous separable Gaussian filtering example can be rewritten using // slices and slice-based inner products. In general, slice-based processing @@ -57,7 +57,7 @@ // Section~\ref{sec:NeighborhoodExample4} becomes impractical or inefficient. // Good examples of slice-based neighborhood processing can be found in any of // the ND anisotropic diffusion function objects, such as -// \doxygen{CurvatureNDAnisotropicDiffusionFunction}. +// \doxygen{itk}{CurvatureNDAnisotropicDiffusionFunction}. // // Software Guide : EndLatex diff --git a/Examples/Learning/SEMModelEstimatorExample.cxx b/Examples/Learning/SEMModelEstimatorExample.cxx index e13d2e659d88bf498447e242405fcb13d13af18e..65ec4960477aef75eff45c0653e45cc550a4d71f 100644 --- a/Examples/Learning/SEMModelEstimatorExample.cxx +++ b/Examples/Learning/SEMModelEstimatorExample.cxx @@ -32,11 +32,11 @@ // \doxygen{otb}{SEMClassifier}. This class performs a stochastic version // of the EM algorithm, but instead of inheriting from // \doxygen{itk}{ExpectationMaximizationMixtureModelEstimator}, we chose to -// inherit from \subdoxygen{itk}{Statistics}{ListSample< TSample >}, +// inherit from \subdoxygen{itk}{Statistics}{ListSample}, // in the same way as \doxygen{otb}{SVMClassifier}. // // The program begins with \doxygen{otb}{VectorImage} and outputs -// \doxygen{itb}{Image}. Then appropriate header files have to be included: +// \doxygen{otb}{Image}. Then appropriate header files have to be included: // // Software Guide : EndLatex @@ -144,7 +144,7 @@ int main(int argc, char * argv[]) // When an initial segmentation is available, the classifier may use it // as image (of type \code{OutputImageType}) or as a // \doxygen{itk}{SampleClassifier} result (of type -// \subdoxygen{itk}{Statistics}{MembershipSample< SampleType >}). +// \subdoxygen{itk}{Statistics}{MembershipSample}). // Software Guide : EndLatex // Software Guide : BeginCodeSnippet @@ -205,7 +205,7 @@ int main(int argc, char * argv[]) // Software Guide : BeginLatex // // The segmentation may outputs a result of type -// \subdoxygen{itk}{Statistics}{MembershipSample< SampleType >} as it is the +// \subdoxygen{itk}{Statistics}{MembershipSample} as it is the // case for the \doxygen{otb}{SVMClassifier}. But when using // \code{GetOutputImage} the output is directly an Image. // diff --git a/Examples/Learning/SOMClassifierExample.cxx b/Examples/Learning/SOMClassifierExample.cxx index d1681051e359e773286fc129d3a833cd991d4c94..cbd6f2d31e3643f431dd1c565165d6f3d77ee3a0 100644 --- a/Examples/Learning/SOMClassifierExample.cxx +++ b/Examples/Learning/SOMClassifierExample.cxx @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) // As for the SOM learning step, we must define the types for the // \code{otb::SOMMap}, and therefore, also for the distance to be // used. We will also define the type for the SOM reader, which is -// actually an \subdoxygen{otb}{ImageFileReader} which the appropriate +// actually an \doxygen{otb}{ImageFileReader} which the appropriate // image type. // // Software Guide : EndLatex @@ -94,7 +94,7 @@ int main(int argc, char* argv[]) // Software Guide : BeginLatex // // The classification will be performed by the -// \subdoxygen{otb}{SOMClassifier}, which, as most of the +// \doxygen{otb}{SOMClassifier}, which, as most of the // classifiers, works on // \subdoxygen{itk}{Statistics}{ListSample}s. In order to be able // to perform an image classification, we will need to use the @@ -218,7 +218,7 @@ int main(int argc, char* argv[]) // // Software Guide : BeginLatex // -// We also declare an \subdoxygen{itk}{ImageRegionIterator} in order +// We also declare an \doxygen{itk}{ImageRegionIterator} in order // to fill the output image with the class labels. // // Software Guide : EndLatex diff --git a/Examples/Learning/SOMExample.cxx b/Examples/Learning/SOMExample.cxx index 9f9d164e942f2c0a5af26d40dd295e75a84cbcf7..814214c4935de5c9701917f9a993422cdf793fc2 100644 --- a/Examples/Learning/SOMExample.cxx +++ b/Examples/Learning/SOMExample.cxx @@ -118,7 +118,7 @@ int main(int itkNotUsed(argc), char* argv[]) // // Software Guide : BeginLatex // -// We can now define the type for the map. The \subdoxygen{otb}{SOMMap} +// We can now define the type for the map. The \doxygen{otb}{SOMMap} // class is templated over the neuron type -- \code{PixelType} here // --, the distance type and the number of dimensions. Note that the // number of dimensions of the map could be different from the one of diff --git a/Examples/Segmentation/VectorConfidenceConnected.cxx b/Examples/Segmentation/VectorConfidenceConnected.cxx index 357577cb68e2c0577b09acd4ae9c97f92489e397..3e4fa502838288f5065efb5378c47fcb0ac46ed7 100644 --- a/Examples/Segmentation/VectorConfidenceConnected.cxx +++ b/Examples/Segmentation/VectorConfidenceConnected.cxx @@ -42,12 +42,13 @@ // This example illustrates the use of the confidence connected concept // applied to images with vector pixel types. The confidence connected // algorithm is implemented for vector images in the class -// \doxygen{VectorConfidenceConnected}. The basic difference between the +// \doxygen{itk}{VectorConfidenceConnectedImageFilter}. The basic difference +// between the // scalar and vector version is that the vector version uses the covariance // matrix instead of a variance, and a vector mean instead of a scalar mean. // The membership of a vector pixel value to the region is measured using the // Mahalanobis distance as implemented in the class -// \subdoxygen{Statistics}{MahalanobisDistanceThresholdImageFunction}. +// \subdoxygen{itk}{Statistics}{MahalanobisDistanceThresholdImageFunction}. // // Software Guide : EndLatex @@ -108,7 +109,7 @@ int main( int argc, char *argv[] ) // Software Guide : BeginLatex // // We now declare the type of the region growing filter. In this case it - // is the \doxygen{VectorConfidenceConnectedImageFilter}. + // is the \doxygen{itk}{VectorConfidenceConnectedImageFilter}. // // Software Guide : EndLatex @@ -211,7 +212,7 @@ int main( int argc, char *argv[] ) // anatomical structure to be segmented. A small neighborhood around the // seed point will be used to compute the initial mean and standard // deviation for the inclusion criterion. The seed is passed in the form - // of a \doxygen{Index} to the \code{SetSeed()} method. + // of a \doxygen{itk}{Index} to the \code{SetSeed()} method. // // \index{itk::Vector\-Confidence\-Connected\-Image\-Filter!SetSeed()} // \index{itk::Vector\-Confidence\-Connected\-Image\-Filter!SetInitialNeighborhoodRadius()} diff --git a/Examples/Simulation/LAIAndPROSAILToSensorResponse.cxx b/Examples/Simulation/LAIAndPROSAILToSensorResponse.cxx index fa7886b540351b0d095f0ae64970943b4e09c799..e61faf0608761bb35f9e6fa8a105b6232b035c9d 100644 --- a/Examples/Simulation/LAIAndPROSAILToSensorResponse.cxx +++ b/Examples/Simulation/LAIAndPROSAILToSensorResponse.cxx @@ -422,7 +422,7 @@ protected: // Software Guide : BeginLatex // // \code{TernaryFunctorImageFilterWithNBands} class is defined here. -// This class inherits form \doxygen{itk::TernaryFunctorImageFilter} with additional nuber of band parameters. +// This class inherits form \doxygen{itk}{TernaryFunctorImageFilter} with additional nuber of band parameters. // It's implementation is done to process Label, LAI, and mask image with Simulation functor. // Software Guide : EndLatex @@ -595,7 +595,7 @@ int main(int argc, char *argv[]) // Software Guide : BeginLatex // // Acquisition parameters are loaded using text file. A detailed definition of acquisition parameters can - // be found in class \doxygen{SailModel}. + // be found in class \doxygen{otb}{SailModel}. // // Software Guide : EndLatex diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h b/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h index 12c94cd02c047bc2034a67cefd64c2b70fbd8227..7fdc308413d2a912eba471b90fe74576e1ef5310 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h @@ -44,6 +44,8 @@ class OGRDataSource; class OGRSFDriver; #endif +class OGRFeature; + #include "OTBGdalAdaptersExport.h" namespace otb @@ -212,6 +214,15 @@ OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type); OTBGdalAdapters_EXPORT std::vector<std::string> GetAvailableDriversAsStringVector(); + /** + * Returns true if the field 'index' is set and not-null in the given feature + * + * Before gdal 2.2, it calls OGRFeature::IsFieldSet(). + * After gdal 2.2, it calls OGRFeature::IsFieldSetAndNotNull() + */ + OTBGdalAdapters_EXPORT + bool IsFieldSetAndNotNull(OGRFeature *feat, int index); + } } } // end namespace otb diff --git a/Modules/Adapters/GdalAdapters/src/CMakeLists.txt b/Modules/Adapters/GdalAdapters/src/CMakeLists.txt index 95a01673319b92719b860e2d4da2ed755d7b1ca1..4ba50ff1e286f05842703510931bffec1d5f0f21 100644 --- a/Modules/Adapters/GdalAdapters/src/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/src/CMakeLists.txt @@ -28,14 +28,9 @@ set(OTBGdalAdapters_SRC otbOGRDriversInit.cxx otbGeometriesToGeometriesFilter.cxx otbOGRDataSourceWrapper.cxx + otbOGRVersionProxy.cxx ) -if(OTB_USE_GDAL_20) - set(OTBGdalAdapters_SRC ${OTBGdalAdapters_SRC} otbOGRVersionProxy2x.cxx) -else(Otb_use_gdal_20) - set(OTBGdalAdapters_SRC ${OTBGdalAdapters_SRC} otbOGRVersionProxy1x.cxx) -endif(OTB_USE_GDAL_20) - add_library(OTBGdalAdapters ${OTBGdalAdapters_SRC}) target_link_libraries(OTBGdalAdapters ${OTBBoost_LIBRARIES} diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRFieldWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRFieldWrapper.cxx index 3b54c06c60d1041f5837f1c46a7b22bb4387713f..49f95f053546c6f59190ef88ae6d28cee0f19110 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRFieldWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRFieldWrapper.cxx @@ -37,6 +37,7 @@ #endif #include "otbOGRFeatureWrapper.h" #include "otbJoinContainer.h" +#include "otbOGRVersionProxy.h" #include <boost/array.hpp> /*===========================================================================*/ /*===========================[ Static Assertions ]===========================*/ @@ -166,7 +167,7 @@ std::ostream & otb::ogr::Field::UncheckedPrintSelf( bool otb::ogr::Field::UncheckedHasBeenSet() const { - return m_Feature->IsFieldSet(m_index); + return otb::ogr::version_proxy::IsFieldSetAndNotNull(m_Feature.get(), m_index); } void otb::ogr::Field::UncheckedUnset() const diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx similarity index 62% rename from Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx rename to Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx index 2ca46ae46a00029da877f3b16ef6e03739fea4fc..22b7a612ca3f7f557eeed7abe2da3c2e1d047fe9 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx @@ -20,15 +20,26 @@ #include "otbOGRVersionProxy.h" +#include "itkMacro.h" + #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" +#if GDAL_VERSION_NUM<2000000 +#include "ogrsf_frmts.h" +#else #include "gdal_priv.h" +#endif +#include "ogr_feature.h" #pragma GCC diagnostic pop #else +#if GDAL_VERSION_NUM<2000000 +#include "ogrsf_frmts.h" +#else #include "gdal_priv.h" #endif - +#include "ogr_feature.h" +#endif // __GNUC__ || __clang__ namespace otb { @@ -37,24 +48,48 @@ namespace ogr namespace version_proxy { +/*-------------------------[GDAL v2 API change]-------------------------------*/ OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type) { +#if GDAL_VERSION_NUM<2000000 + (void)type; + return false; +#else return type == OFTInteger64; +#endif } + GDALDatasetType * Open(const char * filename, bool readOnly) { +#if GDAL_VERSION_NUM<2000000 + return OGRSFDriverRegistrar::Open(filename,!readOnly); +#else return (GDALDatasetType *)GDALOpenEx(filename, (readOnly? GDAL_OF_READONLY : GDAL_OF_UPDATE) | GDAL_OF_VECTOR,NULL,NULL,NULL); +#endif } void Close(GDALDatasetType * dataset) { +#if GDAL_VERSION_NUM<2000000 + OGRDataSource::DestroyDataSource(dataset); +#else GDALClose(dataset); +#endif } GDALDatasetType * Create(GDALDriverType * driver, const char * name) { +#if GDAL_VERSION_NUM<2000000 + GDALDatasetType * ds = driver->CreateDataSource(name); + + if(ds) + ds->SetDriver(driver); + + return ds; +#else return driver->Create(name,0,0,0,GDT_Unknown,NULL); +#endif } bool Delete(const char * name) @@ -67,31 +102,50 @@ bool Delete(const char * name) poDriver = poDS->GetDriver(); Close(poDS); } - +#if GDAL_VERSION_NUM<2000000 + if(poDriver && poDriver->TestCapability(ODrCDeleteDataSource)) + { + OGRErr ret = poDriver->DeleteDataSource(name); + return (ret == OGRERR_NONE); + } +#else if(poDriver) { OGRErr ret = poDriver->Delete(name); - return (ret == OGRERR_NONE); } +#endif return false; } GDALDriverType * GetDriverByName(const char * name) { +#if GDAL_VERSION_NUM<2000000 + return OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(name); +#else return GetGDALDriverManager()->GetDriverByName(name); +#endif } std::string GetDatasetClassName() { +#if GDAL_VERSION_NUM<2000000 + return std::string("OGRDataSource"); +#else return std::string("GDALDataset"); +#endif } std::string GetDriverClassName() { +#if GDAL_VERSION_NUM<2000000 + return std::string("OGRSFDriver"); +#else return std::string("GDALDriver"); +#endif } +#if GDAL_VERSION_NUM>=2000000 namespace raii { // This class is used in the next function, so as to prevent any @@ -118,11 +172,14 @@ private: char ** m_P; }; } +#endif std::vector<std::string> GetFileListAsStringVector(GDALDatasetType * dataset) { std::vector<std::string> ret; - +#if GDAL_VERSION_NUM<2000000 + ret.push_back(std::string(dataset->GetName())); +#else raii::CharPPCapsule capsule(dataset->GetFileList()); std::string files_str=""; @@ -136,35 +193,62 @@ std::vector<std::string> GetFileListAsStringVector(GDALDatasetType * dataset) ++i; } } +#endif return ret; } bool SyncToDisk(GDALDatasetType * dataset) { +#if GDAL_VERSION_NUM<2000000 + const OGRErr res= dataset->SyncToDisk(); + return (res == OGRERR_NONE); +#else dataset->FlushCache(); - return true; +#endif } std::vector<std::string> GetAvailableDriversAsStringVector() { std::vector<std::string> ret; +#if GDAL_VERSION_NUM<2000000 + int nbDrivers = OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount(); + for(int i = 0; i < nbDrivers;++i) + { + ret.push_back(OGRSFDriverRegistrar::GetRegistrar()->GetDriver(i)->GetName()); + } +#else int nbDrivers = GetGDALDriverManager()->GetDriverCount(); for(int i = 0; i < nbDrivers;++i) { ret.push_back(GDALGetDriverShortName(GetGDALDriverManager()->GetDriver(i))); } - +#endif return ret; } std::string GetDriverNameFromDataSource(const GDALDatasetType * ds) { +#if GDAL_VERSION_NUM<2000000 + return std::string(const_cast<GDALDatasetType *>(ds)->GetDriver()->GetName()); +#else return std::string(const_cast<GDALDatasetType *>(ds)->GetDriverName()); +#endif +} + +/*----------------------[GDAL 2.2 change on IsFieldSet()]---------------------*/ +bool IsFieldSetAndNotNull(OGRFeature *feat, int index) +{ +#if GDAL_VERSION_NUM<2020000 + return feat->IsFieldSet(index); +#else + return feat->IsFieldSetAndNotNull(index); +#endif } } } } // end namespace + diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx deleted file mode 100644 index 47c915342349732a594d0a5360c1ecd8bfe1ae5e..0000000000000000000000000000000000000000 --- a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "otbOGRVersionProxy.h" - -#include "itkMacro.h" - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wshadow" -#include "ogrsf_frmts.h" -#pragma GCC diagnostic pop -#else -#include "ogrsf_frmts.h" -#endif - -namespace otb -{ -namespace ogr -{ -namespace version_proxy -{ - -OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType itkNotUsed(type)) -{ - return false; -} - - -GDALDatasetType * Open(const char * filename, bool readOnly) -{ - return OGRSFDriverRegistrar::Open(filename,!readOnly); -} - -void Close(GDALDatasetType * dataset) -{ - OGRDataSource::DestroyDataSource(dataset); -} - -GDALDatasetType * Create(GDALDriverType * driver, const char * name) -{ - GDALDatasetType * ds = driver->CreateDataSource(name); - - if(ds) - ds->SetDriver(driver); - - return ds; -} - -bool Delete(const char * name) -{ - // Open dataset - GDALDatasetType * poDS = Open(name,false); - GDALDriverType * poDriver = ITK_NULLPTR; - if(poDS) - { - poDriver = poDS->GetDriver(); - Close(poDS); - } - - if(poDriver && poDriver->TestCapability(ODrCDeleteDataSource)) - { - - OGRErr ret = poDriver->DeleteDataSource(name); - return (ret == OGRERR_NONE); - } - - return false; -} - -GDALDriverType * GetDriverByName(const char * name) -{ - return OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(name); -} - -std::string GetDatasetClassName() -{ - return std::string("OGRDataSource"); -} - -std::string GetDriverClassName() -{ - return std::string("OGRSFDriver"); -} - -std::vector<std::string> GetFileListAsStringVector(GDALDatasetType * dataset) -{ - std::vector<std::string> ret; - - ret.push_back(std::string(dataset->GetName())); - - return ret; -} - -bool SyncToDisk(GDALDatasetType * dataset) -{ - const OGRErr res= dataset->SyncToDisk(); - - return (res == OGRERR_NONE); -} - -std::vector<std::string> GetAvailableDriversAsStringVector() -{ - std::vector<std::string> ret; - - int nbDrivers = OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount(); - - for(int i = 0; i < nbDrivers;++i) - { - ret.push_back(OGRSFDriverRegistrar::GetRegistrar()->GetDriver(i)->GetName()); - } - - return ret; -} - -std::string GetDriverNameFromDataSource(const GDALDatasetType * ds) -{ - return std::string(const_cast<GDALDatasetType *>(ds)->GetDriver()->GetName()); -} - -} -} -} // end namespace diff --git a/Modules/Applications/AppClassification/app/otbSOMClassification.cxx b/Modules/Applications/AppClassification/app/otbSOMClassification.cxx index 18e12db92ef7836209082b73816c04196be2c9bf..86572e90ad0eebd83dbc8ec8ee3e338677984af6 100644 --- a/Modules/Applications/AppClassification/app/otbSOMClassification.cxx +++ b/Modules/Applications/AppClassification/app/otbSOMClassification.cxx @@ -254,6 +254,10 @@ private: itk::RandomPermutation randPerm(numberOfStreamDivisions); unsigned int index = 0; + // reset seed and step once (itk::RandomPermutation may have used it) + randomGen->SetSeed(GetParameterInt("rand")); + randomGen->GetVariateWithClosedRange(); + // TODO : maybe change the approach: at the moment, the sampling process is able to pick a sample twice or more while (totalSamples < nbsamples) { diff --git a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx index 0dd2d8f56327eaad45cae9d26101f0f1094ff31a..82d5bd8410dad7927c42fdd7a091c63f7e6d930b 100644 --- a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx +++ b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx @@ -37,9 +37,23 @@ namespace Wrapper SetParameterDescription("classifier.libsvm", "This group of parameters allows setting SVM classifier parameters."); AddParameter(ParameterType_Choice, "classifier.libsvm.k", "SVM Kernel Type"); AddChoice("classifier.libsvm.k.linear", "Linear"); + SetParameterDescription("classifier.libsvm.k.linear", + "Linear Kernel, no mapping is done, this is the fastest option."); + AddChoice("classifier.libsvm.k.rbf", "Gaussian radial basis function"); + SetParameterDescription("classifier.libsvm.k.rbf", + "This kernel is a good choice in most of the case. It is " + "an exponential function of the euclidian distance between " + "the vectors."); + AddChoice("classifier.libsvm.k.poly", "Polynomial"); + SetParameterDescription("classifier.libsvm.k.poly", + "Polynomial Kernel, the mapping is a polynomial function."); + AddChoice("classifier.libsvm.k.sigmoid", "Sigmoid"); + SetParameterDescription("classifier.libsvm.k.sigmoid", + "The kernel is a hyperbolic tangente function of the vectors."); + SetParameterString("classifier.libsvm.k", "linear", false); SetParameterDescription("classifier.libsvm.k", "SVM Kernel Type."); AddParameter(ParameterType_Choice, "classifier.libsvm.m", "SVM Model Type"); @@ -47,21 +61,50 @@ namespace Wrapper if (this->m_RegressionFlag) { AddChoice("classifier.libsvm.m.epssvr", "Epsilon Support Vector Regression"); + SetParameterDescription("classifier.libsvm.m.epssvr", + "The distance between feature vectors from the training set and the " + "fitting hyper-plane must be less than Epsilon. For outliers the penalty " + "multiplier C is used "); + AddChoice("classifier.libsvm.m.nusvr", "Nu Support Vector Regression"); SetParameterString("classifier.libsvm.m", "epssvr", false); + SetParameterDescription("classifier.libsvm.m.nusvr", + "Same as the epsilon regression except that this time the bounded " + "parameter nu is used instead of epsilon"); } else { AddChoice("classifier.libsvm.m.csvc", "C support vector classification"); + SetParameterDescription("classifier.libsvm.m.csvc", + "This formulation allows imperfect separation of classes. The penalty " + "is set through the cost parameter C."); + AddChoice("classifier.libsvm.m.nusvc", "Nu support vector classification"); + SetParameterDescription("classifier.libsvm.m.nusvc", + "This formulation allows imperfect separation of classes. The penalty " + "is set through the cost parameter Nu. As compared to C, Nu is harder " + "to optimize, and may not be as fast."); + AddChoice("classifier.libsvm.m.oneclass", "Distribution estimation (One Class SVM)"); + SetParameterDescription("classifier.libsvm.m.oneclass", + "All the training data are from the same class, SVM builds a boundary " + "that separates the class from the rest of the feature space."); SetParameterString("classifier.libsvm.m", "csvc", false); } + AddParameter(ParameterType_Float, "classifier.libsvm.c", "Cost parameter C"); SetParameterFloat("classifier.libsvm.c",1.0, false); - SetParameterDescription( - "classifier.libsvm.c", - "SVM models have a cost parameter C (1 by default) to control the trade-off between training errors and forcing rigid margins."); + SetParameterDescription("classifier.libsvm.c", + "SVM models have a cost parameter C (1 by default) to control the " + "trade-off between training errors and forcing rigid margins."); + + AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Cost parameter Nu"); + SetParameterFloat("classifier.libsvm.nu",0.5, false); + SetParameterDescription("classifier.libsvm.nu", + "Cost parameter Nu, in the range 0..1, the larger the value, " + "the smoother the decision."); + + // It seems that it miss a nu parameter for the nu-SVM use. AddParameter(ParameterType_Empty, "classifier.libsvm.opt", "Parameters optimization"); MandatoryOff("classifier.libsvm.opt"); SetParameterDescription("classifier.libsvm.opt", "SVM parameters optimization flag."); @@ -73,8 +116,15 @@ namespace Wrapper { AddParameter(ParameterType_Float, "classifier.libsvm.eps", "Epsilon"); SetParameterFloat("classifier.libsvm.eps",1e-3, false); - AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Nu"); - SetParameterFloat("classifier.libsvm.nu",0.5, false); + SetParameterDescription("classifier.libsvm.eps", + "The distance between feature vectors from the training set and " + "the fitting hyper-plane must be less than Epsilon. For outliers" + "the penalty mutliplier is set by C."); + // AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Nu"); + // SetParameterFloat("classifier.libsvm.nu",0.5, false); + // SetParameterDescription("classifier.libsvm.nu", + // "Cost parameter Nu, in the range 0..1, the larger the value, " + // "the smoother the decision."); } } @@ -100,6 +150,7 @@ namespace Wrapper { libSVMClassifier->SetDoProbabilityEstimates(true); } + libSVMClassifier->SetNu(GetParameterFloat("classifier.libsvm.nu")); libSVMClassifier->SetC(GetParameterFloat("classifier.libsvm.c")); switch (GetParameterInt("classifier.libsvm.k")) @@ -135,7 +186,6 @@ namespace Wrapper break; } libSVMClassifier->SetEpsilon(GetParameterFloat("classifier.libsvm.eps")); - libSVMClassifier->SetNu(GetParameterFloat("classifier.libsvm.nu")); } else { @@ -155,6 +205,7 @@ namespace Wrapper break; } } + libSVMClassifier->Train(); libSVMClassifier->Save(modelPath); @@ -163,4 +214,4 @@ namespace Wrapper } //end namespace wrapper } //end namespace otb -#endif +#endif \ No newline at end of file diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx index e24c4165de2b6a1b1bf57c672e5ec69a1ef825a2..ac72630fd08ce84b22f64e329eaae10796f69d75 100644 --- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx +++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx @@ -273,7 +273,7 @@ TrainVectorBase::ExtractSamplesWithLabel(std::string parameterName, std::string input->PushBack( mv ); - if( feature.ogr().IsFieldSet( cFieldIndex ) && cFieldIndex != -1 ) + if(cFieldIndex>=0 && ogr::Field(feature,cFieldIndex).HasBeenSet()) target->PushBack( feature.ogr().GetFieldAsInteger( cFieldIndex ) ); else target->PushBack( 0 ); diff --git a/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt b/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt index e77967b05c1ca08b7f9d908a5ebce567a2273572..ebdaca7c686939019b1e019b25515494e919043d 100644 --- a/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt +++ b/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt @@ -23,7 +23,7 @@ otb_module_test() otb_test_application(NAME apTvSARPolarSynth APP SARPolarSynth - OPTIONS -in ${INPUTDATA}/RSAT2_AltonaExtract_1000_1000_100_100.hdr + OPTIONS -in ${INPUTDATA}/RSAT2_AltonaExtract_1000_1000_100_100.tif -out ${TEMP}/resApMultiPolarimetricSynthesis1.tif -psii 10.0 -khii 0.0 diff --git a/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h b/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h index cc04dacdd8526f661aa9209b94cdff9e3fb44aa9..a4adf2d0548ce1eb525d6b1804eb484455d12961 100644 --- a/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h @@ -64,6 +64,8 @@ public: typedef std::vector<LinePointType> PointListType; typedef itk::VectorContainer<unsigned long, PointType> PointContainerType; typedef itk::SmartPointer<PointContainerType> PointContainerPointer; + typedef itk::SizeValueType SizeValueType; + typedef itk::IdentifierType IdentifierType; /** Returns a reference to the list of the Line points.*/ PointListType& GetPoints(void); @@ -72,19 +74,19 @@ public: void SetPoints(PointListType& newPoints); /** Return a point in the list given the index */ - const SpatialObjectPointType* GetPoint(unsigned long id) const ITK_OVERRIDE + const SpatialObjectPointType* GetPoint(IdentifierType id) const ITK_OVERRIDE { return &(m_Points[id]); } /** Return a point in the list given the index */ - SpatialObjectPointType* GetPoint(unsigned long id) ITK_OVERRIDE + SpatialObjectPointType* GetPoint(IdentifierType id) ITK_OVERRIDE { return &(m_Points[id]); } /** Return the number of points in the list */ - itk::SizeValueType GetNumberOfPoints(void) const ITK_OVERRIDE + SizeValueType GetNumberOfPoints(void) const ITK_OVERRIDE { return m_Points.size(); } diff --git a/Modules/Filtering/Polarimetry/test/CMakeLists.txt b/Modules/Filtering/Polarimetry/test/CMakeLists.txt index 73045f5cd8b40c0395a34604f11abb85dceeaa24..d1c77627cf5316b3353b3eab49f760faca17a690 100644 --- a/Modules/Filtering/Polarimetry/test/CMakeLists.txt +++ b/Modules/Filtering/Polarimetry/test/CMakeLists.txt @@ -74,7 +74,7 @@ otb_add_test(NAME saTvVectorMultiChannelsPolarimetricSynthesisFilter COMMAND otb --compare-image ${EPSILON_7} ${BASELINE}/saTvMultiPolarimetricSynthesis1.tif ${TEMP}/resMultiPolarimetricSynthesis1.tif otbVectorMultiChannelsPolarimetricSynthesisFilter - ${INPUTDATA}/RSAT2_AltonaExtract_1000_1000_100_100.hdr + ${INPUTDATA}/RSAT2_AltonaExtract_1000_1000_100_100.tif ${TEMP}/resMultiPolarimetricSynthesis1.tif 10.0 # PsiI 0.0 # KhiI diff --git a/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.txx b/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.txx index 919e3a6d322dc4d5d9cc2e2cf88d16fc457f8629..014ff8e7eef8cc32e52e8154eb583dbab4142020 100644 --- a/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.txx +++ b/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.txx @@ -233,7 +233,7 @@ void VCAImageFilter<TImage>::GenerateData() vnl_matrix<PrecisionType> A(m_NumberOfEndmembers, m_NumberOfEndmembers); A.fill(0); A(m_NumberOfEndmembers - 1, 0) = 1; - typename RandomVariateGeneratorType::Pointer randomGen = RandomVariateGeneratorType::New(); + typename RandomVariateGeneratorType::Pointer randomGen = RandomVariateGeneratorType::GetInstance(); for (unsigned int i = 0; i < m_NumberOfEndmembers; ++i) { diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index 968ec2a5fff7a52fb1aa9292a7b85aaf9a4728c6..812c938e6b86b6dd5005abc9939e5275b639f8e5 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -1578,7 +1578,7 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) if (driverShortName == "NOT-FOUND") { itkExceptionMacro( - << "GDAL Writing failed : the image file name '" << m_FileName.c_str() << "' is not recognized by GDAL."); + << "GDAL Writing failed: the image file name '" << m_FileName.c_str() << "' is not recognized by GDAL."); } if (m_CanStreamWrite) @@ -1664,9 +1664,7 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) if (m_Dataset.IsNull()) { - itkExceptionMacro( - << "GDAL Writing failed : Impossible to create the image file name '" - << m_FileName << "' : " << CPLGetLastErrorMsg() ); + itkExceptionMacro(<< CPLGetLastErrorMsg()); } /*----------------------------------------------------------------------*/ @@ -1768,19 +1766,26 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) /* -------------------------------------------------------------------- */ /* Set the six coefficients of affine geoTransform */ /* -------------------------------------------------------------------- */ - itk::VariableLengthVector<double> geoTransform(6); - /// Reporting origin and spacing - // Beware : GDAL origin is at the corner of the top-left pixel - // whereas OTB/ITK origin is at the centre of the top-left pixel - geoTransform[0] = m_Origin[0] - 0.5*m_Spacing[0]; - geoTransform[3] = m_Origin[1] - 0.5*m_Spacing[1]; - geoTransform[1] = m_Spacing[0]; - geoTransform[5] = m_Spacing[1]; - - // FIXME: Here component 1 and 4 should be replaced by the orientation parameters - geoTransform[2] = 0.; - geoTransform[4] = 0.; - dataset->SetGeoTransform(const_cast<double*>(geoTransform.GetDataPointer())); + if ( vcl_abs(m_Origin[0] - 0.5) > Epsilon + || vcl_abs(m_Origin[1] - 0.5) > Epsilon + || vcl_abs(m_Spacing[0] - 1.0) > Epsilon + || vcl_abs(m_Spacing[1] - 1.0) > Epsilon ) + { + // Only set the geotransform if it is not identity (it may erase GCP) + itk::VariableLengthVector<double> geoTransform(6); + /// Reporting origin and spacing + // Beware : GDAL origin is at the corner of the top-left pixel + // whereas OTB/ITK origin is at the centre of the top-left pixel + geoTransform[0] = m_Origin[0] - 0.5*m_Spacing[0]; + geoTransform[3] = m_Origin[1] - 0.5*m_Spacing[1]; + geoTransform[1] = m_Spacing[0]; + geoTransform[5] = m_Spacing[1]; + + // FIXME: Here component 1 and 4 should be replaced by the orientation parameters + geoTransform[2] = 0.; + geoTransform[4] = 0.; + dataset->SetGeoTransform(const_cast<double*>(geoTransform.GetDataPointer())); + } /* -------------------------------------------------------------------- */ /* Report metadata. */ diff --git a/Modules/IO/IOGDAL/src/otbOGRIOHelper.cxx b/Modules/IO/IOGDAL/src/otbOGRIOHelper.cxx index 8248ef8a1df7019224761445e628f1f59e3d573a..53b61999699415cf18f36e1f182cf698560fbe4a 100644 --- a/Modules/IO/IOGDAL/src/otbOGRIOHelper.cxx +++ b/Modules/IO/IOGDAL/src/otbOGRIOHelper.cxx @@ -211,7 +211,7 @@ void OGRIOHelper otb::VectorDataKeywordlist kwl; for (int fieldNum = 0; fieldNum < feature->GetFieldCount(); ++fieldNum) { - if (feature->IsFieldSet(fieldNum)) + if (ogr::version_proxy::IsFieldSetAndNotNull(feature, fieldNum)) { kwl.AddField(feature->GetFieldDefnRef(fieldNum), feature->GetRawFieldRef(fieldNum)); } diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.h b/Modules/IO/ImageIO/include/otbImageFileReader.h index daf6c58e800fc4c14bccb519edc9dcfc47400324..631f9d7dc27fdda1020a734086e71b95607f7786 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.h +++ b/Modules/IO/ImageIO/include/otbImageFileReader.h @@ -54,19 +54,14 @@ public: /** Constructor. */ ImageFileReaderException(const char *file, unsigned int line, - const char* message = "Error in IO", - const char* loc = "Unknown") : - ExceptionObject(file, line, message, loc) + const std::string& desc = "", + const std::string& filename = "") : + ExceptionObject(file, line, desc), + m_Filename(filename) { } - /** Constructor. */ - ImageFileReaderException(const std::string &file, unsigned int line, - const char* message = "Error in IO", - const char* loc = "Unknown") : - ExceptionObject(file, line, message, loc) - { - } + std::string m_Filename; }; /** \class ImageFileReader @@ -170,12 +165,10 @@ protected: void DoConvertBuffer(void* buffer, size_t numberOfPixels); private: - /** Test whether the given filename exist and it is readable, - this is intended to be called before attempting to use - ImageIO classes for actually reading the file. If the file - doesn't exist or it is not readable, and exception with an - appropriate message will be thrown. */ - void TestFileExistenceAndReadability(); + /** Test whether m_ImageIO is valid (not NULL). This is intended to be called + * after trying to create it via an ImageIOFactory. Throws an exception with + * an appropriate message otherwise. */ + void TestValidImageIO(); /** Generate the filename (for GDALImageI for example). If filename is a directory, look if is a * CEOS product (file "DAT...") In this case, the GdalFileName contain the open image file. @@ -196,8 +189,6 @@ private: bool m_UseStreaming; - std::string m_ExceptionMessage; - // The region that the ImageIO class will return when we ask to // produce the requested region. itk::ImageIORegion m_ActualIORegion; diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index 8f529967ada3dc10cb40705210da8ac43edece85..f701d882571bd7c17dbd6dd90e162b19f450e21b 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -65,7 +65,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> m_UserSpecifiedImageIO(false), m_FileName(""), m_UseStreaming(true), - m_ExceptionMessage(""), m_ActualIORegion(), m_FilenameHelper(FNameHelperType::New()), m_AdditionalNumber(0), @@ -129,9 +128,9 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); - // Test if the file exist and if it can be open. - // An exception will be thrown otherwise. - this->TestFileExistenceAndReadability(); + // Raise an exception if the file could not be opened + // i.e. if this->m_ImageIO is Null + this->TestValidImageIO(); // Tell the ImageIO to read the file OutputImagePixelType *buffer = @@ -242,8 +241,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> } else { - throw otb::ImageFileReaderException(__FILE__, __LINE__, - "Invalid output object type"); + throw otb::ImageFileReaderException(__FILE__, __LINE__, "Invalid output object type"); } } } @@ -253,74 +251,32 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits> ::GenerateOutputInformation(void) { - typename TOutputImage::Pointer output = this->GetOutput(); - itkDebugMacro(<< "Reading file for GenerateOutputInformation()" << this->m_FileName); - // Check to see if we can read the file given the name or prefix - // if (this->m_FileName == "") - { - throw otb::ImageFileReaderException(__FILE__, __LINE__, "FileName must be specified"); - } + { + throw otb::ImageFileReaderException(__FILE__, __LINE__, "Filename must be specified."); + } // Find real image file name // !!!! Update FileName std::string lFileName; - bool found = GetGdalReadImageFileName(this->m_FileName, lFileName); - if (found == false) - { - otbMsgDebugMacro(<< "Filename was NOT unknown. May be recognized by a Image factory ! "); - } - // Update FileName - this->m_FileName = lFileName; - - // Test if the file exists and if it can be opened. - // An exception will be thrown otherwise. - // We catch the exception because some ImageIO's may not actually - // open a file. Still reports file error if no ImageIO is loaded. - - try - { - m_ExceptionMessage = ""; - this->TestFileExistenceAndReadability(); - } - catch (itk::ExceptionObject & err) - { - m_ExceptionMessage = err.GetDescription(); - } - + bool found = GetGdalReadImageFileName(this->m_FileName, lFileName); + if (found) + { + // Update FileName + this->m_FileName = lFileName; + } + if (this->m_UserSpecifiedImageIO == false) //try creating via factory - { + { this->m_ImageIO = ImageIOFactory::CreateImageIO(this->m_FileName.c_str(), otb::ImageIOFactory::ReadMode); - } - - if (this->m_ImageIO.IsNull()) - { - //this->Print(std::cerr); - otb::ImageFileReaderException e(__FILE__, __LINE__); - std::ostringstream msg; - msg << " Could not create IO object for file " - << this->m_FileName.c_str() << std::endl; - msg << " Tried to create one of the following:" << std::endl; - std::list<itk::LightObject::Pointer> allobjects = - itk::ObjectFactoryBase::CreateAllInstance("otbImageIOBase"); - for (std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin(); - i != allobjects.end(); ++i) - { - otb::ImageIOBase* io = dynamic_cast<otb::ImageIOBase*>(i->GetPointer()); - // IO should never be null, but we would better check for it - if(io) - msg << " " << io->GetNameOfClass() << std::endl; - } - msg << " You probably failed to set a file suffix, or" << std::endl; - msg << " set the suffix to an unsupported type." << std::endl; - e.SetDescription(msg.str().c_str()); - throw e; - return; - } + } + // Raise an exception if the file could not be opened + // i.e. if this->m_ImageIO is Null + this->TestValidImageIO(); // Get the ImageIO MetaData Dictionary itk::MetaDataDictionary& dict = this->m_ImageIO->GetMetaDataDictionary(); @@ -331,7 +287,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> bool lVectorImage = false; if (strcmp(output->GetNameOfClass(), "VectorImage") == 0) lVectorImage= true; - + this->m_ImageIO->SetOutputImagePixelType(PixelIsComplex(dummy),lVectorImage); // Pass the dataset number (used for hdf files for example) @@ -435,9 +391,9 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> if(!m_KeywordListUpToDate && !m_FilenameHelper->GetSkipGeom()) { - + std::string lFileNameOssimKeywordlist = GetDerivedDatasetSourceFileName(m_FileName); - + // Update otb Keywordlist ImageKeywordlist otb_kwl; if (!m_FilenameHelper->ExtGEOMFileNameIsSet()) @@ -450,7 +406,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> otb_kwl = ReadGeometryFromGEOMFile(m_FilenameHelper->GetExtGEOMFileName()); otbMsgDevMacro(<< "Loading external kwl"); } - + // Don't add an empty ossim keyword list if(!otb_kwl.Empty()) { @@ -511,7 +467,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> } - + // If Skip ProjectionRef is activated, remove ProjRef from dict if (m_FilenameHelper->GetSkipCarto()) { @@ -576,9 +532,9 @@ std::string ImageFileReader<TOutputImage, ConvertPixelTraits> ::GetDerivedDatasetSourceFileName(const std::string & filename) const { - + const size_t dsds_pos = filename.find(DerivedSubdatasetPrefix); - + if(dsds_pos != std::string::npos) { // Derived subdataset from gdal @@ -595,50 +551,22 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> template <class TOutputImage, class ConvertPixelTraits> void ImageFileReader<TOutputImage, ConvertPixelTraits> -::TestFileExistenceAndReadability() +::TestValidImageIO() { - // Test if the file a server name : if so the test is skipped - if (this->m_FileName.find(std::string("http://")) == 0 || - this->m_FileName.find(std::string("https://")) == 0) - { - return; - } + if (this->m_ImageIO.IsNull()) + { + std::string fileToCheck = GetDerivedDatasetSourceFileName(m_FileName); - std::string fileToCheck = GetDerivedDatasetSourceFileName(m_FileName); - - // Test if the file exists. - if (!itksys::SystemTools::FileExists(fileToCheck.c_str())) + // Test if the file exists. + if (!itksys::SystemTools::FileExists(fileToCheck.c_str())) { - otb::ImageFileReaderException e(__FILE__, __LINE__); - std::ostringstream msg; - msg << "The file doesn't exist. " - << std::endl << "Filename = " << fileToCheck - << std::endl; - e.SetDescription(msg.str().c_str()); - throw e; - return; + throw otb::ImageFileReaderException (__FILE__, __LINE__, "The file does not exist.", fileToCheck); } - - // Test if the file can be open for reading access. - //Only if m_FileName specify a filename (not a dirname) - if (itksys::SystemTools::FileExists(fileToCheck.c_str(), true)) + else { - std::ifstream readTester; - readTester.open(fileToCheck.c_str()); - if (readTester.fail()) - { - readTester.close(); - std::ostringstream msg; - msg << "The file couldn't be opened for reading. " - << std::endl << "Filename: " << fileToCheck - << std::endl; - otb::ImageFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION); - throw e; - return; - - } - readTester.close(); + throw otb::ImageFileReaderException(__FILE__, __LINE__, "Probably unsupported format or incorrect filename extension.", this->m_FileName); } + } } template <class TOutputImage, class ConvertPixelTraits> @@ -695,7 +623,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> } fic_trouve = true; } - + otbMsgDevMacro(<< "lFileNameGdal : " << GdalFileName.c_str()); otbMsgDevMacro(<< "fic_trouve : " << fic_trouve); return (fic_trouve); @@ -716,12 +644,12 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> { const std::string skip_geom_key = "skipgeom"; const std::string geom_key = "geom"; - + if (in) { // First, see if the simple filename has changed typename FNameHelperType::Pointer helper = FNameHelperType::New(); - + helper->SetExtendedFileName(in); std::string simpleFileName = helper->GetSimpleFileName(); @@ -735,7 +663,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> if(oldMap.size() != newMap.size() || !std::equal(oldMap.begin(),oldMap.end(),newMap.begin())) { this->Modified(); - + // Now check if keywordlist needs to be generated again // Condition is: one of the old or new map has the skip_geom // key and the other does not @@ -759,7 +687,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> m_KeywordListUpToDate = false; this->Modified(); } - + m_FilenameHelper = helper; } } @@ -781,15 +709,15 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> return this->m_ImageIO->GetOverviewsCount(); } - - + + template <class TOutputImage, class ConvertPixelTraits> std::vector<std::string> ImageFileReader<TOutputImage, ConvertPixelTraits> ::GetOverviewsInfo() { this->UpdateOutputInformation(); - + return this->m_ImageIO->GetOverviewsInfo(); } diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 3224f5a3860a47e2cb59c7d24d00296bb90747dd..37bb644ed2731560caa13bc13851954290027b58 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -448,20 +448,7 @@ ImageFileWriter<TInputImage> { itk::ImageFileWriterException e(__FILE__, __LINE__); std::ostringstream msg; - msg << " Could not create IO object for file " - << m_FileName.c_str() << std::endl; - msg << " Tried to create one of the following:" << std::endl; - std::list<itk::LightObject::Pointer> allobjects = - itk::ObjectFactoryBase::CreateAllInstance("otbImageIOBase"); - for (std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin(); - i != allobjects.end(); ++i) - { - otb::ImageIOBase* io = dynamic_cast<otb::ImageIOBase*>(i->GetPointer()); - if(io) - msg << " " << io->GetNameOfClass() << std::endl; - } - msg << " You probably failed to set a file suffix, or" << std::endl; - msg << " set the suffix to an unsupported type." << std::endl; + msg << "Cannot write image " << m_FileName.c_str() << ". Probably unsupported format or incorrect filename extension."; e.SetDescription(msg.str().c_str()); e.SetLocation(ITK_LOCATION); throw e; diff --git a/Modules/IO/ImageIO/src/otbImageIOFactory.cxx b/Modules/IO/ImageIO/src/otbImageIOFactory.cxx index 671a62d39c2bce0ddf537ac4fee0d06ad268cc20..1f084b6afd8fa219a10e5437c4723a724db9ac9f 100644 --- a/Modules/IO/ImageIO/src/otbImageIOFactory.cxx +++ b/Modules/IO/ImageIO/src/otbImageIOFactory.cxx @@ -48,38 +48,35 @@ ImageIOFactory::CreateImageIO(const char* path, FileModeType mode) itk::ObjectFactoryBase::CreateAllInstance("otbImageIOBase"); for(std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin(); i != allobjects.end(); ++i) - { + { otb::ImageIOBase* io = dynamic_cast<otb::ImageIOBase*>(i->GetPointer()); if(io) - { + { possibleImageIO.push_back(io); - } - else - { - std::cerr << "Error ImageIO factory did not return an ImageIOBase: " - << (*i)->GetNameOfClass() - << std::endl; - } } - for(std::list<otb::ImageIOBase::Pointer>::iterator k = possibleImageIO.begin(); - k != possibleImageIO.end(); ++k) + else { + itkGenericExceptionMacro(<< "ImageIO factory did not return an ImageIOBase but a " << (*i)->GetNameOfClass()); + } + } + + for(std::list<otb::ImageIOBase::Pointer>::iterator k = possibleImageIO.begin(); k != possibleImageIO.end(); ++k) + { if( mode == ReadMode ) - { + { if((*k)->CanReadFile(path)) - { + { return *k; - } } + } else if( mode == WriteMode ) - { + { if((*k)->CanWriteFile(path)) - { + { return *k; - } - } } + } return ITK_NULLPTR; } diff --git a/Modules/IO/TestKernel/src/otbTestHelper.cxx b/Modules/IO/TestKernel/src/otbTestHelper.cxx index dfdd2345b95d7649b02cf56091b80d7a309f7769..9c1559a7138dbd3da2f5917ee6d2fe66d4dae441 100644 --- a/Modules/IO/TestKernel/src/otbTestHelper.cxx +++ b/Modules/IO/TestKernel/src/otbTestHelper.cxx @@ -1941,7 +1941,7 @@ void TestHelper::DumpOGRFeature(FILE* fpOut, OGRFeature* feature, char** papszOp poFDefn->GetNameRef(), OGRFieldDefn::GetFieldTypeName(poFDefn->GetType())); - if (feature->IsFieldSet(iField)) fprintf(fpOut, "%s\n", feature->GetFieldAsString(iField)); + if (ogr::version_proxy::IsFieldSetAndNotNull(feature, iField)) fprintf(fpOut, "%s\n", feature->GetFieldAsString(iField)); else fprintf(fpOut, "(null)\n"); } diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h index c5fb59f28c9fa5931351921309b5ac35cbf46b48..552880cb9a83a4e43b7e29ae75689613633e5ef0 100644 --- a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h @@ -22,8 +22,8 @@ #define otbMachineLearningModel_h #include "itkObject.h" -#include "itkVariableLengthVector.h" #include "itkListSample.h" +#include "otbMachineLearningModelTraits.h" namespace otb { @@ -66,6 +66,7 @@ namespace otb * * \ingroup OTBLearningBase */ + template <class TInputValue, class TTargetValue, class TConfidenceValue = double > class ITK_EXPORT MachineLearningModel : public itk::Object @@ -81,22 +82,22 @@ public: /**\name Input related typedefs */ //@{ - typedef TInputValue InputValueType; - typedef itk::VariableLengthVector<InputValueType> InputSampleType; - typedef itk::Statistics::ListSample<InputSampleType> InputListSampleType; + typedef typename MLMSampleTraits<TInputValue>::ValueType InputValueType; + typedef typename MLMSampleTraits<TInputValue>::SampleType InputSampleType; + typedef itk::Statistics::ListSample<InputSampleType> InputListSampleType; //@} /**\name Target related typedefs */ //@{ - typedef TTargetValue TargetValueType; - typedef itk::FixedArray<TargetValueType,1> TargetSampleType; - typedef itk::Statistics::ListSample<TargetSampleType> TargetListSampleType; + typedef typename MLMTargetTraits<TTargetValue>::ValueType TargetValueType; + typedef typename MLMTargetTraits<TTargetValue>::SampleType TargetSampleType; + typedef itk::Statistics::ListSample<TargetSampleType> TargetListSampleType; //@} /**\name Confidence value typedef */ - typedef TConfidenceValue ConfidenceValueType; - typedef itk::FixedArray<ConfidenceValueType,1> ConfidenceSampleType; - typedef itk::Statistics::ListSample<ConfidenceSampleType> ConfidenceListSampleType; + typedef typename MLMTargetTraits<TConfidenceValue>::ValueType ConfidenceValueType; + typedef typename MLMTargetTraits<TConfidenceValue>::SampleType ConfidenceSampleType; + typedef itk::Statistics::ListSample<ConfidenceSampleType> ConfidenceListSampleType; /**\name Standard macros */ //@{ diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModelTraits.h b/Modules/Learning/LearningBase/include/otbMachineLearningModelTraits.h new file mode 100644 index 0000000000000000000000000000000000000000..e9bc4cec29b9b3b45891e0265d63009bff34b76e --- /dev/null +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModelTraits.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef otbMachineLearningModelTraits_h +#define otbMachineLearningModelTraits_h + + +#include "itkVariableLengthVector.h" +#include "itkFixedArray.h" +#include "itkIsNumber.h" +#include "itkMetaProgrammingLibrary.h" + +namespace otb +{ + +/** + * This is the struct defining the sample implementation for + * MachineLearningModel. It offers two type definitions: SampleType + * and ValueType. + * + * \tparam TInput : input sample type (can be either a scalar type or + * a VariableLenghtVector + * \tparam isNumber either TrueType or FalseType for partial + * specialization + + */ +template <typename TInput, typename isNumber> struct MLMSampleTraitsImpl; + + +/// \cond SPECIALIZATION_IMPLEMENTATION +// For Numbers +template <typename TInput> struct MLMSampleTraitsImpl<TInput, itk::mpl::TrueType> { + typedef TInput ValueType; + typedef itk::VariableLengthVector<TInput> SampleType; +}; + +// For Vectors +template <typename TInput> struct MLMSampleTraitsImpl<TInput, itk::mpl::FalseType> { + typedef typename TInput::ValueType ValueType; + typedef TInput SampleType; +}; +/// \endcond + +/** + * Simplified implementation of SampleTraits using MLMSampleTraitsImpl + */ +template <typename TInput> using MLMSampleTraits = MLMSampleTraitsImpl< TInput, typename itk::mpl::IsNumber<TInput>::Type >; + + +/** + * This is the struct defining the sample implementation for + * MachineLearningModel. It offers two type definitions: TargetType + * and ValueType. + * + * \tparam TInput : input sample type (can be either a scalar type or + * a VariableLenghtVector or a FixedArray + * \tparam isNumber either TrueType or FalseType for partial + * specialization + + */ +template <typename TInput, typename isNumber> struct MLMTargetTraitsImpl; + + +/// \cond SPECIALIZATION_IMPLEMENTATION +// For Numbers +template <typename TInput> struct MLMTargetTraitsImpl<TInput, itk::mpl::TrueType> { + typedef TInput ValueType; + typedef itk::FixedArray<TInput,1> SampleType; +}; + +// For Vectors +template <typename TInput> struct MLMTargetTraitsImpl<TInput, itk::mpl::FalseType> { + typedef typename TInput::ValueType ValueType; + typedef TInput SampleType; +}; +/// \endcond + +/** + * Simplified implementation of TargetTraits using MLMTargetTraitsImpl + */ +template <typename TInput> using MLMTargetTraits = MLMTargetTraitsImpl< TInput, typename itk::mpl::IsNumber<TInput>::Type >; + + +} // End namespace otb + +#endif diff --git a/Modules/Learning/LearningBase/test/CMakeLists.txt b/Modules/Learning/LearningBase/test/CMakeLists.txt index 74a67d44dddd939201c134f28be152281b85a7a2..d1d16c3e65801e606c6e6903538b65264a4483a6 100644 --- a/Modules/Learning/LearningBase/test/CMakeLists.txt +++ b/Modules/Learning/LearningBase/test/CMakeLists.txt @@ -29,6 +29,7 @@ otbDecisionTreeWithRealValues.cxx otbSEMClassifierNew.cxx otbDecisionTreeNew.cxx otbKMeansImageClassificationFilterNew.cxx +otbMachineLearningModelTemplates.cxx ) add_executable(otbLearningBaseTestDriver ${OTBLearningBaseTests}) diff --git a/Modules/Learning/LearningBase/test/otbMachineLearningModelTemplates.cxx b/Modules/Learning/LearningBase/test/otbMachineLearningModelTemplates.cxx new file mode 100644 index 0000000000000000000000000000000000000000..96d35e014394d6b0d6836a90ddcbf3a2303db4bf --- /dev/null +++ b/Modules/Learning/LearningBase/test/otbMachineLearningModelTemplates.cxx @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <otbMachineLearningModel.h> + +typedef otb::MachineLearningModel<float,short> MachineLearningModelType1; +typedef MachineLearningModelType1::InputValueType InputValueType1; +typedef MachineLearningModelType1::InputSampleType InputSampleType1; +typedef MachineLearningModelType1::InputListSampleType InputListSampleType1; +typedef MachineLearningModelType1::TargetValueType TargetValueType1; +typedef MachineLearningModelType1::TargetSampleType TargetSampleType1; +typedef MachineLearningModelType1::TargetListSampleType TargetListSampleType1; + +typedef otb::MachineLearningModel<float,itk::VariableLengthVector<double> > MachineLearningModelType2; +typedef MachineLearningModelType2::InputValueType InputValueType2; +typedef MachineLearningModelType2::InputSampleType InputSampleType2; +typedef MachineLearningModelType2::InputListSampleType InputListSampleType2; +typedef MachineLearningModelType2::TargetValueType TargetValueType2; +typedef MachineLearningModelType2::TargetSampleType TargetSampleType2; +typedef MachineLearningModelType2::TargetListSampleType TargetListSampleType2; + + + diff --git a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h index a8baa08e58118980fff9deb9dd184e05d9ef2d0c..329722af5a2dd5d971f6dfaa0f86ef29be3dc188 100644 --- a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h @@ -141,7 +141,7 @@ public: return m_Parameters.coef0; } - /** Set the C parameter for the training for C_SVC, EPSILON_SVR and NU_SVR */ + /** Set the C parameter for the training for C_SVC, EPSILON_SVR and C_SVR */ otbSetSVMParameterMacro(C,C,double) /** Get the C parameter for the training for C_SVC, EPSILON_SVR and NU_SVR */ diff --git a/Modules/Radiometry/OpticalCalibration/test/CMakeLists.txt b/Modules/Radiometry/OpticalCalibration/test/CMakeLists.txt index 3221ced64e202aae2402e1a4ec311e699e00bd2d..dc0a87b1ec54d0fbce0e2e5e1b706cd73273f6dc 100644 --- a/Modules/Radiometry/OpticalCalibration/test/CMakeLists.txt +++ b/Modules/Radiometry/OpticalCalibration/test/CMakeLists.txt @@ -249,7 +249,7 @@ otb_add_test(NAME raTuLuminanceToImageImageFilterNew COMMAND otbOpticalCalibrati #FIXME Those tests have performing local copies of header, baselines...They were migrate "as it" for now in version 5.0 but # something cleaner could be done in the future. #TODO Rewrite those tests and ban local copy and cmake trickery -if(OTB_DATA_USE_LARGEINPUT) +if(OTB_DATA_USE_LARGEINPUT AND OTB_DATA_ROOT) set(TOULOUSEQBDIR ${TEMP}/OpticalCalibLumToImQBPAN) file(MAKE_DIRECTORY ${TOULOUSEQBDIR}) diff --git a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.txx b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.txx index 422d19f1b4b19b818c380b572efb881b4a8f5cfd..e14cfb9f34e67ade7b301b87279119ff117cb692 100644 --- a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.txx +++ b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.txx @@ -97,14 +97,16 @@ ReduceSpectralResponse<TSpectralResponse , TRSR> ++it; while (it != pairs.end()) { - PrecisionType lambda1 = (*(it-1)).first; - PrecisionType lambda2 = (*it).first; -// PrecisionType deltaLambda = lambda2-lambda1; ValuePrecisionType rsr1 = (*(it-1)).second; ValuePrecisionType rsr2 = (*it).second; - ValuePrecisionType spectrum1 = (*m_InputSpectralResponse)(lambda1); - ValuePrecisionType spectrum2 = (*m_InputSpectralResponse)(lambda2); - /* + if(rsr1 > 0 || rsr2 >0) + { + PrecisionType lambda1 = (*(it-1)).first; + PrecisionType lambda2 = (*it).first; +// PrecisionType deltaLambda = lambda2-lambda1; + ValuePrecisionType spectrum1 = (*m_InputSpectralResponse)(lambda1); + ValuePrecisionType spectrum2 = (*m_InputSpectralResponse)(lambda2); + /* In order to simplify the computation for the reflectance mode, we introduce the solar irradiance in the general formula with a value of 1.0 for the luminance case. @@ -112,21 +114,22 @@ ReduceSpectralResponse<TSpectralResponse , TRSR> In this way the formula is the same if we weight the RSR by the solar irradiance before the integration. */ - ValuePrecisionType solarIrradiance1(1.0); - ValuePrecisionType solarIrradiance2(1.0); - if(m_ReflectanceMode) - { - solarIrradiance1 = (*solarIrradiance)(lambda1); - solarIrradiance2 = (*solarIrradiance)(lambda2); + ValuePrecisionType solarIrradiance1(1.0); + ValuePrecisionType solarIrradiance2(1.0); + if(m_ReflectanceMode) + { + solarIrradiance1 = (*solarIrradiance)(lambda1); + solarIrradiance2 = (*solarIrradiance)(lambda2); + } + rsr1 *= solarIrradiance1; + rsr2 *= solarIrradiance2; + res += trapezoid_area(lambda1, lambda2, + rsr1*spectrum1, + rsr2*spectrum2); + totalArea += trapezoid_area(lambda1, lambda2, + rsr1, + rsr2); } - rsr1 *= solarIrradiance1; - rsr2 *= solarIrradiance2; - res += trapezoid_area(lambda1, lambda2, - rsr1*spectrum1, - rsr2*spectrum2); - totalArea += trapezoid_area(lambda1, lambda2, - rsr1, - rsr2); ++it; } return res / totalArea; diff --git a/Modules/Radiometry/Simulation/include/otbSailModel.h b/Modules/Radiometry/Simulation/include/otbSailModel.h index 288d0d7030f876381a374b5ae6923aace4de0f7e..572e25ae219f4bde18549f34e08a3b03d67c7e08 100644 --- a/Modules/Radiometry/Simulation/include/otbSailModel.h +++ b/Modules/Radiometry/Simulation/include/otbSailModel.h @@ -25,6 +25,9 @@ #include "otbSpectralResponse.h" #include "otbDataSpecP5B.h" #include "otbSimulationStep2Base.h" +#include "otbSoilDataBase.h" +#include <string> +#include <memory> namespace otb { @@ -42,116 +45,122 @@ namespace otb class OTBSimulation_EXPORT SailModel : public SimulationStep2Base { - public: - /** Standard class typedefs */ - typedef SailModel Self; - typedef SimulationStep2Base Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef Superclass::SpectralResponseType SpectralResponseType; - typedef std::vector<double> VectorType; - typedef Superclass::ParametersType ParametersType; - - typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType; - - /** Standard macros */ - itkNewMacro(Self); - itkTypeMacro(SailModel, ProcessObject); - - - /** Set Inputs */ - void SetReflectance(const SpectralResponseType *object) ITK_OVERRIDE; - SpectralResponseType * GetReflectance(); - - void SetTransmittance(const SpectralResponseType *object) ITK_OVERRIDE; - SpectralResponseType * GetTransmittance(); - - /** Set parameters */ - /** Set/Get leaf area index */ - itkSetMacro(LAI, double); - itkGetMacro(LAI, double); - - /** Set/Get average leaf angle (deg)*/ - itkSetMacro(Angl, double); - itkGetMacro(Angl, double); - - /** Set/Get soil coefficient*/ - itkSetMacro(PSoil, double); - itkGetMacro(PSoil, double); - - /** Set/Get diffuse/direct radiation*/ - itkSetMacro(Skyl, double); - itkGetMacro(Skyl, double); - - /** Set/Get hot spot */ - itkSetMacro(HSpot, double); - itkGetMacro(HSpot, double); - - /** Set/Get solar zenith angle (deg) */ - itkSetMacro(TTS, double); - itkGetMacro(TTS, double); - - /** Set/Get observer zenith angle (deg) */ - itkSetMacro(TTO, double); - itkGetMacro(TTO, double); - - /** Set/Get azimuth(deg) */ - itkSetMacro(PSI, double); - itkGetMacro(PSI, double); - - /** Get the computed fcover */ - itkGetMacro(FCoverView, double); - - /** GenerateData */ - void GenerateData() ITK_OVERRIDE; - - /** Get Output */ - virtual SpectralResponseType * GetViewingReflectance(); - virtual SpectralResponseType * GetHemisphericalReflectance(); - virtual SpectralResponseType * GetViewingAbsorptance(); - virtual SpectralResponseType * GetHemisphericalAbsorptance(); - - const ParametersType GetInput(); - void SetInput(const ParametersType &); - using Superclass::SetInput; - - - protected: - /** Constructor */ - SailModel(); - /** Destructor */ - ~SailModel() ITK_OVERRIDE; - /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType) ITK_OVERRIDE; - using Superclass::MakeOutput; - - /** Compute Leaf Angle Distribution */ - void Calc_LIDF(const double a, VectorType &lidf); - void Campbell(const double ala, VectorType &freq); - - /** J functions */ - double Jfunc1(const double k, const double l, const double t); - double Jfunc2(const double k, const double l, const double t); - double Jfunc3(const double k, const double l, const double t); - /** Volscatt */ - void Volscatt(const double tts, const double tto, const double psi, const double ttl, VectorType &result); - - private: - SailModel(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - - double m_LAI; //leaf area index - double m_Angl; //average leaf angle - double m_PSoil; //soil coefficient - double m_Skyl; //diffuse/direct radiation - double m_HSpot; //hot spot - double m_TTS; //solar zenith angle - double m_TTO; //observer zenith angle - double m_PSI; //azimuth - double m_FCoverView; //fCover in the viewing direction +public: + /** Standard class typedefs */ + typedef SailModel Self; + typedef SimulationStep2Base Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef Superclass::SpectralResponseType SpectralResponseType; + typedef std::vector<double> VectorType; + typedef Superclass::ParametersType ParametersType; + + typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType; + + /** Standard macros */ + itkNewMacro(Self); + itkTypeMacro(SailModel, ProcessObject); + + + /** Set Inputs */ + void SetReflectance(const SpectralResponseType *object) override; + SpectralResponseType * GetReflectance(); + + void SetTransmittance(const SpectralResponseType *object) override; + SpectralResponseType * GetTransmittance(); + + /** Set parameters */ + /** Set/Get leaf area index */ + itkSetMacro(LAI, double); + itkGetMacro(LAI, double); + + /** Set/Get average leaf angle (deg)*/ + itkSetMacro(Angl, double); + itkGetMacro(Angl, double); + + /** Set/Get soil coefficient*/ + itkSetMacro(PSoil, double); + itkGetMacro(PSoil, double); + + /** Set/Get diffuse/direct radiation*/ + itkSetMacro(Skyl, double); + itkGetMacro(Skyl, double); + + /** Set/Get hot spot */ + itkSetMacro(HSpot, double); + itkGetMacro(HSpot, double); + + /** Set/Get solar zenith angle (deg) */ + itkSetMacro(TTS, double); + itkGetMacro(TTS, double); + + /** Set/Get observer zenith angle (deg) */ + itkSetMacro(TTO, double); + itkGetMacro(TTO, double); + + /** Set/Get azimuth(deg) */ + itkSetMacro(PSI, double); + itkGetMacro(PSI, double); + + /** Get the computed fcover */ + itkGetMacro(FCoverView, double); + + /** Use an external soil DB */ + void UseExternalSoilDB(std::shared_ptr<SoilDataBase> SoilDB, size_t SoilIndex); + + /** GenerateData */ + void GenerateData() override; + + /** Get Output */ + virtual SpectralResponseType * GetViewingReflectance(); + virtual SpectralResponseType * GetHemisphericalReflectance(); + virtual SpectralResponseType * GetViewingAbsorptance(); + virtual SpectralResponseType * GetHemisphericalAbsorptance(); + + const ParametersType GetInput(); + void SetInput(const ParametersType &); + using Superclass::SetInput; + + +protected: + /** Constructor */ + SailModel(); + /** Destructor */ + ~SailModel() override; + /** PrintSelf method */ + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType) override; + using Superclass::MakeOutput; + + /** Compute Leaf Angle Distribution */ + void Calc_LIDF(const double a, VectorType &lidf) const; + void Campbell(const double ala, VectorType &freq) const; + + /** J functions */ + double Jfunc1(const double k, const double l, const double t) const; + double Jfunc2(const double k, const double l, const double t) const; + double Jfunc3(const double k, const double l, const double t) const; + /** Volscatt */ + void Volscatt(const double tts, const double tto, const double psi, const double ttl, VectorType &result) const; + +private: + SailModel(const Self&) = delete; + void operator=(const Self&) = delete; + + double m_LAI; //leaf area index + double m_Angl; //average leaf angle + double m_PSoil; //soil coefficient + double m_Skyl; //diffuse/direct radiation + double m_HSpot; //hot spot + double m_TTS; //solar zenith angle + double m_TTO; //observer zenith angle + double m_PSI; //azimuth + double m_FCoverView; //fCover in the viewing direction + bool m_UseSoilFile; //use a soil file instead of DataSpecP5B + size_t m_SoilIndex; //which soil in the soil file + std::shared_ptr<SoilDataBase> m_SoilDataBase; }; }// end namespace otb diff --git a/Modules/Radiometry/Simulation/include/otbSoilDataBase.h b/Modules/Radiometry/Simulation/include/otbSoilDataBase.h new file mode 100644 index 0000000000000000000000000000000000000000..673bc51335897306cd29140075a981db3c4be2d2 --- /dev/null +++ b/Modules/Radiometry/Simulation/include/otbSoilDataBase.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef otbSoilDataBase_h +#define otbSoilDataBase_h + +#include "OTBSimulationExport.h" +#include "itkMacro.h" +#include <vector> +#include <unordered_map> +#include <string> + +namespace otb +{ + +class ITK_ABI_EXPORT SoilDataBase +{ +public: + //wavelength in nm + using WavelenghtType = unsigned int; + using SoilData = std::unordered_map<WavelenghtType, double>; + using SoilDataVector = std::vector<SoilData>; + + SoilDataBase(const std::string& SoilFileName, double wlfactor); + const SoilDataVector& GetDB() const; + double GetReflectance(size_t SoilIndex, WavelenghtType wl) const; + +protected: + size_t CountColumns(std::string fileName) const; + void ParseSoilFile(); + + std::string m_SoilFileName; + double m_WlFactor; + SoilDataVector m_SoilDataVector; + std::vector<WavelenghtType> m_Wavelengths; +}; +} + +#endif /* otbSoilDataBase_h */ diff --git a/Modules/Radiometry/Simulation/src/CMakeLists.txt b/Modules/Radiometry/Simulation/src/CMakeLists.txt index a58c5464ab111f24e90ad9ddf9196c24567dd00f..7f862d356f25dcafffb5494621429ab41dfbadb0 100644 --- a/Modules/Radiometry/Simulation/src/CMakeLists.txt +++ b/Modules/Radiometry/Simulation/src/CMakeLists.txt @@ -23,6 +23,7 @@ set(OTBSimulation_SRC otbProspectModel.cxx otbDataSpecP5B.cxx otbLeafParameters.cxx + otbSoilDataBase.cxx ) add_library(OTBSimulation ${OTBSimulation_SRC}) diff --git a/Modules/Radiometry/Simulation/src/otbSailModel.cxx b/Modules/Radiometry/Simulation/src/otbSailModel.cxx index 15e262fee7351cd7d1c32bf19b444a9bc09e73a9..1049da6833319c037cbe4ab92ce4512ca8add577 100644 --- a/Modules/Radiometry/Simulation/src/otbSailModel.cxx +++ b/Modules/Radiometry/Simulation/src/otbSailModel.cxx @@ -34,22 +34,22 @@ namespace otb /** Constructor */ SailModel ::SailModel() : m_LAI(2), m_Angl(50), m_PSoil(1), m_Skyl(70), m_HSpot(0.2), - m_TTS(30), m_TTO(0), m_PSI(0), m_FCoverView(0.0) + m_TTS(30), m_TTO(0), m_PSI(0), m_FCoverView(0.0), m_UseSoilFile(false) { - this->ProcessObject::SetNumberOfRequiredInputs(2); - this->ProcessObject::SetNumberOfRequiredOutputs(4); + this->ProcessObject::SetNumberOfRequiredInputs(2); + this->ProcessObject::SetNumberOfRequiredOutputs(4); - SpectralResponseType::Pointer vRefl = static_cast<SpectralResponseType *>(this->MakeOutput(0).GetPointer()); - this->itk::ProcessObject::SetNthOutput(0, vRefl.GetPointer()); + SpectralResponseType::Pointer vRefl = static_cast<SpectralResponseType *>(this->MakeOutput(0).GetPointer()); + this->itk::ProcessObject::SetNthOutput(0, vRefl.GetPointer()); - SpectralResponseType::Pointer hRefl = static_cast<SpectralResponseType *>(this->MakeOutput(1).GetPointer()); - this->itk::ProcessObject::SetNthOutput(1, hRefl.GetPointer()); + SpectralResponseType::Pointer hRefl = static_cast<SpectralResponseType *>(this->MakeOutput(1).GetPointer()); + this->itk::ProcessObject::SetNthOutput(1, hRefl.GetPointer()); - SpectralResponseType::Pointer vAbs = static_cast<SpectralResponseType *>(this->MakeOutput(2).GetPointer()); - this->itk::ProcessObject::SetNthOutput(2, vAbs.GetPointer()); + SpectralResponseType::Pointer vAbs = static_cast<SpectralResponseType *>(this->MakeOutput(2).GetPointer()); + this->itk::ProcessObject::SetNthOutput(2, vAbs.GetPointer()); - SpectralResponseType::Pointer hAbs = static_cast<SpectralResponseType *>(this->MakeOutput(3).GetPointer()); - this->itk::ProcessObject::SetNthOutput(3, hAbs.GetPointer()); + SpectralResponseType::Pointer hAbs = static_cast<SpectralResponseType *>(this->MakeOutput(3).GetPointer()); + this->itk::ProcessObject::SetNthOutput(3, hAbs.GetPointer()); } /** Destructor */ @@ -62,112 +62,112 @@ void SailModel ::SetReflectance(const SpectralResponseType * object) { - this->itk::ProcessObject::SetNthInput(0, const_cast<SpectralResponseType *>(object)); + this->itk::ProcessObject::SetNthInput(0, const_cast<SpectralResponseType *>(object)); } SailModel::SpectralResponseType * SailModel ::GetReflectance() -{ - if(this->GetNumberOfInputs() != 2) - { - //exit - return ITK_NULLPTR; - } - return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetInput(0)); -} + { + if(this->GetNumberOfInputs() != 2) + { + //exit + return ITK_NULLPTR; + } + return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetInput(0)); + } /** Set/Get input transmittance */ -void -SailModel -::SetTransmittance(const SpectralResponseType * object) -{ - this->itk::ProcessObject::SetNthInput(1, const_cast<SpectralResponseType *>(object)); -} - -SailModel::SpectralResponseType * -SailModel -::GetTransmittance() -{ - if(this->GetNumberOfInputs() != 2) - { - //exit - return ITK_NULLPTR; - } - return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetInput(1)); -} + void + SailModel + ::SetTransmittance(const SpectralResponseType * object) + { + this->itk::ProcessObject::SetNthInput(1, const_cast<SpectralResponseType *>(object)); + } + + SailModel::SpectralResponseType * + SailModel + ::GetTransmittance() + { + if(this->GetNumberOfInputs() != 2) + { + //exit + return ITK_NULLPTR; + } + return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetInput(1)); + } /** Make output */ -SailModel::DataObjectPointer -SailModel -::MakeOutput(DataObjectPointerArraySizeType) -{ - return static_cast<itk::DataObject*>(SpectralResponseType::New().GetPointer()); -} + SailModel::DataObjectPointer + SailModel + ::MakeOutput(DataObjectPointerArraySizeType) + { + return static_cast<itk::DataObject*>(SpectralResponseType::New().GetPointer()); + } /** Get output viewing reflectance */ -SailModel::SpectralResponseType * -SailModel -::GetViewingReflectance() -{ - if(this->GetNumberOfOutputs() < 4) - { - //exit - return ITK_NULLPTR; - } - return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(0)); -} + SailModel::SpectralResponseType * + SailModel + ::GetViewingReflectance() + { + if(this->GetNumberOfOutputs() < 4) + { + //exit + return ITK_NULLPTR; + } + return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(0)); + } /** Get output hemispherical reflectance */ -SailModel::SpectralResponseType * -SailModel -::GetHemisphericalReflectance() -{ - if(this->GetNumberOfOutputs() < 4) - { - //exit - return ITK_NULLPTR; - } - return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(1)); -} + SailModel::SpectralResponseType * + SailModel + ::GetHemisphericalReflectance() + { + if(this->GetNumberOfOutputs() < 4) + { + //exit + return ITK_NULLPTR; + } + return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(1)); + } /** Get output viewing absorptance */ -SailModel::SpectralResponseType * -SailModel -::GetViewingAbsorptance() -{ - if(this->GetNumberOfOutputs() < 4) - { - //exit - return ITK_NULLPTR; - } - return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(2)); -} + SailModel::SpectralResponseType * + SailModel + ::GetViewingAbsorptance() + { + if(this->GetNumberOfOutputs() < 4) + { + //exit + return ITK_NULLPTR; + } + return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(2)); + } /** Get output hemispherical absorptance */ -SailModel::SpectralResponseType * -SailModel -::GetHemisphericalAbsorptance() -{ - if(this->GetNumberOfOutputs() < 4) - { - //exit - return ITK_NULLPTR; - } - return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(3)); -} + SailModel::SpectralResponseType * + SailModel + ::GetHemisphericalAbsorptance() + { + if(this->GetNumberOfOutputs() < 4) + { + //exit + return ITK_NULLPTR; + } + return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(3)); + } /** Set Parameters */ -void -SailModel -::SetInput(const ParametersType & params) -{ - - if(params.Size()!=8) itkExceptionMacro( << "Must have 8 parameters in that order : LAI, Angl, PSoil, Skyl, HSpot, TTS, TTO, PSI" ); - this->SetParameters(params); - m_LAI=params[0]; - m_Angl=params[1]; + void + SailModel + ::SetInput(const ParametersType & params) + { + + if(params.Size()!=8) itkExceptionMacro( << "Must have 8 parameters in that order : LAI, Angl, PSoil, Skyl, HSpot, TTS, TTO, PSI" ); + this->SetParameters(params); + m_LAI=params[0]; + m_Angl=params[1]; m_PSoil=params[2]; m_Skyl=params[3]; m_HSpot=params[4]; @@ -319,7 +319,14 @@ SailModel // Soil Reflectance Properties //rsoil1 = dry soil //rsoil2 = wet soil - rsoil0 = m_PSoil*Rsoil1+(1-m_PSoil)*Rsoil2; + if(!m_UseSoilFile) + { + rsoil0 = m_PSoil*Rsoil1+(1-m_PSoil)*Rsoil2; + } + else + { + rsoil0 = m_SoilDataBase->GetReflectance(m_SoilIndex, lambda)*m_PSoil; + } // Here rho and tau come in sigb = ddb*rho+ddf*tau; @@ -339,94 +346,94 @@ SailModel // Here the LAI comes in // Outputs for the case LAI = 0 if (m_LAI<0) - { - //tss = 1; - too = 1; - tsstoo = 1; - rdd = 0; - tdd = 1; - rsd = 0; - tsd = 0; - rdo = 0; - tdo = 0; - //rso = 0; - rsos = 0; - rsod = 0; - - rddt = rsoil0; - rsdt = rsoil0; - rdot = rsoil0; - rsodt = 0; - rsost = rsoil0; - //rsot = rsoil0; - } - - // Other cases (LAI > 0) - e1 = exp(-m*m_LAI); - e2 = e1*e1; - rinf = (att-m)/sigb; - rinf2 = rinf*rinf; - re = rinf*e1; - denom = 1.-rinf2*e2; - - J1ks=Jfunc1(ks, m, m_LAI); - J2ks=Jfunc2(ks, m, m_LAI); - J1ko=Jfunc1(ko, m, m_LAI); - J2ko=Jfunc2(ko, m, m_LAI); - - Ps = (sf+sb*rinf)*J1ks; - Qs = (sf*rinf+sb)*J2ks; - Pv = (vf+vb*rinf)*J1ko; - Qv = (vf*rinf+vb)*J2ko; - - rdd = rinf*(1.-e2)/denom; - tdd = (1.-rinf2)*e1/denom; - tsd = (Ps-re*Qs)/denom; - rsd = (Qs-re*Ps)/denom; - tdo = (Pv-re*Qv)/denom; - rdo = (Qv-re*Pv)/denom; - - tss = exp(-ks*m_LAI); - too = exp(-ko*m_LAI); - z = Jfunc3(ks, ko, m_LAI); - g1 = (z-J1ks*too)/(ko+m); - g2 = (z-J1ko*tss)/(ks+m); - - Tv1 = (vf*rinf+vb)*g1; - Tv2 = (vf+vb*rinf)*g2; - T1 = Tv1*(sf+sb*rinf); - T2 = Tv2*(sf*rinf+sb); - T3 = (rdo*Qs+tdo*Ps)*rinf; - - // Multiple scattering contribution to bidirectional canopy reflectance - rsod = (T1+T2-T3)/(1.-rinf2); - - // Treatment of the hotspot-effect - alf=1e6; - // Apply correction 2/(K+k) suggested by F.-M. Bron - if (m_HSpot>0) alf=(dso/m_HSpot)*2./(ks+ko); - if (alf>200) alf=200; - if (alf==0) - { - // The pure hotspot - no shadow - tsstoo = tss; - sumint = (1-tss)/(ks*m_LAI); - } - else - { - // Outside the hotspot - fhot=m_LAI*vcl_sqrt(ko*ks); - // Integrate by exponential Simpson method in 20 steps - // the steps are arranged according to equal partitioning - // of the slope of the joint probability function - x1=0; - y1=0; - f1=1; - fint=(1.-exp(-alf))*0.05; - sumint=0; - - for(unsigned int j=1; j<=20; ++j) - { + { + //tss = 1; + too = 1; + tsstoo = 1; + rdd = 0; + tdd = 1; + rsd = 0; + tsd = 0; + rdo = 0; + tdo = 0; + //rso = 0; + rsos = 0; + rsod = 0; + + rddt = rsoil0; + rsdt = rsoil0; + rdot = rsoil0; + rsodt = 0; + rsost = rsoil0; + //rsot = rsoil0; + } + + // Other cases (LAI > 0) + e1 = exp(-m*m_LAI); + e2 = e1*e1; + rinf = (att-m)/sigb; + rinf2 = rinf*rinf; + re = rinf*e1; + denom = 1.-rinf2*e2; + + J1ks=Jfunc1(ks, m, m_LAI); + J2ks=Jfunc2(ks, m, m_LAI); + J1ko=Jfunc1(ko, m, m_LAI); + J2ko=Jfunc2(ko, m, m_LAI); + + Ps = (sf+sb*rinf)*J1ks; + Qs = (sf*rinf+sb)*J2ks; + Pv = (vf+vb*rinf)*J1ko; + Qv = (vf*rinf+vb)*J2ko; + + rdd = rinf*(1.-e2)/denom; + tdd = (1.-rinf2)*e1/denom; + tsd = (Ps-re*Qs)/denom; + rsd = (Qs-re*Ps)/denom; + tdo = (Pv-re*Qv)/denom; + rdo = (Qv-re*Pv)/denom; + + tss = exp(-ks*m_LAI); + too = exp(-ko*m_LAI); + z = Jfunc3(ks, ko, m_LAI); + g1 = (z-J1ks*too)/(ko+m); + g2 = (z-J1ko*tss)/(ks+m); + + Tv1 = (vf*rinf+vb)*g1; + Tv2 = (vf+vb*rinf)*g2; + T1 = Tv1*(sf+sb*rinf); + T2 = Tv2*(sf*rinf+sb); + T3 = (rdo*Qs+tdo*Ps)*rinf; + + // Multiple scattering contribution to bidirectional canopy reflectance + rsod = (T1+T2-T3)/(1.-rinf2); + + // Treatment of the hotspot-effect + alf=1e6; + // Apply correction 2/(K+k) suggested by F.-M. Bron + if (m_HSpot>0) alf=(dso/m_HSpot)*2./(ks+ko); + if (alf>200) alf=200; + if (alf==0) + { + // The pure hotspot - no shadow + tsstoo = tss; + sumint = (1-tss)/(ks*m_LAI); + } + else + { + // Outside the hotspot + fhot=m_LAI*vcl_sqrt(ko*ks); + // Integrate by exponential Simpson method in 20 steps + // the steps are arranged according to equal partitioning + // of the slope of the joint probability function + x1=0; + y1=0; + f1=1; + fint=(1.-exp(-alf))*0.05; + sumint=0; + + for(unsigned int j=1; j<=20; ++j) + { if (j<20) x2 = -vcl_log(1.-j*fint)/alf; else x2 = 1; y2 = -(ko+ks)*m_LAI*x2+fhot*(1.-exp(-alf*x2))/alf; @@ -435,13 +442,13 @@ SailModel x1=x2; y1=y2; f1=f2; - } - tsstoo=f1; - } + } + tsstoo=f1; + } - // Bidirectional reflectance - // Single scattering contribution - rsos = w*m_LAI*sumint; + // Bidirectional reflectance + // Single scattering contribution + rsos = w*m_LAI*sumint; // Total canopy contribution // rso=rsos+rsod; //Interaction with the soil @@ -478,7 +485,7 @@ SailModel void SailModel -::Calc_LIDF(const double a, VectorType &lidf) +::Calc_LIDF(const double a, VectorType &lidf) const { int ala=a; VectorType freq; @@ -490,7 +497,7 @@ SailModel void SailModel -::Campbell(const double ala, VectorType &freq) +::Campbell(const double ala, VectorType &freq) const { unsigned int n=18; double excent = exp(-1.6184e-5*vcl_pow(ala, 3)+2.1145e-3*ala*ala-1.2390e-1*ala+3.2491); @@ -552,7 +559,7 @@ SailModel void SailModel -::Volscatt(const double tts, const double tto, const double psi, const double ttl, VectorType &result) +::Volscatt(const double tts, const double tto, const double psi, const double ttl, VectorType &result) const { double rd = CONST_PI/180; @@ -666,7 +673,7 @@ SailModel double SailModel -::Jfunc1(const double k, const double l, const double t) +::Jfunc1(const double k, const double l, const double t) const { //J1 function with avoidance of singularity problem double v; @@ -686,7 +693,7 @@ SailModel double SailModel -::Jfunc2(const double k, const double l, const double t) +::Jfunc2(const double k, const double l, const double t) const { double v; v = (1.-exp(-(k+l)*t))/(k+l); @@ -696,7 +703,7 @@ SailModel double SailModel -::Jfunc3(const double k, const double l, const double t) +::Jfunc3(const double k, const double l, const double t) const { double v; v = (1.-exp(-(k+l)*t))/(k+l); @@ -711,4 +718,12 @@ SailModel Superclass::PrintSelf(os, indent); } + +void SailModel::UseExternalSoilDB(std::shared_ptr<SoilDataBase> SoilDB, + size_t SoilIndex) +{ + m_UseSoilFile = true; + m_SoilIndex = SoilIndex; + m_SoilDataBase = SoilDB; +} } // end namespace otb diff --git a/Modules/Radiometry/Simulation/src/otbSoilDataBase.cxx b/Modules/Radiometry/Simulation/src/otbSoilDataBase.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6c7686a3ecf6ce509a44d04611d0946d7950df73 --- /dev/null +++ b/Modules/Radiometry/Simulation/src/otbSoilDataBase.cxx @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "otbSoilDataBase.h" +#include <fstream> +#include <sstream> +#include <algorithm> +#include <boost/algorithm/string.hpp> +#include "itkMacro.h" + + +namespace otb +{ + +SoilDataBase::SoilDataBase(const std::string& SoilFileName, double wlfactor) : + m_SoilFileName(SoilFileName), m_WlFactor(wlfactor) +{ + ParseSoilFile(); +}; + +const typename SoilDataBase::SoilDataVector& SoilDataBase::GetDB() const +{ + return m_SoilDataVector; +} + +double SoilDataBase::GetReflectance(size_t SoilIndex, WavelenghtType wl) const +{ + if(SoilIndex >= m_SoilDataVector.size()) + { + std::stringstream errmessg; + errmessg << "Soil index must be >= 0 and < " << m_SoilDataVector.size() << + ". " << SoilIndex <<" was passed.\n"; + throw std::range_error( errmessg.str() ); + } + // wl not in the set of measured ones + if(m_SoilDataVector[SoilIndex].find(wl)==m_SoilDataVector[SoilIndex].end()) + { + const auto wlmin = m_Wavelengths[0]; + const auto wlmax = m_Wavelengths[m_Wavelengths.size()-1]; + if(wl<wlmin) return (*m_SoilDataVector[SoilIndex].find(wlmin)).second; + if(wl>wlmax) return (*m_SoilDataVector[SoilIndex].find(wlmax)).second; + + const auto p = std::partition_point(m_Wavelengths.cbegin(), m_Wavelengths.cend(), + [&](WavelenghtType w){ return w<wl;} + ); + const auto wlinf = *(p-1); + const auto wlsup = *p; + const auto factinf = wl-wlinf; + const auto factsup = wlsup-wl; + const auto vinf = (*m_SoilDataVector[SoilIndex].find(wlinf)).second; + const auto vsup = (*m_SoilDataVector[SoilIndex].find(wlsup)).second; + return (vinf*factinf+vsup*factsup)/(factinf+factsup); + } + else + { + return (*m_SoilDataVector[SoilIndex].find(wl)).second; + } +} + +size_t SoilDataBase::CountColumns(std::string fileName) const +{ + std::ifstream ifile(fileName.c_str()); + std::string line; + if (ifile.is_open()) + { + size_t nbSpaces = 0; + if(!getline(ifile,line)) + { + itkGenericExceptionMacro(<< "Error reading file " << fileName); + } + ifile.close(); + boost::trim(line); + auto found = line.find(' '); + while(found!=std::string::npos) + { + ++nbSpaces; + while(line[found+1] == ' ') ++found; + found = line.find(' ', found+1); + } + return nbSpaces+1; + } + else + { + itkGenericExceptionMacro(<< "Could not open file " << fileName); + } +} +void SoilDataBase::ParseSoilFile() +{ + auto number_of_soils = CountColumns(m_SoilFileName) - 1; + m_SoilDataVector.resize(number_of_soils); + std::ifstream sdb(m_SoilFileName); + if(! sdb.is_open()) + { + itkGenericExceptionMacro(<< "Could not open file " << m_SoilFileName); + } + std::string line; + while(std::getline(sdb, line)) + { + if(line.size() > 3) + { + std::stringstream ss(line); + double tmpwl; + ss >> tmpwl; + WavelenghtType wl = static_cast<WavelenghtType>(m_WlFactor*tmpwl); + m_Wavelengths.push_back(wl); + for(size_t i=0; i< number_of_soils; ++i) + { + double refl; + ss >> refl; + m_SoilDataVector[i][wl] = refl; + } + } + } + std::sort(m_Wavelengths.begin(), m_Wavelengths.end()); +} +}// namespace otb diff --git a/Modules/Radiometry/Simulation/test/CMakeLists.txt b/Modules/Radiometry/Simulation/test/CMakeLists.txt index fc44b849a94be0157179642837bd8d185e86ca35..bcb073372891b6d7cba40aa8aaa8c7db4536a9ea 100644 --- a/Modules/Radiometry/Simulation/test/CMakeLists.txt +++ b/Modules/Radiometry/Simulation/test/CMakeLists.txt @@ -53,10 +53,11 @@ otbSailReflVTest.cxx otbSatelliteRSRNew.cxx otbSailReflHTest.cxx otbFilterFunctionValues.cxx +otbSoilDBTest.cxx ) add_executable(otbSimulationTestDriver ${OTBSimulationTests}) -target_link_libraries(otbSimulationTestDriver ${OTBSimulation-Test_LIBRARIES}) +target_link_libraries(otbSimulationTestDriver ${OTBSimulation-Test_LIBRARIES} ) otb_module_target_label(otbSimulationTestDriver) # Tests Declaration @@ -318,3 +319,46 @@ otb_add_test(NAME raTuFilterFunctionValuesTest COMMAND otbSimulationTestDriver 0.05 # user step 0.2 0.5 0.3 0.9 0.8 # vector ) + +otb_add_test(NAME siTvSoilDataParseFile COMMAND otbSimulationTestDriver otbSoilDataBaseParseFile + ${INPUTDATA}/Radiometry/Soils/sols_avignon_1990.txt + 400 # wlmin + 2450# wlmax + 10 # wlstep + 400 # wltest + 0 # soil index test + 1.0200000e-001 # refl test + 460 + 2 + 6.2000000e-002 + 2440 + 134 + 6.8700000e-001 + 2450 + 133 + 6.0800000e-001 + ) + +otb_add_test(NAME siTvSailReflHSoilTest COMMAND otbSimulationTestDriver + --compare-ascii ${EPSILON_3} ${BASELINE_FILES}/Simulation/siTvSailReflHSoilTest.txt + ${TEMP}/siTvSailReflHSoilTest.txt + otbSailReflHTest + 30.0 #cab + 10.0 #car + 0.0 #CBrown + 0.015 #Cw + 0.009 #Cm + 1.2 #N + 2 #LAI + 50 #Angl + 1 #PSoil + 70 #Skyl + 0.2 #HSpot + 30 #TTS + 0 #TTO + 0 #PSI + ${TEMP}/siTvSailReflHSoilTest.txt + ${INPUTDATA}/Radiometry/Soils/sols_avignon_1990.txt + 20 # soil index + 1000 #wlfactor + ) diff --git a/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx b/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx index dfd6c31c3831f31ec9779bf91315b8b6835f0e59..33f6d8cbeabe245a75fe2b42ff9ef03917cdfd09 100644 --- a/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx +++ b/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx @@ -29,11 +29,11 @@ int otbSailReflHTest(int argc, char * argv[]) { - if(argc != 16) - { - std::cout<<"Wrong number of arguments !"<<std::endl; - return EXIT_FAILURE; - } + if(argc < 16 || argc > 19) + { + std::cout<<"Wrong number of arguments !"<<std::endl; + return EXIT_FAILURE; + } double Cab=static_cast<double>(atof(argv[1])); double Car=static_cast<double>(atof(argv[2])); @@ -50,6 +50,17 @@ int otbSailReflHTest(int argc, char * argv[]) double TTO=static_cast<double>(atof(argv[13])); double PSI=static_cast<double>(atof(argv[14])); char * OutputName = argv[15]; + std::string SoilFileName{}; + size_t SoilIndex{0}; + double WlFactor{1000}; + bool UseSoilFile = false; + if(argc == 19) + { + UseSoilFile = true; + SoilFileName = argv[16]; + SoilIndex = static_cast<size_t>(atoi(argv[17])); + WlFactor = static_cast<double>(atof(argv[18])); + } typedef otb::ProspectModel ProspectType; @@ -81,13 +92,20 @@ int otbSailReflHTest(int argc, char * argv[]) sail->SetPSI(PSI); sail->SetReflectance(prospect->GetReflectance()); sail->SetTransmittance(prospect->GetTransmittance()); + std::shared_ptr<otb::SoilDataBase> SoilDB; + if(UseSoilFile) + { + std::cout << "Using soil file " << SoilFileName << '\n'; + SoilDB = std::make_shared<otb::SoilDataBase>(SoilFileName, WlFactor); + sail->UseExternalSoilDB(SoilDB, SoilIndex); + } sail->Update(); std::ofstream outputFile(OutputName, std::ios::out); for(unsigned int i=0; i<sail->GetHemisphericalReflectance()->Size(); ++i) - { - outputFile<<sail->GetHemisphericalReflectance()->GetResponse()[i].second<<std::endl; - } + { + outputFile<<sail->GetHemisphericalReflectance()->GetResponse()[i].second<<std::endl; + } return EXIT_SUCCESS; diff --git a/Modules/Radiometry/Simulation/test/otbSimulationTestDriver.cxx b/Modules/Radiometry/Simulation/test/otbSimulationTestDriver.cxx index 854e8b8b25d77b803b8dee10beda90e2c3df17cb..8ae63e04d0381f176bda436767d79e7b74c4f49d 100644 --- a/Modules/Radiometry/Simulation/test/otbSimulationTestDriver.cxx +++ b/Modules/Radiometry/Simulation/test/otbSimulationTestDriver.cxx @@ -50,4 +50,5 @@ void RegisterTests() REGISTER_TEST(otbSailReflHTest); REGISTER_TEST(otbFilterFunctionValuesSpectralResponseTest); REGISTER_TEST(otbFilterFunctionValuesTest); + REGISTER_TEST(otbSoilDataBaseParseFile); } diff --git a/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx b/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..49e89d70444dbcca3ebba8cf52187cf100079788 --- /dev/null +++ b/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "otbMacro.h" +#include "otbSoilDataBase.h" +#include <iostream> + +int otbSoilDataBaseParseFile(int argc, char * argv[]) +{ + if(argc < 5) + { + std::cout << "Usage: " << argv[0] << " soil_file wlmin wlmax wlstep wltest1 soilindextest1 refltest1 [wltest2 soilindextest2 refltest2 ...]" << '\n'; + return EXIT_FAILURE; + } + std::string sfn(argv[1]); + + otb::SoilDataBase sdb(sfn, 1000); + auto db = sdb.GetDB(); + + for(unsigned int i=5; i<static_cast<unsigned int>(argc); i+=3) + { + auto wltest = std::stoi(argv[i]); + auto sindex = std::stoi(argv[i+1]); + auto refltest = std::stod(argv[i+2]); + auto read_refl = db[sindex][wltest]; + if(fabs(refltest-read_refl)>10e-5) + { + std::cout << "GetDB " << i << " " << refltest << " " << read_refl << "\n"; + return EXIT_FAILURE; + } + + read_refl = sdb.GetReflectance(sindex, wltest); + if(fabs(refltest-read_refl)>10e-5) + { + std::cout << "GetRefl " << i << " " << refltest << " " << read_refl << "\n"; + return EXIT_FAILURE; + } + + } + + for(unsigned int i=5; i<static_cast<unsigned int>(argc); i+=3) + { + auto wltest = std::stoi(argv[i]); + auto sindex = std::stoi(argv[i+1]); + auto refltest = std::stod(argv[i+2]); + auto read_refl = db[sindex][wltest]; + + read_refl = sdb.GetReflectance(sindex, wltest+1); + if(fabs(refltest-read_refl)>10e-2) + { + std::cout << refltest << " " << read_refl << '\n'; + return EXIT_FAILURE; + } + + } + + return EXIT_SUCCESS; +} + diff --git a/Modules/Visualization/Mapla/src/mvdMaplaWin32.rc.in b/Modules/Visualization/Mapla/src/mvdMaplaWin32.rc.in index 59c150741c2d6544df9fdaf41eb6de06dbf1a800..9c40a86f8cec28f6cc0cbd48d459878bc44a7ee2 100644 --- a/Modules/Visualization/Mapla/src/mvdMaplaWin32.rc.in +++ b/Modules/Visualization/Mapla/src/mvdMaplaWin32.rc.in @@ -16,7 +16,7 @@ BEGIN BLOCK "000004b0" BEGIN VALUE "CompanyName", "OrfeoToolbox" - VALUE "FileDescription", "Monteverdi 2" + VALUE "FileDescription", "Monteverdi" VALUE "FileVersion", "@Monteverdi_VERSION_MAJOR@.@Monteverdi_VERSION_MINOR@.@Monteverdi_VERSION_PATCH@.0" VALUE "LegalCopyright", "Copyright (c) 2012-2013 Centre National d'Etudes Spatiales. All rights reserved." VALUE "InternalName", "mapla" diff --git a/Modules/Visualization/Monteverdi/src/mvdWin32.rc.in b/Modules/Visualization/Monteverdi/src/mvdWin32.rc.in index fdb8647ebd9224e7b7c4e93078dd8519da12d612..c26d776103b87385ed3d05e1ac958eb35f1b99d4 100644 --- a/Modules/Visualization/Monteverdi/src/mvdWin32.rc.in +++ b/Modules/Visualization/Monteverdi/src/mvdWin32.rc.in @@ -16,12 +16,12 @@ BEGIN BLOCK "000004b0" BEGIN VALUE "CompanyName", "OrfeoToolbox" - VALUE "FileDescription", "Monteverdi 2" + VALUE "FileDescription", "Monteverdi" VALUE "FileVersion", "@Monteverdi_VERSION_MAJOR@.@Monteverdi_VERSION_MINOR@.@Monteverdi_VERSION_PATCH@.0" VALUE "LegalCopyright", "Copyright (c) 2012-2013 Centre National d'Etudes Spatiales. All rights reserved." VALUE "InternalName", "monteverdi" VALUE "OriginalFilename", "monteverdi.exe" - VALUE "ProductName", "Monteverdi 2" + VALUE "ProductName", "Monteverdi" VALUE "ProductVersion", "@Monteverdi_VERSION_MAJOR@.@Monteverdi_VERSION_MINOR@.@Monteverdi_VERSION_PATCH@.0" END END diff --git a/Modules/Wrappers/ApplicationEngine/include/otbLogger.h b/Modules/Wrappers/ApplicationEngine/include/otbLogger.h new file mode 100644 index 0000000000000000000000000000000000000000..ba43072a199e2a1e29f481dc232022e457017389 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/include/otbLogger.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbLogger_h +#define otbLogger_h + +#include "itkLoggerBase.h" +#include "itkLogger.h" + +namespace otb { + +/** \class Logger + * \brief An ITK logger specialized for OTB + * + * Sets OTB wide settings in its constructor + * + * \ingroup OTBApplicationEngine + */ +class Logger : public itk::Logger +{ +public: + typedef Logger Self; + typedef itk::Logger Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + itkTypeMacro(Logger, Object); + itkNewMacro(Self); + + // Overwrite this to provide custom formatting of log entries + std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; + +protected: + Logger(); + virtual ~Logger(); +}; // class Logger + +} // namespace otb + +#endif // otbLogger_h diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 57286317e950ee5de9fa7c64e0da5fc1470a9f72..3d944f931ca7f268d8b0b07389f97bf5cf289af6 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -26,7 +26,7 @@ #include "otbWrapperTags.h" #include "otbWrapperParameterGroup.h" -#include "itkLogger.h" +#include "otbLogger.h" #include "itkTimeProbe.h" #include "otbWrapperMacros.h" #include "otbWrapperInputImageParameter.h" @@ -40,6 +40,37 @@ namespace otb { + +/** \class ApplicationException + * \brief Exception for runtime errors in OTB Applications + * + * Usually thrown with the otbAppLogFATAL macro + * + * \ingroup OTBApplicationEngine + */ +class ApplicationException : public itk::ExceptionObject +{ +public: + /** Run-time information. */ + itkTypeMacro( ApplicationException, ExceptionObject ); + + /** Constructor. */ + ApplicationException(const char *file, unsigned int line, + const char* message = "Application error.", + const char* loc = "Unknown") : + ExceptionObject(file, line, message, loc) + { + } + + /** Constructor. */ + ApplicationException(const std::string &file, unsigned int line, + const char* message = "Application error.", + const char* loc = "Unknown") : + ExceptionObject(file, line, message, loc) + { + } +}; + namespace Wrapper { @@ -70,6 +101,7 @@ public: m_Name = name; GetDocExample()->SetApplicationName(name); this->Modified(); + m_Logger->SetName(name); } itkGetStringMacro(Name); @@ -663,7 +695,7 @@ public: */ ComplexImagePixelType GetParameterComplexOutputImagePixelType(std::string parameter); - itk::Logger* GetLogger(); + otb::Logger* GetLogger(); itk::ProcessObject* GetProgressSource() const; @@ -916,7 +948,6 @@ protected: } } - private: /* Implement this method to add parameters */ virtual void DoInit() = 0; @@ -938,7 +969,7 @@ private: std::string m_Name; std::string m_Description; ParameterGroup::Pointer m_ParameterList; - itk::Logger::Pointer m_Logger; + otb::Logger::Pointer m_Logger; itk::ProcessObject::Pointer m_ProgressSource; std::string m_ProgressSourceDescription; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h index 94a5429f0563ef3a3cc2233ca0267d966131fa90..6b4bf70c7d66869098aa17dc42aa2a7f12fc5d4f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h @@ -71,7 +71,9 @@ public: /** Get one specific stored image filename. */ std::string GetNthFileName( unsigned int i ) const; - /** Get one list of the stored image. */ + /** Get one list of the stored image. WARNING : if the parameter list changes, + * the returned image list may become obsolete. You should call + * GetImageList() again to make sure your image list is up-to-date. */ FloatVectorImageListType* GetImageList() const; /** Get one specific stored image. */ diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index f8aa185cedefc55657c3cbc98c2fa6abdf78f72b..64a620f70610e941fc293f1ada0704d904fbc22b 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -56,14 +56,7 @@ InputImageParameter::GetImage() typename ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(m_FileName); - try - { - reader->UpdateOutputInformation(); - } - catch (itk::ExceptionObject &) - { - this->ClearValue(); - } + reader->UpdateOutputInformation(); m_Image = reader->GetOutput(); m_Reader = reader; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperMacros.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperMacros.h index 49da20449c4ec637e5ff474011b84b9b3e5cec66..39e4c57d938c3e58c6064b30da019aed529585bf 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperMacros.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperMacros.h @@ -24,10 +24,15 @@ #define otbAppLogFATAL(x) \ { \ - std::ostringstream msg; \ - msg << "" x << std::endl; \ - this->GetLogger()->Write( itk::LoggerBase::FATAL, msg.str() ); \ - itkGenericExceptionMacro(<< "Fatal error caught. Aborting..."); \ + std::ostringstream msg; \ + msg << "" x << std::endl; \ + this->GetLogger()->Fatal(msg.str()); \ + { \ + std::ostringstream message; \ + message << "otb::ApplicationException " x; \ + ::otb::ApplicationException e_(__FILE__, __LINE__, message.str().c_str(), ITK_LOCATION); \ + throw e_; /* Explicit naming to work around Intel compiler bug. */ \ + } \ } #define otbAppLogCRITICAL(x) \ diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 6bfea3af16946d97709a23d8f148558cc763b7ee..3251a05d8e7f250abf1aae901438544cd7ae13eb 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -48,6 +48,7 @@ set(OTBApplicationEngine_SRC otbWrapperApplicationRegistry.cxx otbWrapperApplicationFactoryBase.cxx otbWrapperCompositeApplication.cxx + otbLogger.cxx ) add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC}) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbLogger.cxx b/Modules/Wrappers/ApplicationEngine/src/otbLogger.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f7994eed4db3a1830b7fc2e1028bd23344c205eb --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbLogger.cxx @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbLogger.h" +#include "itksys/SystemTools.hxx" + +namespace otb +{ + +Logger::Logger() : + itk::Logger::Logger() +{ +#if OTB_DEBUG + this->SetPriorityLevel(itk::LoggerBase::DEBUG); +#else + this->SetPriorityLevel(itk::LoggerBase::INFO); +#endif + + this->SetLevelForFlushing(itk::LoggerBase::CRITICAL); + + this->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE); + this->SetHumanReadableFormat("%Y-%m-%d %H:%M:%S"); +} + +Logger::~Logger() +{ +} + +std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, std::string const & content) +{ + static const std::string levelString[] = { "(MUSTFLUSH)", "(FATAL)", "(CRITICAL)", + "(WARNING)", "(INFO)", "(DEBUG)", "(NOTSET)" }; + + // TODO: assert(level <= std::extent<decltype(levelString)>::value); // requires C++11 + + std::ostringstream s; + + + switch ( this->m_TimeStampFormat ) + { + case REALVALUE: + { + s.precision(30); + s << m_Clock->GetTimeInSeconds(); + break; + } + case HUMANREADABLE: + { + s << itksys::SystemTools::GetCurrentDateTime( this->m_HumanReadableFormat.c_str() ); + break; + } + } + s << " " << levelString[level] << ": " << content; + + return s.str(); +} + +} // namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 5c68b10c37fd720e34060e674f9434869842e25d..7a7b45bb34e6b7b329b8ce174bd916d9a2f24c4d 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -53,7 +53,7 @@ namespace Wrapper Application::Application() : m_Name(""), m_Description(""), - m_Logger(itk::Logger::New()), + m_Logger(otb::Logger::New()), m_ProgressSourceDescription(""), m_DocName(""), m_DocLongDescription(""), @@ -68,15 +68,13 @@ Application::Application() { // Don't call Init from the constructor, since it calls a virtual method ! m_Logger->SetName("Application.logger"); - m_Logger->SetPriorityLevel(itk::LoggerBase::DEBUG); - m_Logger->SetLevelForFlushing(itk::LoggerBase::CRITICAL); } Application::~Application() { } -itk::Logger* Application::GetLogger() +otb::Logger* Application::GetLogger() { return m_Logger; } @@ -199,9 +197,7 @@ void Application::SetParameterString(std::string parameter, std::string value, b else if (dynamic_cast<InputImageParameter*>(param)) { InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); - if ( !paramDown->SetFromFileName(value) ) - otbAppLogCRITICAL( <<"Invalid image filename " << value <<"."); - + paramDown->SetFromFileName(value); } else if (dynamic_cast<ComplexInputImageParameter*>(param)) { @@ -436,7 +432,7 @@ int Application::ExecuteAndWriteOutput() std::string checkReturn = outputParam->CheckFileName(true); if (!checkReturn.empty()) { - otbAppLogWARNING("Check filename : "<<checkReturn); + otbAppLogWARNING("Check filename: "<<checkReturn); } if (useRAM) { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx index 059dc30217c4505c0cc6de3b2af5814294c2e0af..e65e22078177f51cf6d8f85a188d68f4ac9f1416 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx @@ -43,38 +43,21 @@ InputFilenameListParameter::SetListFromFileName(const std::vector<std::string> & // First clear previous file chosen this->ClearValue(); - bool isOk = true; for(unsigned int i=0; i<filenames.size(); i++) { std::string filename = filenames[i]; - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) // File existence checked by the reader if (!filename.empty()) { StringParameter::Pointer strParameter = StringParameter::New(); strParameter->SetValue(filename); - try - { - strParameter->HasValue(); - } - catch(itk::ExceptionObject & /*err*/) - { - this->ClearValue(); - isOk = false; - break; - } + strParameter->HasValue(); // everything went fine, store the object reference m_FilenameList->PushBack(strParameter); } } - if( !isOk ) - { - return false; - } - SetActive(true); this->Modified(); return true; @@ -92,22 +75,12 @@ InputFilenameListParameter::AddNullElement() bool InputFilenameListParameter::AddFromFileName(const std::string & filename) { - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) // File existence checked by the reader if (!filename.empty()) { StringParameter::Pointer strParameter = StringParameter::New(); strParameter->SetValue(filename); - try - { - strParameter->HasValue(); - } - catch(itk::ExceptionObject & /*err*/) - { - this->ClearValue(); - return false; - } + strParameter->HasValue(); // everything went fine, store the object references m_FilenameList->PushBack(strParameter); @@ -127,22 +100,12 @@ InputFilenameListParameter::SetNthFileName( const unsigned int id, const std::st itkExceptionMacro(<< "No file "<<id<<". Only "<<m_FilenameList->Size()<<" filenames available."); } - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) // File existence checked by the reader if (!filename.empty()) { StringParameter::Pointer strParameter = StringParameter::New(); strParameter->SetValue(filename); - try - { - strParameter->HasValue(); - } - catch(itk::ExceptionObject &) - { - this->ClearValue(); - return false; - } + strParameter->HasValue(); m_FilenameList->SetNthElement(id, strParameter); SetActive(true); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx index 01be700ea7f9055d967cd8a466dc39cc55f1e313..cd41fcf1d80f0ffd3edcfeb1980ee6195a8654dc 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx @@ -44,40 +44,23 @@ InputImageListParameter::SetListFromFileName(const std::vector<std::string> & fi // First clear previous file chosen this->ClearValue(); - bool isOk = true; for(unsigned int i=0; i<filenames.size(); i++) { const std::string filename = filenames[i]; - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) + // File existence checked by the reader if (!filename.empty()) { // Try to build a new ParameterInputImage InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - tmpInputImageParameter->SetFromFileName(filename); - if(!tmpInputImageParameter->HasValue()) - { - // If loading failed - this->ClearValue(); - isOk = false; - break; - } - m_InputImageParameterVector.push_back(tmpInputImageParameter); - m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage()); } } - if( !isOk ) - { - return false; - } - - SetActive(true); this->Modified(); + SetActive(true); return true; } @@ -86,7 +69,6 @@ void InputImageListParameter::AddNullElement() { m_InputImageParameterVector.push_back(ITK_NULLPTR); - m_ImageList->PushBack(ITK_NULLPTR); SetActive(false); this->Modified(); } @@ -94,27 +76,16 @@ InputImageListParameter::AddNullElement() bool InputImageListParameter::AddFromFileName(const std::string & filename) { - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) // File existence checked by the reader if (!filename.empty()) { - // Try to build a new ParameterInputImage InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - tmpInputImageParameter->SetFromFileName(filename); - - if(!tmpInputImageParameter->HasValue()) - { - // If loading failed - this->ClearValue(); - return false; - } - + m_InputImageParameterVector.push_back(tmpInputImageParameter); - m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage()); - SetActive(true); + this->Modified(); + SetActive(true); return true; } @@ -129,24 +100,14 @@ InputImageListParameter::SetNthFileName( const unsigned int id, const std::strin itkExceptionMacro(<< "No image "<<id<<". Only "<<m_InputImageParameterVector.size()<<" images available."); } - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) // File existence checked by the reader if (!filename.empty()) { InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - tmpInputImageParameter->SetFromFileName(filename); - if(!tmpInputImageParameter->HasValue()) - { - this->ClearValue(); - return false; - } - m_InputImageParameterVector[id] = tmpInputImageParameter; - m_ImageList->SetNthElement(id,tmpInputImageParameter->GetFloatVectorImage()); - + this->Modified(); SetActive(true); return true; @@ -166,7 +127,7 @@ InputImageListParameter::GetFileNameList() const { filenames.push_back( (*it)->GetFileName() ); } - + return filenames; } @@ -185,36 +146,32 @@ InputImageListParameter::GetNthFileName( unsigned int i ) const FloatVectorImageListType* InputImageListParameter::GetImageList() const { + m_ImageList->Clear(); + for (unsigned int i=0 ; i < this->Size() ; ++i) + { + m_ImageList->PushBack(m_InputImageParameterVector[i]->GetFloatVectorImage()); + } return m_ImageList; } FloatVectorImageType* InputImageListParameter::GetNthImage(unsigned int i) const { - if(m_ImageList->Size()<i) + if(this->Size()<=i) { - itkExceptionMacro(<< "No image "<<i<<". Only "<<m_ImageList->Size()<<" images available."); + itkExceptionMacro(<< "No image "<<i<<". Only "<<this->Size()<<" images available."); } - return m_ImageList->GetNthElement(i); + return m_InputImageParameterVector[i]->GetFloatVectorImage(); } void InputImageListParameter::SetImageList(FloatVectorImageListType* imList) { // Check input availability - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) - try - { - for(unsigned int i=0; i<imList->Size(); i++) - { - imList->GetNthElement( i )->UpdateOutputInformation(); - } - } - catch(itk::ExceptionObject &) - { - return; - } + for(unsigned int i = 0; i < imList->Size(); i++) + { + imList->GetNthElement(i)->UpdateOutputInformation(); + } // Clear previous values this->ClearValue(); @@ -223,39 +180,33 @@ InputImageListParameter::SetImageList(FloatVectorImageListType* imList) { // Try to build a new ParameterInputImage InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - + tmpInputImageParameter->SetImage(imList->GetNthElement(i)); - + m_InputImageParameterVector.push_back(tmpInputImageParameter); m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage()); } - + SetActive(true); this->Modified(); } void InputImageListParameter::SetNthImage(unsigned int i, ImageBaseType * img) { - if(m_ImageList->Size()<i) - { - itkExceptionMacro(<< "No image "<<i<<". Only "<<m_ImageList->Size()<<" images available."); - } - try - { - img->UpdateOutputInformation(); - } - catch(itk::ExceptionObject &) - { - return; - } - + if(this->Size()<i) + { + itkExceptionMacro(<< "No image "<<i<<". Only "<<this->Size()<<" images available."); + } + + // Check input availability + img->UpdateOutputInformation(); + // Try to build a new ParameterInputImage InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - + tmpInputImageParameter->SetImage(img); m_InputImageParameterVector[i] = tmpInputImageParameter; - m_ImageList->SetNthElement(i,tmpInputImageParameter->GetFloatVectorImage()); } @@ -263,23 +214,13 @@ void InputImageListParameter::AddImage(ImageBaseType* image) { // Check input availability - // TODO : when the logger will be available, redirect the exception - // in the logger (like what is done in MsgReporter) - try - { - image->UpdateOutputInformation(); - } - catch(itk::ExceptionObject &) - { - return; - } + image->UpdateOutputInformation(); InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New(); - + tmpInputImageParameter->SetImage(image); - + m_InputImageParameterVector.push_back(tmpInputImageParameter); - m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage()); this->Modified(); } @@ -287,16 +228,18 @@ InputImageListParameter::AddImage(ImageBaseType* image) bool InputImageListParameter::HasValue() const { - if(m_ImageList->Size() == 0) + if(this->Size() == 0) { return false; } bool res(true); unsigned int i(0); - while(i < m_ImageList->Size() && res == true) + while(i < this->Size() && res == true) { - res = m_ImageList->GetNthElement(i).IsNotNull(); + res = (m_InputImageParameterVector[i] ? + m_InputImageParameterVector[i]->HasValue() : + false); i++; } @@ -307,12 +250,11 @@ InputImageListParameter::HasValue() const void InputImageListParameter::Erase( unsigned int id ) { - if(m_ImageList->Size()<id) + if(this->Size()<id) { - itkExceptionMacro(<< "No image "<<id<<". Only "<<m_ImageList->Size()<<" images available."); + itkExceptionMacro(<< "No image "<<id<<". Only "<<this->Size()<<" images available."); } - m_ImageList->Erase( id ); m_InputImageParameterVector.erase(m_InputImageParameterVector.begin()+id); this->Modified(); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx index dcd9d215283d8ea80a71b816ab1a7a18d9ba84a4..08c0e1c36249954b7a18c58fd253f7df9d0d1b67 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx @@ -53,27 +53,10 @@ InputImageParameter::SetFromFileName(const std::string& filename) // - Done in the reader // - allow appending additional information to the filename // myfile.tif:2 for example, or myfile.tif:nocarto - if (!filename.empty()) - { - FloatVectorReaderType::Pointer reader = FloatVectorReaderType::New(); - - try - { - reader->SetFileName(filename); - reader->UpdateOutputInformation(); - } - catch(itk::ExceptionObject & /*err*/) - { - return false; - } - - // the specified filename is valid => store the value - m_FileName = filename; - m_UseFilename = true; - SetActive(true); - return true; - } - return false; + m_FileName = filename; + m_UseFilename = true; + SetActive(true); + return true; } diff --git a/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h b/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h index a7869e4842741e315d4adac5eb8d0e24972bf07e..c54d4a9fed22c2358c08f4589a08077ba5881443 100644 --- a/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h +++ b/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h @@ -134,7 +134,7 @@ protected: * Pay attention, the executable paths have to be loaded or set in * the environment before calling the function. */ - void LoadApplication(); + bool LoadApplication(); /** Parse the user expression, extract the key and the associated * string and set it as value of each corresponding application diff --git a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx index c684158fccf30be7fa54c11ddd20343cc141f96d..4c5bd8a93f43780e7d4827b260ae92e73ca9fde3 100644 --- a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx +++ b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx @@ -256,24 +256,28 @@ std::string CleanWord(const std::string & word) return res; } +void ShowUsage(char* argv[]) +{ + std::cerr << "Usage: " << argv[0] << " module_name [MODULEPATH] [arguments]" << std::endl; +} + int main(int argc, char* argv[]) { #ifdef OTB_USE_MPI otb::MPIConfig::Instance()->Init(argc,argv); #endif - + if (argc < 2) - { - std::cerr << "Usage : " << argv[0] << " module_name [MODULEPATH] [arguments]" << std::endl; - return EXIT_FAILURE; - } + { + ShowUsage(argv); + return false; + } std::vector<std::string> vexp; std::string exp; if (strcmp(argv[1], "-inxml") == 0) { - //exp = PrepareExpressionFromXML(argv[2]); vexp = PrepareVectorExpressionFromXML(argv[2]); } else @@ -281,15 +285,6 @@ int main(int argc, char* argv[]) // Construct the string expression for (int i = 1; i < argc; i++) { - /*if (i != argc - 1) - { - exp.append(argv[i]); - exp.append(" "); - } - else - { - exp.append(argv[i]); - }*/ std::string strarg(argv[i]); std::string cleanArg = CleanWord(strarg); if (cleanArg.empty()) @@ -300,12 +295,16 @@ int main(int argc, char* argv[]) vexp.push_back(cleanArg); } } - // std::cerr << exp << ":\n"; typedef otb::Wrapper::CommandLineLauncher LauncherType; LauncherType::Pointer launcher = LauncherType::New(); - //if (launcher->Load(exp) == true) + if (vexp.empty()) + { + ShowUsage(argv); + return false; + } + bool success = launcher->Load(vexp) && launcher->ExecuteAndWriteOutput(); // shutdown MPI after application finished diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx index 4be16ba228f5c27a3ad114f77609d011038a72e2..686d4d58cf65f248024accc8ad306cda13d73e4a 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx @@ -49,6 +49,8 @@ #include <string> #include <iostream> +using std::string; + namespace otb { namespace Wrapper @@ -94,20 +96,15 @@ bool CommandLineLauncher::Load(const std::vector<std::string> &vexp) bool CommandLineLauncher::Load() { - if (m_VExpression.empty()) - { - itkExceptionMacro("No expression specified..."); - } - if (this->CheckParametersPrefix() == false) { - std::cerr << "ERROR: Parameter keys have to set using \"-\", not \"--\"" << std::endl; + std::cerr << "ERROR: Parameters are set using \"-\", not \"--\"." << std::endl; return false; } if (this->CheckUnicity() == false) { - std::cerr << "ERROR: At least one key is not unique in the expression..." << std::endl; + std::cerr << "ERROR: At least one parameter is not unique in the expression." << std::endl; return false; } @@ -116,14 +113,12 @@ bool CommandLineLauncher::Load() if (m_Parser->GetPathsAsString(m_VExpression).size() != 0) { std::cerr << "ERROR: At least one specified path within \"" << m_Parser->GetPathsAsString(m_VExpression) - << "\" is invalid or doesn't exist..." << std::endl; + << "\" is invalid or doesn't exist." << std::endl; return false; } } - this->LoadApplication(); - - return true; + return this->LoadApplication(); } bool CommandLineLauncher::Execute() @@ -145,31 +140,54 @@ bool CommandLineLauncher::Execute() bool CommandLineLauncher::ExecuteAndWriteOutput() { try - { + { if (this->BeforeExecute() == false) - { + { return false; - } + } if( m_Application->ExecuteAndWriteOutput() == 0 ) - { + { this->DisplayOutputParameters(); - } + } else + { return false; } + } + catch(otb::ApplicationException& err) + { + // These are thrown with otbAppLogFATAL, a macro which logs a user + // friendly error message before throwing. So log exception details only + // in debug. + m_Application->GetLogger()->Debug("Caught otb::ApplicationException during application execution:\n"); + m_Application->GetLogger()->Debug(string(err.what()) + "\n"); + return false; + } + catch(otb::ImageFileReaderException& err) + { + m_Application->GetLogger()->Debug("Caught otb::ImageFileReaderException during application execution:\n"); + m_Application->GetLogger()->Debug(string(err.what()) + "\n"); + m_Application->GetLogger()->Fatal(string("Cannot open image ") + err.m_Filename + string(". ") + err.GetDescription() + string("\n")); + return false; + } + catch(itk::ExceptionObject& err) + { + m_Application->GetLogger()->Debug("Caught itk::ExceptionObject during application execution:\n"); + m_Application->GetLogger()->Debug(string(err.what()) + "\n"); + m_Application->GetLogger()->Fatal(string(err.GetDescription()) + "\n"); + return false; + } catch(std::exception& err) - { - std::ostringstream message; - message << "The following error occurred during application execution : " << err.what() << std::endl; - m_Application->GetLogger()->Write( itk::LoggerBase::FATAL, message.str() ); + { + m_Application->GetLogger()->Fatal(std::string("Caught std::exception during application execution: ") + err.what() + "\n"); return false; - } + } catch(...) - { - m_Application->GetLogger()->Write( itk::LoggerBase::FATAL, "An unknown exception has been raised during application execution" ); + { + m_Application->GetLogger()->Fatal("Caught unknown exception during application execution.\n"); return false; - } + } return true; } @@ -177,10 +195,10 @@ bool CommandLineLauncher::ExecuteAndWriteOutput() bool CommandLineLauncher::BeforeExecute() { if (m_Application.IsNull()) - { - std::cerr << "ERROR: No loaded application..." << std::endl; + { + std::cerr << "ERROR: No loaded application." << std::endl; return false; - } + } // Check if there's keys in the expression if the application takes // at least 1 mandatory parameter @@ -189,7 +207,8 @@ bool CommandLineLauncher::BeforeExecute() if( appKeyList.size()!=0 && keyList.size()==0 ) { - std::cerr << "ERROR: Waiting for at least one parameter..." << std::endl; + std::cerr << "ERROR: Waiting for at least one parameter." << std::endl; + std::cerr << std::endl; this->DisplayHelp(); return false; } @@ -237,64 +256,22 @@ bool CommandLineLauncher::BeforeExecute() std::string unknownKey; if (this->CheckKeyValidity(unknownKey) == false) { - std::cerr << "ERROR: option -"<<unknownKey<<" does not exist in the application." << std::endl; - this->DisplayHelp(); + std::cerr << "ERROR: Parameter -" << unknownKey <<" does not exist in the application." << std::endl; return false; } - try - { - if (this->LoadParameters() != OKPARAM) - { - std::cerr << "ERROR: Troubles loading parameter, please check your line argument..." << std::endl; - // Force to reload the application, the LoadParameters can change wrong values - this->LoadApplication(); - m_Application->Init(); - this->DisplayHelp(); - return false; - } - } - catch (itk::ExceptionObject& err) - { - std::cerr << "ERROR: Troubles in parameter setting, please check your line argument..." << std::endl; - std::cerr << err.GetDescription() << std::endl; - // Force to reload the application, the LoadParameters can change wrong values - this->LoadApplication(); - m_Application->Init(); - this->DisplayHelp(); + ParamResultType result = this->LoadParameters(); + if (result == MISSINGMANDATORYPARAMETER) + { + std::cerr << std::endl; + this->DisplayHelp(); return false; - } - - // Check for the progress report - if (m_Parser->IsAttributExists("-progress", m_VExpression) == true) - { - std::vector<std::string> val; - val = m_Parser->GetAttribut("-progress", m_VExpression); - if (val.size() != 1) - { - std::cerr << "ERROR: Invalid progress argument, must be unique value..." << std::endl; - return false; - } - if (val[0] == "1" || val[0] == "true") - { - m_ReportProgress = true; - } - else - if (val[0] == "0" || val[0] == "false") - { - m_ReportProgress = false; - } - else - { - std::cerr << "ERROR: Invalid progress argument, must be 0, 1, false or true..." << std::endl; - // Force to reload the application, the LoadParameters can change wrong values - this->LoadApplication(); - this->DisplayHelp(); - - return false; - } - } + } + else if (result != OKPARAM) + { + return false; + } return true; } @@ -319,15 +296,14 @@ bool CommandLineLauncher::LoadPath() return true; } -void CommandLineLauncher::LoadApplication() +bool CommandLineLauncher::LoadApplication() { // Look for the module name std::string moduleName; - //if (m_Parser->GetModuleName(moduleName, m_Expression) != CommandLineParser::OK) if (m_Parser->GetModuleName(moduleName, m_VExpression) != CommandLineParser::OK) { - std::cerr << "ERROR: LoadApplication, no module found..." << std::endl; - return; + std::cerr << "ERROR: Invalid module name: " << m_VExpression[0] << "." << std::endl; + return false; } // Instantiate the application using the factory @@ -342,26 +318,27 @@ void CommandLineLauncher::LoadApplication() std::vector<std::string> list = ApplicationRegistry::GetAvailableApplications(); if (list.size() == 0) { - std::cerr << "ERROR: Available modules : none." << std::endl; + std::cerr << "ERROR: Available modules: none." << std::endl; } else { - std::cerr << "ERROR: Available modules :" << std::endl; + std::cerr << "ERROR: Available modules:" << std::endl; for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it) { std::cerr << "\t" << *it << std::endl; } } + return false; } else { // Attach log output to the Application logger - m_Application->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE); m_Application->GetLogger()->AddLogOutput(m_LogOutput); // Add an observer to the AddedProcess event m_Application->AddObserver(AddProcessToWatchEvent(), m_AddProcessCommand.GetPointer()); + return true; } } @@ -386,6 +363,25 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() m_Application->UpdateParameters(); } + // Check for the progress report parameter + if (m_Parser->IsAttributExists("-progress", m_VExpression) == true) + { + std::vector<std::string> val = m_Parser->GetAttribut("-progress", m_VExpression); + if (val.size() == 1 && (val[0] == "1" || val[0] == "true")) + { + m_ReportProgress = true; + } + else if (val.size() == 1 && (val[0] == "0" || val[0] == "false")) + { + m_ReportProgress = false; + } + else + { + std::cerr << "ERROR: Invalid value for parameter -progress. It must be 0, 1, false or true." << std::endl; + return WRONGPARAMETERVALUE; + } + } + const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true); // Loop over each parameter key declared in the application // FIRST PASS : set parameter values @@ -412,8 +408,7 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() // Check if there is a value associated to the attribute if ( values.empty() ) { - std::cerr << "ERROR: No value associated to the parameter : \"" << paramKey - << "\", invalid number of values " << values.size() << std::endl; + std::cerr << "ERROR: No value associated to parameter -" << paramKey << "." << std::endl; return INVALIDNUMBEROFVALUE; } @@ -468,16 +463,16 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() else if (values[1] == "double") outPixType = ImagePixelType_double; else - { + { + std::cerr << "ERROR: Invalid output type for parameter -" << paramKey << ": " << values[1] << "." << std::endl; return WRONGPARAMETERVALUE; - } + } dynamic_cast<OutputImageParameter *> (param.GetPointer())->SetPixelType(outPixType); } else - if (values.size() != 1 && values.size() != 2) + if (values.size() > 2) { - std::cerr << "ERROR: Invalid number of value for: \"" << paramKey - << "\", invalid number of values " << values.size() << std::endl; + std::cerr << "ERROR: Too many values for parameter -" << paramKey << " (expected 2 or less, got " << values.size() << ")." << std::endl; return INVALIDNUMBEROFVALUE; } } @@ -493,9 +488,10 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() else if (values[1] == "cdouble") outPixType = ComplexImagePixelType_double; else - { + { + std::cerr << "ERROR: Invalid output type for parameter -" << paramKey << ": " << values[1] << "." << std::endl; return WRONGPARAMETERVALUE; - } + } dynamic_cast<ComplexOutputImageParameter *> (param.GetPointer())->SetComplexPixelType(outPixType); } else @@ -568,11 +564,11 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() { dynamic_cast<EmptyParameter *> (param.GetPointer())->SetActive(false); } - else - { - std::cerr << "ERROR: Wrong parameter value: " << paramKey << std::endl; - return WRONGPARAMETERVALUE; - } + else + { + std::cerr << "ERROR: Wrong value for parameter -" << paramKey << "." << std::endl; + return WRONGPARAMETERVALUE; + } } // Update the flag UserValue param->SetUserValue(true); @@ -633,27 +629,26 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() } if( mustBeSet ) - { + { if (!paramExists) - { + { // If key doesn't exist and parameter hasn't default value set... if (!hasValue) - { - std::cerr << "ERROR: Missing mandatory parameter: " << paramKey << " " << m_Application->HasValue(paramKey) - << std::endl; + { + std::cerr << "ERROR: Missing mandatory parameter -" << paramKey << "." << std::endl; return MISSINGMANDATORYPARAMETER; - } } + } else - { + { values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_VExpression); if (values.size() == 0 && !m_Application->HasValue(paramKey)) - { - std::cerr << "ERROR: Missing mandatory parameter: " << paramKey << std::endl; + { + std::cerr << "ERROR: Missing mandatory parameter -" << paramKey << "." << std::endl; return MISSINGPARAMETERVALUE; - } } } + } // Check if non mandatory parameter have values else { @@ -662,7 +657,7 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_VExpression); if (values.size() == 0) { - std::cerr << "ERROR: Missing non-mandatory parameter: " << paramKey << std::endl; + std::cerr << "ERROR: Missing non-mandatory parameter -" << paramKey << "." << std::endl; return MISSINGPARAMETERVALUE; } } diff --git a/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h b/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h index f9760192c4b240e2b16167fbd1355b646934c1ba..d7b42e3083116faed0e1d51627f39c48206114d6 100644 --- a/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h +++ b/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h @@ -81,8 +81,12 @@ public: void SetIOMode( IOMode ); IOMode GetIOMode() const; +signals: + void FilenameChanged(); + protected slots: void SelectFile(); + void CallFilenameChanged(); private: QtFileSelectionWidget(const QtFileSelectionWidget&); //purposely not implemented diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h index 8c2a578642ccd736d0ccc0354f2db96da64bd480..01684af9326ed3b20133ddedcce04d9f29f4c8ae 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h @@ -48,8 +48,11 @@ public: inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); +signals: + void FileNameIsSet(); + protected slots: - bool SetFileName( const QString& value ); + bool SetFileName(); void SelectFile(); private: diff --git a/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx b/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx index 818628ac6efec74c521db9adc15e6f9d4d10181e..37e4f3eed3ee02c97da7956d506f55d3c82ab98c 100644 --- a/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx +++ b/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx @@ -74,6 +74,7 @@ void QtFileSelectionWidget::DoCreateWidget() m_HLayout->addWidget(m_Checkbox); m_Input = new QLineEdit; + connect( m_Input, SIGNAL(editingFinished()), this, SLOT(CallFilenameChanged()) ); m_HLayout->addWidget(m_Input); // Set up input text edit @@ -116,8 +117,16 @@ QtFileSelectionWidget return; m_Input->setText( filename ); + + emit FilenameChanged(); } +void +QtFileSelectionWidget +::CallFilenameChanged() +{ + emit FilenameChanged(); +} } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx index 18e3a7aa9c80e6c46737d5c6563ba69c9c73098c..8224946af0c073f5707a8ee268c2e4dfde1ebefa 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx @@ -134,7 +134,7 @@ void QtWidgetInputImageListParameter::DoCreateWidget() fileSelection->setFixedHeight(30); fileLayout->addWidget(fileSelection); m_InputImageListParam->AddNullElement(); - connect(fileSelection->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateImageList())); + connect(fileSelection, SIGNAL(FilenameChanged()), this, SLOT(UpdateImageList())); m_FileSelectionList.push_back(fileSelection); @@ -160,16 +160,14 @@ void QtWidgetInputImageListParameter::DoCreateWidget() void QtWidgetInputImageListParameter::UpdateImageList() { - /* Adding a NullElement so to make the m_FileSelectionList and -* m_InputImageList's ImageList are of same size. So that GetImageList().Size() -* seems to be happy. - */ - for(unsigned int i = m_InputImageListParam->GetImageList()->Size(); i < m_FileSelectionList.size(); i++) + // Adding a NullElement so to make the m_FileSelectionList and + // m_InputImageList's ImageList are of same size. + for(unsigned int i = m_InputImageListParam->Size(); i < m_FileSelectionList.size(); i++) { m_InputImageListParam->AddNullElement(); } - for(unsigned int j = 0; j < m_InputImageListParam->GetImageList()->Size(); j++) + for(unsigned int j = 0; j < m_InputImageListParam->Size(); j++) { if(m_InputImageListParam->SetNthFileName(j, m_FileSelectionList[j]->GetFilename()) == false) { @@ -321,8 +319,8 @@ QtWidgetInputImageListParameter::AddFile() /* No need of AddNullElement() here. Moved adding NullElement when updating the list */ //m_InputImageListParam->AddNullElement(); connect( - fileSelection->GetInput(), - SIGNAL( textChanged( const QString & ) ), + fileSelection, + SIGNAL( FilenameChanged() ), this, SLOT( UpdateImageList() ) ); @@ -374,7 +372,7 @@ QtWidgetInputImageListParameter::EraseFile() m_FileLayout->addWidget(fileSelection); m_FileSelectionList.push_back(fileSelection); m_InputImageListParam->AddNullElement(); - connect(fileSelection->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateImageList())); + connect(fileSelection, SIGNAL(FilenameChanged()), this, SLOT(UpdateImageList())); QGroupBox *mainGroup = new QGroupBox(); mainGroup->setLayout(m_FileLayout); @@ -398,7 +396,7 @@ void QtWidgetInputImageListParameter::RecreateImageList() for(unsigned int j = 0; j < m_FileSelectionList.size(); j++) { m_InputImageListParam->AddFromFileName(m_FileSelectionList[j]->GetFilename()); - connect(m_FileSelectionList[j]->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateImageList())); + connect(m_FileSelectionList[j], SIGNAL(FilenameChanged()), this, SLOT(UpdateImageList())); } emit Change(); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx index 2f2b06519d1a69b0e0253d4f710bd2e9dad45660..2929d528a5515d1f4696b390e99e4ef46b0b0b20 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx @@ -69,8 +69,8 @@ void QtWidgetInputImageParameter::DoCreateWidget() m_HLayout->setContentsMargins(0, 0, 0, 0); m_Input = new QLineEdit; m_Input->setToolTip( m_InputImageParam->GetDescription() ); - connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) ); - connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) ); + connect( m_Input, SIGNAL(editingFinished()), this, SLOT(SetFileName()) ); + connect( this, SIGNAL(FileNameIsSet()), GetModel(), SLOT(NotifyUpdate()) ); m_HLayout->addWidget(m_Input); @@ -105,7 +105,9 @@ QtWidgetInputImageParameter if( filename.isEmpty() ) return; - if( !SetFileName( filename ) ) + m_Input->setText( filename ); + + if( !SetFileName() ) { std::ostringstream oss; @@ -119,21 +121,20 @@ QtWidgetInputImageParameter return; } - - m_Input->setText( filename ); } -bool QtWidgetInputImageParameter::SetFileName(const QString& value) +bool QtWidgetInputImageParameter::SetFileName() { bool res = true; // save value if( m_InputImageParam->SetFromFileName( - QFile::encodeName( value ).constData() ) == true ) + QFile::encodeName( m_Input->text() ).constData() ) == true ) { // notify of value change QString key( m_InputImageParam->GetKey() ); emit ParameterChanged(key); + emit FileNameIsSet(); } else res = false; diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx index 30f0da4573d846694fb636e403c7d2d6cc9226dc..1fa1e283efa1d6710096ba5c8dcb6512bf433da8 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx @@ -23,6 +23,8 @@ //Use to create command line from the application parameters #include "otbWrapperOutputProcessXMLParameter.h" +using std::string; + namespace otb { @@ -44,7 +46,6 @@ QtWidgetModel m_LogOutput = QtLogOutput::New(); // Attach log output to the Application logger - m_Application->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE); m_Application->GetLogger()->AddLogOutput(m_LogOutput); m_Timer = new QTimer(this); @@ -266,41 +267,44 @@ AppliThread { int result = -1; - // - // Try to execute OTB-application. try - { + { result = m_Application->ExecuteAndWriteOutput(); - } - // - // Catch standard exceptions. - catch( std::exception& err ) - { - std::ostringstream message; - - message - << "The following error occurred during OTB-application execution: " - << err.what() - << std::endl; - - m_Application->GetLogger()->Write( itk::LoggerBase::FATAL, message.str() ); - - // Signal exception. + } + catch(otb::ApplicationException& err) + { + // These are thrown with otbAppLogFATAL, a macro which logs a user + // friendly error message before throwing. So log exception details only + // in debug. + m_Application->GetLogger()->Debug("Caught otb::ApplicationException during application execution:\n"); + m_Application->GetLogger()->Debug(string(err.what()) + "\n"); emit ExceptionRaised( err.what() ); - } - // - // Catch other exceptions. - catch( ... ) - { - m_Application->GetLogger()->Write( - itk::LoggerBase::FATAL, - "An unknown exception has been raised during OTB-application execution" - ); + } + catch(otb::ImageFileReaderException& err) + { + m_Application->GetLogger()->Debug("Caught otb::ImageFileReaderException during application execution:\n"); + m_Application->GetLogger()->Debug(string(err.what()) + "\n"); + m_Application->GetLogger()->Fatal(string("Cannot open image ") + err.m_Filename + string(". ") + err.GetDescription() + string("\n")); + emit ExceptionRaised( err.what() ); + } + catch(itk::ExceptionObject& err) + { + m_Application->GetLogger()->Debug("Caught itk::ExceptionObject during application execution:\n"); + m_Application->GetLogger()->Debug(string(err.what()) + "\n"); + m_Application->GetLogger()->Fatal(string(err.GetDescription()) + "\n"); + emit ExceptionRaised( err.what() ); + } + catch(std::exception& err) + { + m_Application->GetLogger()->Fatal(string("Caught std::exception during application execution: ") + err.what() + "\n"); + emit ExceptionRaised( err.what() ); + } + catch(...) + { + m_Application->GetLogger()->Fatal("Caught unknown exception during application execution.\n"); + emit ExceptionRaised("Unknown exception."); + } - // Signal exception. - emit ExceptionRaised( "Exception raised by OTB-application." ); - } - // // Signal OTB-application has ended with result status. emit ApplicationExecutionDone( result ); } diff --git a/Modules/Wrappers/SWIG/src/itkBase.i b/Modules/Wrappers/SWIG/src/itkBase.i index b514c3ca5e511f171fc3992dae4d6ec6d2cfb7dc..2a15719f26f03106b4bb599ac0161931bb0636a7 100644 --- a/Modules/Wrappers/SWIG/src/itkBase.i +++ b/Modules/Wrappers/SWIG/src/itkBase.i @@ -29,6 +29,10 @@ %exception { try { $action + } catch(otb::ImageFileReaderException& err) { + std::ostringstream oss; + oss << "Cannot open image " << err.m_Filename + ". " + err.GetDescription(); + SWIG_exception( SWIG_RuntimeError, oss.str().c_str() ); } catch( itk::ExceptionObject &ex ) { std::ostringstream oss; oss << "Exception thrown in otbApplication $symname: " << ex.what(); diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 4f548c756caf7c113e21087bd31661186303b827..72adde8bd4d3181aee5c712ea41f0822ece49f39 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -576,7 +576,7 @@ class ApplicationProxy(object): if attr in key_list: return self.GetParameterValue(attr.lower()) else: - raise AttributeError + raise AttributeError("Parameter {} does not exist in the application.".format(attr.lower())) def __setattr__(self, attr, value): """ @@ -593,7 +593,7 @@ class ApplicationProxy(object): if attr in key_list: self.SetParameterValue(attr.lower(), value) else: - raise AttributeError + raise AttributeError("Parameter {} does not exist in the application.".format(attr.lower())) } } diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 59d424a3db71c35f66693fac370f71caeb196bd9..51d05f450e770d662bd8bc6ed3c82642777a3316 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -147,7 +147,7 @@ OTB-v.5.8.0 - Changes since version 5.6.1 (November 8th, 2016) * 0001300: monteverdi $input_filename crash with relative path * 0001303: Memory issue in Monteverdi with images with subdatasets (HDF4) * 0001299: Monteverdi shortcuts list needs some updates - * 0001291: Word "Échiquier" is not displayed properly in layer stack (effect column) + * 0001291: Word "Echiquier" is not displayed properly in layer stack (effect column) * OTB-Packaging * 0001290: Unable to run OTB applications from Mapla.app on Mac OS X @@ -1758,7 +1758,7 @@ OTB-v.3.12.0 - Changes since version 3.10.0 (2011/01/31) are missing) * Documentation - * 0000483: "<" or ">" are interpreted as ¿ in Cookbook + * 0000483: "<" or ">" are interpreted as inverted ? in Cookbook * 0000370: Cookbook : make a HTML documentation * 0000378: Doxygen not updated @@ -2251,10 +2251,10 @@ OTB-v.3.0.0 - Changes since version 2.8.0 (2009/05/11) -------------------------------------------------------- * Applications - - Urban area extraction (Pléaides, QB, Ikonos, SPOT5). For more + - Urban area extraction (Pleaides, QB, Ikonos, SPOT5). For more details, see the README file - - Image to Data Base registration (Pléiades, QB). For more details, see + - Image to Data Base registration (Pleiades, QB). For more details, see the README file - Feature Extraction: add new textures, new radiometric indexes and add MeanShift capabilities @@ -2262,7 +2262,7 @@ OTB-v.3.0.0 - Changes since version 2.8.0 (2009/05/11) * Library The library includes these additions - - Cloud detection for QB/Pléiades images + - Cloud detection for QB/Pleiades images - Alignment and right angle detection (Burns, Grompone) - Radiometric indices (vegetation, water, soil) - Optimized texture computations including Haralick, SFS, Pantex, diff --git a/SuperBuild/CMake/External_boost.cmake b/SuperBuild/CMake/External_boost.cmake index 8dc75b7a2d4a8e1943dfb19b78a3df7d22bd0851..baff81fc2a466ddd4d98c2d2c7af842de5d76bce 100644 --- a/SuperBuild/CMake/External_boost.cmake +++ b/SuperBuild/CMake/External_boost.cmake @@ -71,7 +71,7 @@ set(BOOST_BUILD_COMMAND ${CMAKE_COMMAND} #NOTE: update _SB_Boost_INCLUDE_DIR below when you change version number ExternalProject_Add(BOOST PREFIX BOOST - URL "http://download.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.bz2" + URL "http://downloads.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.bz2" URL_MD5 65a840e1a0b13a558ff19eeb2c4f0cbe BINARY_DIR ${BOOST_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} @@ -79,6 +79,7 @@ ExternalProject_Add(BOOST CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND} BUILD_COMMAND ${BOOST_BUILD_COMMAND} INSTALL_COMMAND "" + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 diff --git a/SuperBuild/CMake/External_curl.cmake b/SuperBuild/CMake/External_curl.cmake index fc6fe75d08b1005ea14b66e9e34df5f5398c4c0d..8728bdeb7e8a02c4af70125d157e3cd492862015 100644 --- a/SuperBuild/CMake/External_curl.cmake +++ b/SuperBuild/CMake/External_curl.cmake @@ -24,64 +24,41 @@ SETUP_SUPERBUILD(CURL) # declare dependencies ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(CURL ZLIB) - if(NOT APPLE) - ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OPENSSL) + ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(CURL OPENSSL) endif() -if(MSVC) - if(NOT BUILD_SHARED_LIBS) - message(FATAL_ERROR "static build or curl not supported") - return() - endif() - - if(OTB_TARGET_SYSTEM_ARCH_IS_X64) - set(CURL_INSTALL_DIR_PREFIX "libcurl-vc-x64") - else() - set(CURL_INSTALL_DIR_PREFIX "libcurl-vc-x86") - endif() - - set(CURL_INSTALL_DIR_PREFIX "${CURL_INSTALL_DIR_PREFIX}-release-dll-zlib-dll-ipv6-sspi-winssl") - - ExternalProject_Add(CURL +ExternalProject_Add(CURL PREFIX CURL URL "http://curl.haxx.se/download/curl-7.40.0.tar.gz" URL_MD5 58943642ea0ed050ab0431ea1caf3a6f - SOURCE_DIR ${CURL_SB_SRC} - BINARY_DIR ${CURL_SB_SRC}/winbuild + BINARY_DIR ${CURL_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} DOWNLOAD_DIR ${DOWNLOAD_LOCATION} + CMAKE_CACHE_ARGS + ${SB_CMAKE_CACHE_ARGS} + -DBUILD_CURL_TESTS:BOOL=OFF + -DBUILD_CURL_EXE:BOOL=ON + -DCMAKE_USE_OPENSSL:BOOL=OFF + -DCMAKE_USE_LIBSSH2:BOOL=OFF + -DCURL_DISABLE_LDAP:BOOL=ON + -DCMAKE_USE_OPENLDAP:BOOL=OFF + -DENABLE_MANUAL:BOOL=OFF + -DENABLE_IPV6:BOOL=OFF + ${CURL_SB_CONFIG} DEPENDS ${CURL_DEPENDENCIES} - CONFIGURE_COMMAND "" - BUILD_COMMAND nmake /f ${CURL_SB_SRC}/winbuild/Makefile.vc mode=dll WITH_ZLIB=dll WITH_DEVEL=${SB_INSTALL_PREFIX} - INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CURL_SB_SRC}/builds/${CURL_INSTALL_DIR_PREFIX}/ ${SB_INSTALL_PREFIX} + CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -else(UNIX) +SUPERBUILD_PATCH_SOURCE(CURL) - ExternalProject_Add(CURL - PREFIX CURL - URL "http://curl.haxx.se/download/curl-7.40.0.tar.gz" - URL_MD5 58943642ea0ed050ab0431ea1caf3a6f - BINARY_DIR ${CURL_SB_BUILD_DIR} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - CMAKE_CACHE_ARGS - ${SB_CMAKE_CACHE_ARGS} - -DBUILD_CURL_TESTS:BOOL=OFF - -DBUILD_CURL_EXE:BOOL=ON - -DCMAKE_USE_OPENSSL:BOOL=${SB_ENABLE_OPENSSL_CURL} - -DCMAKE_USE_LIBSSH2:BOOL=OFF - -DCURL_DISABLE_LDAP:BOOL=ON - -DCMAKE_USE_OPENLDAP:BOOL=OFF - ${CURL_SB_CONFIG} - DEPENDS ${CURL_DEPENDENCIES} - CMAKE_COMMAND ${SB_CMAKE_COMMAND} - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 - ) +set(_SB_CURL_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) +if(WIN32) + set(_SB_CURL_LIBRARY "${SB_INSTALL_PREFIX}/lib/libcurl_imp.lib") +elseif(UNIX) + set(_SB_CURL_LIBRARY ${SB_INSTALL_PREFIX}/lib/libcurl${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() - -SUPERBUILD_UPDATE_CMAKE_VARIABLES(CURL TRUE) diff --git a/SuperBuild/CMake/External_expat.cmake b/SuperBuild/CMake/External_expat.cmake index 2991992a9875afa5735d9a4478288065691c6e14..d59f4391faf8a06f7d8b84d786afef692244a44e 100644 --- a/SuperBuild/CMake/External_expat.cmake +++ b/SuperBuild/CMake/External_expat.cmake @@ -24,7 +24,7 @@ SETUP_SUPERBUILD(EXPAT) ExternalProject_Add(EXPAT PREFIX EXPAT - URL "http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz/download" + URL "http://downloads.sourceforge.net/project/expat/expat/2.1.0/expat-2.1.0.tar.gz" URL_MD5 dd7dab7a5fea97d2a6a43f511449b7cd BINARY_DIR ${EXPAT_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} @@ -35,6 +35,10 @@ ExternalProject_Add(EXPAT -DBUILD_tests:BOOL=OFF -DBUILD_tools:BOOL=OFF CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) SUPERBUILD_UPDATE_CMAKE_VARIABLES(EXPAT FALSE) diff --git a/SuperBuild/CMake/External_fftw.cmake b/SuperBuild/CMake/External_fftw.cmake index a6969ab7b225836c475f196d01de19c51383522c..ce1bdbea7f377f3402465e0d31867f46bb05922f 100644 --- a/SuperBuild/CMake/External_fftw.cmake +++ b/SuperBuild/CMake/External_fftw.cmake @@ -54,6 +54,7 @@ ExternalProject_Add(FFTWF --disable-fortran --disable-dependency-tracking DEPENDS ${FFTW_DEPENDENCIES} + LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) @@ -80,6 +81,8 @@ ExternalProject_Add(FFTWD --disable-fortran --disable-dependency-tracking DEPENDS FFTWF + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) diff --git a/SuperBuild/CMake/External_freetype.cmake b/SuperBuild/CMake/External_freetype.cmake index 014e35f0ccbc44730f248d9d3f26e9c4a8cb0c48..1af53391eb1546030311305916d1e902696222fa 100644 --- a/SuperBuild/CMake/External_freetype.cmake +++ b/SuperBuild/CMake/External_freetype.cmake @@ -39,6 +39,10 @@ ExternalProject_Add(FREETYPE ${SB_CMAKE_CACHE_ARGS} ${FREETYPE_SB_CONFIG} CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) set(_SB_FREETYPE_INCLUDE_DIRS ${SB_INSTALL_PREFIX}/include/freetype2) diff --git a/SuperBuild/CMake/External_gdal.cmake b/SuperBuild/CMake/External_gdal.cmake index aa87dc9f44e755b5e1824c90f9a2b01f682c4e45..fd7ed1836132c30fe132e67c14c3add1ca92f11e 100644 --- a/SuperBuild/CMake/External_gdal.cmake +++ b/SuperBuild/CMake/External_gdal.cmake @@ -65,7 +65,6 @@ if(UNIX) ${SB_CONFIGURE_ARGS} --with-cfitsio=no --with-dods-root=no - --with-dwgdirect=no --with-ecw=no --with-epsilon=no --with-fme=no @@ -100,6 +99,8 @@ if(UNIX) --with-xerces=no --with-xml2=no --with-pg=no + --with-webp=no + --with-threads=yes ${GDAL_SB_CONFIG} ${GDAL_SB_EXTRA_OPTIONS} ) @@ -107,8 +108,6 @@ if(UNIX) #set(GDAL_INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install) else(MSVC) - STRING(REGEX REPLACE "/$" "" CMAKE_WIN_INSTALL_PREFIX ${SB_INSTALL_PREFIX}) - STRING(REGEX REPLACE "/" "\\\\" CMAKE_WIN_INSTALL_PREFIX ${CMAKE_WIN_INSTALL_PREFIX}) configure_file( ${CMAKE_SOURCE_DIR}/patches/GDAL/nmake_gdal_extra.opt.in ${CMAKE_BINARY_DIR}/nmake_gdal_extra.opt) @@ -133,8 +132,8 @@ endif() ExternalProject_Add(GDAL PREFIX GDAL - URL "http://download.osgeo.org/gdal/2.1.0/gdal-2.1.0.tar.gz" - URL_MD5 0fc165cd947c54b132204233dfb243f1 + URL "http://download.osgeo.org/gdal/2.2.1/gdal-2.2.1.tar.gz" + URL_MD5 785acf2b0cbf9d56d37c9044d0ee2505 SOURCE_DIR ${GDAL_SB_SRC} BINARY_DIR ${GDAL_SB_SRC} INSTALL_DIR ${SB_INSTALL_PREFIX} @@ -143,6 +142,7 @@ ExternalProject_Add(GDAL CONFIGURE_COMMAND ${GDAL_CONFIGURE_COMMAND} BUILD_COMMAND ${GDAL_BUILD_COMMAND} INSTALL_COMMAND ${GDAL_INSTALL_COMMAND} + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 diff --git a/SuperBuild/CMake/External_geos.cmake b/SuperBuild/CMake/External_geos.cmake index f129a04379cd304f097e5425df52b29a0c73e913..921aa4d667cf4ba7f621cb8965ca47af08742c61 100644 --- a/SuperBuild/CMake/External_geos.cmake +++ b/SuperBuild/CMake/External_geos.cmake @@ -22,23 +22,10 @@ INCLUDE_ONCE_MACRO(GEOS) SETUP_SUPERBUILD(GEOS) -if(MSVC) - set(GEOS_PATCH_COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_SOURCE_DIR}/patches/GEOS/CMakeLists.txt - ${CMAKE_SOURCE_DIR}/patches/GEOS/nmake.opt - ${GEOS_SB_SRC}) - set(GEOS_CMAKE_COMMAND ${SB_CMAKE_COMMAND} -DGEOS_SB_SRC=${GEOS_SB_SRC}) - -else() - set(GEOS_PATCH_COMMAND) - set(GEOS_CMAKE_COMMAND ${SB_CMAKE_COMMAND}) - -endif() - ExternalProject_Add(GEOS PREFIX GEOS - URL "http://download.osgeo.org/geos/geos-3.5.0.tar.bz2" - URL_MD5 136842690be7f504fba46b3c539438dd + URL "http://download.osgeo.org/geos/geos-3.6.1.tar.bz2" + URL_MD5 c97e338b3bc81f9848656e9d693ca6cc SOURCE_DIR ${GEOS_SB_SRC} BINARY_DIR ${GEOS_SB_SRC} INSTALL_DIR ${SB_INSTALL_PREFIX} @@ -46,17 +33,23 @@ ExternalProject_Add(GEOS CMAKE_CACHE_ARGS ${SB_CMAKE_CACHE_ARGS} -DGEOS_ENABLE_TESTS:BOOL=OFF - PATCH_COMMAND ${GEOS_PATCH_COMMAND} + -DGEOS_ENABLE_MACOSX_FRAMEWORK:BOOL=OFF + -DGEOS_BUILD_STATIC:BOOL=${BUILD_STATIC_LIBS} + -DGEOS_BUILD_SHARED:BOOL=${BUILD_SHARED_LIBS} CMAKE_COMMAND ${GEOS_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -if(NOT MSVC) - SUPERBUILD_PATCH_SOURCE(GEOS) -endif() +# Patch still needed with version 3.6.1 to avoid error during CMake configuration +# See https://trac.osgeo.org/geos/ticket/753 +SUPERBUILD_PATCH_SOURCE(GEOS) set(_SB_GEOS_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) if(WIN32) - set(_SB_GEOS_LIBRARY ${SB_INSTALL_PREFIX}/lib/geos_i.lib ) + set(_SB_GEOS_LIBRARY ${SB_INSTALL_PREFIX}/lib/geos.lib ) elseif(UNIX) set(_SB_GEOS_LIBRARY ${SB_INSTALL_PREFIX}/lib/libgeos${CMAKE_SHARED_LIBRARY_SUFFIX}) -endif() \ No newline at end of file +endif() diff --git a/SuperBuild/CMake/External_geotiff.cmake b/SuperBuild/CMake/External_geotiff.cmake index 99babdd855a58186668364bbea4be881fb3ff479..3bb24a3202b39db9724a8261da78bf7fdfdf86fc 100644 --- a/SuperBuild/CMake/External_geotiff.cmake +++ b/SuperBuild/CMake/External_geotiff.cmake @@ -35,59 +35,28 @@ ADD_SUPERBUILD_CMAKE_VAR(GEOTIFF ZLIB_LIBRARY) ADD_SUPERBUILD_CMAKE_VAR(GEOTIFF JPEG_INCLUDE_DIR) ADD_SUPERBUILD_CMAKE_VAR(GEOTIFF JPEG_LIBRARY) -#RK: we are forced to use autoconf on osx due to cmake's find_* functions -#Do we need to use the same of Linux ? -if(UNIX) - set(GEOTIFF_SB_CONFIG) - ADD_SUPERBUILD_CONFIGURE_VAR(GEOTIFF PROJ_ROOT --with-proj) - ADD_SUPERBUILD_CONFIGURE_VAR(GEOTIFF TIFF_ROOT --with-libtiff) - ADD_SUPERBUILD_CONFIGURE_VAR(GEOTIFF JPEG_ROOT --with-jpeg) - ADD_SUPERBUILD_CONFIGURE_VAR(GEOTIFF ZLIB_ROOT --with-libz) +ExternalProject_Add(GEOTIFF + PREFIX GEOTIFF + URL "http://download.osgeo.org/geotiff/libgeotiff/libgeotiff-1.4.2.tar.gz" + URL_MD5 96ab80e0d4eff7820579957245d844f8 + SOURCE_DIR ${GEOTIFF_SB_SRC} + BINARY_DIR ${GEOTIFF_SB_BUILD_DIR} + INSTALL_DIR ${SB_INSTALL_PREFIX} + DOWNLOAD_DIR ${DOWNLOAD_LOCATION} + DEPENDS ${GEOTIFF_DEPENDENCIES} + CMAKE_CACHE_ARGS + ${SB_CMAKE_CACHE_ARGS} + -DBUILD_TESTING:BOOL=OFF + -DPROJ4_OSGEO4W_HOME:PATH=${SB_INSTALL_PREFIX} + ${GEOTIFF_SB_CONFIG} + CMAKE_COMMAND ${SB_CMAE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + ) - ExternalProject_Add(GEOTIFF - PREFIX GEOTIFF - URL "http://download.osgeo.org/geotiff/libgeotiff/libgeotiff-1.4.1.tar.gz" - URL_MD5 48bdf817e6e7a37671cc1f41b01e10fc - SOURCE_DIR ${GEOTIFF_SB_SRC} - BINARY_DIR ${GEOTIFF_SB_SRC} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - DEPENDS ${GEOTIFF_DEPENDENCIES} - CONFIGURE_COMMAND - ${SB_ENV_CONFIGURE_CMD} - ${GEOTIFF_SB_SRC}/configure - ${SB_CONFIGURE_ARGS} - ${GEOTIFF_SB_CONFIG} - LOG_BUILD 1 - LOG_INSTALL 1 - ) - - # [LOG_CONFIGURE 1] # Wrap configure in script to log output - # [LOG_BUILD 1] # Wrap build in script to log output - # [LOG_TEST 1] # Wrap test in script to log output - # [LOG_INSTALL 1] # Wrap install in script to log output - SUPERBUILD_PATCH_SOURCE(GEOTIFF) - -else() - - ExternalProject_Add(GEOTIFF - PREFIX GEOTIFF - URL "http://download.osgeo.org/geotiff/libgeotiff/libgeotiff-1.4.1.tar.gz" - URL_MD5 48bdf817e6e7a37671cc1f41b01e10fc - SOURCE_DIR ${GEOTIFF_SB_SRC} - BINARY_DIR ${GEOTIFF_SB_BUILD_DIR} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - DEPENDS ${GEOTIFF_DEPENDENCIES} - CMAKE_CACHE_ARGS - ${SB_CMAKE_CACHE_ARGS} - -DBUILD_TESTING:BOOL=OFF - -DPROJ4_OSGEO4W_HOME:PATH=${SB_INSTALL_PREFIX} - ${GEOTIFF_SB_CONFIG} - CMAKE_COMMAND ${SB_CMAKE_COMMAND} - ) - -endif() +SUPERBUILD_PATCH_SOURCE(GEOTIFF) set(_SB_GEOTIFF_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) if(WIN32) diff --git a/SuperBuild/CMake/External_glew.cmake b/SuperBuild/CMake/External_glew.cmake index 769ba0b808c3b8e83539e3dce0c3bb90501aad56..3f370e28e0642d584cfbdecfb881fa28d71a07e4 100644 --- a/SuperBuild/CMake/External_glew.cmake +++ b/SuperBuild/CMake/External_glew.cmake @@ -24,13 +24,17 @@ SETUP_SUPERBUILD(GLEW) ExternalProject_Add(GLEW PREFIX GLEW - URL "https://sourceforge.net/projects/glew/files/glew/1.13.0/glew-1.13.0.tgz/download" + URL "https://downloads.sourceforge.net/project/glew/glew/1.13.0/glew-1.13.0.tgz" URL_MD5 7cbada3166d2aadfc4169c4283701066 SOURCE_DIR ${GLEW_SB_SRC} BINARY_DIR ${GLEW_SB_BUILD_DIR} DOWNLOAD_DIR ${DOWNLOAD_LOCATION} INSTALL_DIR ${SB_INSTALL_PREFIX} CONFIGURE_COMMAND ${SB_CMAKE_COMMAND} ${SB_CMAKE_CACHE_ARGS} -DBUILD_UTILS:BOOL=OFF ${GLEW_SB_SRC}/build/cmake/ + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) SUPERBUILD_PATCH_SOURCE(GLEW) diff --git a/SuperBuild/CMake/External_glfw.cmake b/SuperBuild/CMake/External_glfw.cmake index ed7285bd7cfff094d8754c1feb65e8bf09e0b29b..62e2ee046d0dbd1f1b83c6adb2ef13a834d4a9e0 100644 --- a/SuperBuild/CMake/External_glfw.cmake +++ b/SuperBuild/CMake/External_glfw.cmake @@ -35,4 +35,10 @@ ExternalProject_Add(GLFW -DGLFW_BUILD_DOCS:BOOL=OFF -DGLFW_BUILD_TESTS:BOOL=OFF CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) + +SUPERBUILD_PATCH_SOURCE(GLFW) diff --git a/SuperBuild/CMake/External_glut.cmake b/SuperBuild/CMake/External_glut.cmake index 3299afd9b35d353890c6775ffffe88ccf198757a..8894a4931c3619b58bb01125b85494ecf2fbb37c 100644 --- a/SuperBuild/CMake/External_glut.cmake +++ b/SuperBuild/CMake/External_glut.cmake @@ -53,6 +53,10 @@ ExternalProject_Add(GLUT DOWNLOAD_DIR ${DOWNLOAD_LOCATION} PATCH_COMMAND ${GLUT_PATCH_COMMAND} CONFIGURE_COMMAND ${GLUT_CONFIGURE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) set(_SB_GLUT_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) diff --git a/SuperBuild/CMake/External_itk.cmake b/SuperBuild/CMake/External_itk.cmake index d46abbc7f9e55233b27047cca25a64244af3daa5..a96dc75196ce61766cb5e8ad9f491e83a163cb63 100644 --- a/SuperBuild/CMake/External_itk.cmake +++ b/SuperBuild/CMake/External_itk.cmake @@ -152,14 +152,14 @@ set(ITK_SB_COMPILATION_FLAGS #variables are later used in packaging set(SB_ITK_VERSION_MAJOR "4") -set(SB_ITK_VERSION_MINOR "10") +set(SB_ITK_VERSION_MINOR "12") set(_SB_ITK_DIR ${SB_INSTALL_PREFIX}/lib/cmake/ITK-${SB_ITK_VERSION_MAJOR}.${SB_ITK_VERSION_MINOR}) ExternalProject_Add(ITK PREFIX ITK - URL "http://downloads.sourceforge.net/project/itk/itk/4.10/InsightToolkit-4.10.0.tar.gz" - URL_MD5 8c67ba296da3835fb67bb29d98dcff3e + URL "https://sourceforge.net/projects/itk/files/itk/4.12/InsightToolkit-4.12.0.tar.gz" + URL_MD5 561a403f93c88c64085b5623e8e61f79 SOURCE_DIR ${ITK_SB_SRC} BINARY_DIR ${ITK_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} @@ -180,6 +180,10 @@ ExternalProject_Add(ITK ${ITK_SB_CONFIG} DEPENDS ${ITK_DEPENDENCIES} CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) SUPERBUILD_PATCH_SOURCE(ITK) diff --git a/SuperBuild/CMake/External_jpeg.cmake b/SuperBuild/CMake/External_jpeg.cmake index 0a4fca1b69d3debed537887ce4d71ecf7da60679..38e1460e508505e880d72656f47142ce118d3ee2 100644 --- a/SuperBuild/CMake/External_jpeg.cmake +++ b/SuperBuild/CMake/External_jpeg.cmake @@ -45,13 +45,17 @@ endif() ExternalProject_Add(JPEG PREFIX JPEG - URL "http://sourceforge.net/projects/libjpeg-turbo/files/1.4.1/libjpeg-turbo-1.4.1.tar.gz" + URL "http://downloads.sourceforge.net/project/libjpeg-turbo/1.4.1/libjpeg-turbo-1.4.1.tar.gz" URL_MD5 b1f6b84859a16b8ebdcda951fa07c3f2 SOURCE_DIR ${JPEG_SB_SRC} BINARY_DIR ${JPEG_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} DOWNLOAD_DIR ${DOWNLOAD_LOCATION} CONFIGURE_COMMAND ${JPEG_CONFIGURE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) SUPERBUILD_PATCH_SOURCE(JPEG) diff --git a/SuperBuild/CMake/External_libkml.cmake b/SuperBuild/CMake/External_libkml.cmake index 4d412687de14f6a74ef470cc02d0431713f6773b..e330ab05f7f5809a07ebf78dd7f0a980dde81522 100644 --- a/SuperBuild/CMake/External_libkml.cmake +++ b/SuperBuild/CMake/External_libkml.cmake @@ -44,7 +44,10 @@ ExternalProject_Add(LIBKML CMAKE_CACHE_ARGS ${SB_CMAKE_CACHE_ARGS} ${LIBKML_SB_CONFIG} CMAKE_COMMAND ${SB_CMAKE_COMMAND} - LOG_BUILD 1 + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) set(_SB_LIBKML_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) diff --git a/SuperBuild/CMake/External_libsvm.cmake b/SuperBuild/CMake/External_libsvm.cmake index 4a903c3e59c2d3bfe2ef7adc802051f34d19f33e..435c6d280c5faeb2bf5d2152cc3381c16a9f783b 100644 --- a/SuperBuild/CMake/External_libsvm.cmake +++ b/SuperBuild/CMake/External_libsvm.cmake @@ -35,6 +35,10 @@ ExternalProject_Add(LIBSVM PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/patches/LIBSVM/CMakeLists.txt ${LIBSVM_SB_SRC} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) set(_SB_LIBSVM_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) diff --git a/SuperBuild/CMake/External_muparser.cmake b/SuperBuild/CMake/External_muparser.cmake index 20bb3ca23b068de7b6fb6ca0af2b4f991a9ac19f..669cd29da28b2979529ca4b5da69608c66ac2aae 100644 --- a/SuperBuild/CMake/External_muparser.cmake +++ b/SuperBuild/CMake/External_muparser.cmake @@ -35,6 +35,10 @@ ExternalProject_Add(MUPARSER PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/patches/MUPARSER/CMakeLists.txt ${MUPARSER_SB_SRC} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -SUPERBUILD_UPDATE_CMAKE_VARIABLES(MUPARSER FALSE) \ No newline at end of file +SUPERBUILD_UPDATE_CMAKE_VARIABLES(MUPARSER FALSE) diff --git a/SuperBuild/CMake/External_muparserx.cmake b/SuperBuild/CMake/External_muparserx.cmake index a946a0da64a7e44fcc6f45e329015fa9272bf91d..e67b3974ad51cb504eb75cd31aa8f64153acde72 100644 --- a/SuperBuild/CMake/External_muparserx.cmake +++ b/SuperBuild/CMake/External_muparserx.cmake @@ -42,6 +42,10 @@ ExternalProject_Add(MUPARSERX ${MUPARSERX_FLAGS} CMAKE_COMMAND ${SB_CMAKE_COMMAND} DEPENDS ${MUPARSERX_DEPENDENCIES} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) #Patch mpParserMessageProvider.cpp. This patch is integrated upstream but not yet released (last release is 4.0.7) diff --git a/SuperBuild/CMake/External_mvd.cmake b/SuperBuild/CMake/External_mvd.cmake deleted file mode 100644 index b3bf91b18f2b96a49e94fc8d1186f6fe75ab3abe..0000000000000000000000000000000000000000 --- a/SuperBuild/CMake/External_mvd.cmake +++ /dev/null @@ -1,56 +0,0 @@ -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -if( __EXTERNAL_MVD__) - return() -else() - set(__EXTERNAL_MVD__ 1) -endif() - -SETUP_SUPERBUILD(MVD) - -set(MONTEVERDI_GIT_TAG "develop" CACHE STRING "branch name of monteverdi to build. Default is 'develop'") - -# declare dependencies -ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(MVD OTB QWT QT4) - -set(MVD_SB_CONFIG) -ADD_SUPERBUILD_CMAKE_VAR(MVD OTB_DIR) -ADD_SUPERBUILD_CMAKE_VAR(MVD QWT_INCLUDE_DIR) -ADD_SUPERBUILD_CMAKE_VAR(MVD QWT_LIBRARY) -ADD_SUPERBUILD_CMAKE_VAR(MVD QT_QMAKE_EXECUTABLE) - -#TODO: control build testing via cmake variable properly - -ExternalProject_Add(MVD - PREFIX MVD - GIT_REPOSITORY "https://git@git.orfeo-toolbox.org/git/monteverdi2.git" - GIT_TAG "${MONTEVERDI_GIT_TAG}" - SOURCE_DIR ${MVD_SB_SRC} - BINARY_DIR ${MVD_SB_BUILD_DIR} - INSTALL_DIR ${CMAKE_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - DEPENDS ${MVD_DEPENDENCIES} - CMAKE_CACHE_ARGS ${SB_CMAKE_CACHE_ARGS} - -DMonteverdi_INSTALL_LIB_DIR:STRING=lib - -DOTB_DATA_ROOT:STRING=${OTB_DATA_ROOT} - ${MVD_SB_CONFIG} - CMAKE_COMMAND ${SB_CMAKE_COMMAND} -) diff --git a/SuperBuild/CMake/External_opencv.cmake b/SuperBuild/CMake/External_opencv.cmake index 854d09de427b0a9c86456694c46f98b3ca55e8f4..675777f3e8ef080192d0bfdd6741b40ed8332237 100644 --- a/SuperBuild/CMake/External_opencv.cmake +++ b/SuperBuild/CMake/External_opencv.cmake @@ -100,6 +100,10 @@ ExternalProject_Add(OPENCV ${OPENCV_SB_CONFIG} DEPENDS ${OPENCV_DEPENDENCIES} CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) diff --git a/SuperBuild/CMake/External_openjpeg.cmake b/SuperBuild/CMake/External_openjpeg.cmake index cabb84509f4821470b7c09da4b8ce7cd52057ca4..09de9cb472905cfb0473061051b6447d217ec556 100644 --- a/SuperBuild/CMake/External_openjpeg.cmake +++ b/SuperBuild/CMake/External_openjpeg.cmake @@ -56,9 +56,13 @@ ExternalProject_Add(OPENJPEG ${OPENJPEG_SB_CONFIG} DEPENDS ${OPENJPEG_DEPENDENCIES} CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) SUPERBUILD_UPDATE_CMAKE_VARIABLES(OPENJPEG FALSE) -#Apply patches to openjpeg (for now Even Roualt optim) +#Apply patches to openjpeg (for now Even Rouault optimizations) SUPERBUILD_PATCH_SOURCE(OPENJPEG "-ut") diff --git a/SuperBuild/CMake/External_openssl.cmake b/SuperBuild/CMake/External_openssl.cmake index e398c44a89274d9ba61ea0adcdb424608f0d1cd3..7e20c05fb4fd4698ca683c638914d840de68ff64 100644 --- a/SuperBuild/CMake/External_openssl.cmake +++ b/SuperBuild/CMake/External_openssl.cmake @@ -25,32 +25,47 @@ SETUP_SUPERBUILD(OPENSSL) ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OPENSSL ZLIB) if(WIN32) + find_program(PERL_COMMAND NAMES perl perl.exe) + if(NOT PERL_COMMAND) + message(FATAL_ERROR "PERL_COMMAND not set. it is needed to configure openssl!") + return() + endif() + set(OPENSSL_BUILD_ARCH "linux-x32") set(OPENSSL_BUILD_ARCH "VC-WIN32") + set(OPENSSL_CONFIGURE_CMD "${OPENSSL_SB_SRC}/ms/do_ms.bat") if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(OPENSSL_BUILD_ARCH "linux-x86_64") set(OPENSSL_BUILD_ARCH "VC-WIN64A") + set(OPENSSL_CONFIGURE_CMD "${OPENSSL_SB_SRC}/ms/do_win64a.bat") endif() endif() if(MSVC) - STRING(REGEX REPLACE "/$" "" CMAKE_WIN_INSTALL_PREFIX ${SB_INSTALL_PREFIX}) - STRING(REGEX REPLACE "/" "\\\\" CMAKE_WIN_INSTALL_PREFIX ${CMAKE_WIN_INSTALL_PREFIX}) ExternalProject_Add(OPENSSL PREFIX OPENSSL URL "https://github.com/openssl/openssl/archive/OpenSSL_1_0_1p.tar.gz" URL_MD5 6bc1f9a9d9d474aceceb377e758e48ec DEPENDS ${OPENSSL_DEPENDENCIES} - BINARY_DIR ${OPENSSL_SB_BUILD_DIR} + BINARY_DIR ${OPENSSL_SB_SRC} INSTALL_DIR ${SB_INSTALL_PREFIX} DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - PATCH_COMMAND ${CMAKE_COMMAND} -E copy_directory ${OPENSSL_SB_SRC} ${OPENSSL_SB_BUILD_DIR} - CONFIGURE_COMMAND + PATCH_COMMAND ${SB_ENV_CONFIGURE_CMD} - ${CMAKE_COMMAND} -E chdir ${OPENSSL_SB_BUILD_DIR} - perl Configure ${OPENSSL_BUILD_ARCH} no-asm --prefix=${CMAKE_WIN_INSTALL_PREFIX} --openssldir=${CMAKE_WIN_INSTALL_PREFIX} - BUILD_COMMAND ms/do_ms.bat - INSTALL_COMMAND nmake -f ms/ntdll.mak install + ${PERL_COMMAND} ${OPENSSL_SB_SRC}/Configure + ${OPENSSL_BUILD_ARCH} + no-asm + "--prefix=${SB_INSTALL_PREFIX_NATIVE}" + "--openssldir=${SB_INSTALL_PREFIX_NATIVE}" + CONFIGURE_COMMAND + ${SB_ENV_CONFIGURE_CMD} + ${OPENSSL_CONFIGURE_CMD} + BUILD_COMMAND nmake -f "${OPENSSL_SB_SRC}/ms/ntdll.mak" + INSTALL_COMMAND nmake -f "${OPENSSL_SB_SRC}/ms/ntdll.mak" install + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) else(UNIX) @@ -59,16 +74,25 @@ else(UNIX) DEPENDS ${OPENSSL_DEPENDENCIES} URL "https://github.com/openssl/openssl/archive/OpenSSL_1_0_1p.tar.gz" URL_MD5 6bc1f9a9d9d474aceceb377e758e48ec - BINARY_DIR ${OPENSSL_SB_BUILD_DIR} + BINARY_DIR ${OPENSSL_SB_SRC} INSTALL_DIR ${SB_INSTALL_PREFIX} DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - PATCH_COMMAND ${CMAKE_COMMAND} -E copy_directory ${OPENSSL_SB_SRC} ${OPENSSL_SB_BUILD_DIR} CONFIGURE_COMMAND ${SB_ENV_CONFIGURE_CMD} - ${CMAKE_COMMAND} -E chdir ${OPENSSL_SB_BUILD_DIR} ./config ${OPENSSL_BUILD_ARCH} - --prefix=${SB_INSTALL_PREFIX} shared zlib zlib-dynamic -I${SB_INSTALL_PREFIX}/include -L${SB_INSTALL_PREFIX}/lib + ${OPENSSL_SB_SRC}/config ${OPENSSL_BUILD_ARCH} + "--prefix=${SB_INSTALL_PREFIX}" + shared + zlib + zlib-dynamic + "-I${SB_INSTALL_PREFIX}/include" + "-L${SB_INSTALL_PREFIX}/lib" BUILD_COMMAND $(MAKE) - INSTALL_COMMAND $(MAKE) install) + INSTALL_COMMAND $(MAKE) install + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + ) ExternalProject_Add_Step(OPENSSL remove_static COMMAND ${CMAKE_COMMAND} -E remove @@ -82,7 +106,7 @@ endif() set(_SB_OPENSSL_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) if(WIN32) - set(_SB_OPENSSL_LIBRARY ${SB_INSTALL_PREFIX}/lib/libcurl.lib) + set(_SB_OPENSSL_LIBRARY "${SB_INSTALL_PREFIX}/lib/ssleay32.lib;${SB_INSTALL_PREFIX}/lib/libeay32.lib") elseif(UNIX) set(_SB_OPENSSL_LIBRARY ${SB_INSTALL_PREFIX}/lib/libssl${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() diff --git a/SuperBuild/CMake/External_openthreads.cmake b/SuperBuild/CMake/External_openthreads.cmake index bf783fd625a753991e6311078a2c392ad5328ff4..43661aa81cbdc81d382f5cec078dca61c860f691 100644 --- a/SuperBuild/CMake/External_openthreads.cmake +++ b/SuperBuild/CMake/External_openthreads.cmake @@ -37,6 +37,10 @@ ExternalProject_Add(OPENTHREADS PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/patches/OPENTHREADS/CMakeLists.txt ${OPENTHREADS_SB_SRC} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) set(_SB_OPENTHREADS_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) diff --git a/SuperBuild/CMake/External_ossim.cmake b/SuperBuild/CMake/External_ossim.cmake index 8347a3cb854486d43b833a8105138e557f2c360d..04d89d5f3ba6c207b726d4c9cfc4351d06b275b3 100644 --- a/SuperBuild/CMake/External_ossim.cmake +++ b/SuperBuild/CMake/External_ossim.cmake @@ -67,6 +67,10 @@ ExternalProject_Add(OSSIM ${OSSIM_SB_CONFIG} DEPENDS ${OSSIM_DEPENDENCIES} CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) ExternalProject_Add_Step(OSSIM patch_no_cmakelists diff --git a/SuperBuild/CMake/External_pcre.cmake b/SuperBuild/CMake/External_pcre.cmake index 717f09f576d2fe2f638a154c33019bc8c300fdd8..aefa89e5b535315fef74cee9bff3ed2d0bbb18ba 100644 --- a/SuperBuild/CMake/External_pcre.cmake +++ b/SuperBuild/CMake/External_pcre.cmake @@ -25,7 +25,7 @@ if(MSVC) else() ExternalProject_Add(PCRE PREFIX PCRE - URL "http://sourceforge.net/projects/pcre/files/pcre/8.36/pcre-8.36.tar.gz/download" + URL "http://downloads.sourceforge.net/project/pcre/pcre/8.36/pcre-8.36.tar.gz" URL_MD5 ff7b4bb14e355f04885cf18ff4125c98 BINARY_DIR ${PCRE_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} diff --git a/SuperBuild/CMake/External_png.cmake b/SuperBuild/CMake/External_png.cmake index 1d2d16148dddfef8363f12a002785ca364d96b57..cd149a67b88e1741c912623d7f8f28957a228850 100644 --- a/SuperBuild/CMake/External_png.cmake +++ b/SuperBuild/CMake/External_png.cmake @@ -30,7 +30,7 @@ ADD_SUPERBUILD_CMAKE_VAR(PNG ZLIB_LIBRARY) ExternalProject_Add(PNG PREFIX PNG - URL "http://sourceforge.net/projects/libpng/files/libpng16/older-releases/1.6.16/lpng1616.zip/download" + URL "http://downloads.sourceforge.net/project/libpng/libpng16/older-releases/1.6.16/lpng1616.zip" URL_MD5 c90c9587c9a5c735327fb3f6900f6b03 BINARY_DIR ${PNG_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} @@ -48,6 +48,10 @@ ExternalProject_Add(PNG -DSKIP_INSTALL_EXECUTABLES:BOOL=OFF ${PNG_SB_CONFIG} CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) set(_SB_PNG_PNG_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) diff --git a/SuperBuild/CMake/External_proj.cmake b/SuperBuild/CMake/External_proj.cmake index 2949915c9fc42904d863752944473f78c3393494..a4fc838c7e44757776948edbda6dbeb2358fe40a 100644 --- a/SuperBuild/CMake/External_proj.cmake +++ b/SuperBuild/CMake/External_proj.cmake @@ -22,51 +22,32 @@ INCLUDE_ONCE_MACRO(PROJ) SETUP_SUPERBUILD(PROJ) -if(MSVC) - ExternalProject_Add(PROJ - PREFIX PROJ - URL "http://download.osgeo.org/proj/proj-4.8.0.tar.gz" - URL_MD5 d815838c92a29179298c126effbb1537 - SOURCE_DIR ${PROJ_SB_SRC} - BINARY_DIR ${PROJ_SB_SRC} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - CONFIGURE_COMMAND "" - BUILD_COMMAND nmake /f ${PROJ_SB_SRC}/makefile.vc - INSTALL_COMMAND nmake /f ${PROJ_SB_SRC}/makefile.vc install-all INSTDIR=${SB_INSTALL_PREFIX_NATIVE} - ) - -else() - - if(APPLE) - set(PROJ_SB_ENV_CONFIGURE_CMD ${SB_ENV_CONFIGURE_CMD} LDFLAGS=-headerpad_max_install_names) - else() - set(PROJ_SB_ENV_CONFIGURE_CMD ${SB_ENV_CONFIGURE_CMD}) - endif() - - ExternalProject_Add(PROJ - PREFIX PROJ - URL "http://download.osgeo.org/proj/proj-4.8.0.tar.gz" - URL_MD5 d815838c92a29179298c126effbb1537 - BINARY_DIR ${PROJ_SB_SRC} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - CONFIGURE_COMMAND - ${SB_ENV_CONFIGURE_CMD} - ${PROJ_SB_SRC}/configure - --prefix=${SB_INSTALL_PREFIX} - --enable-static=no - BUILD_COMMAND $(MAKE) - INSTALL_COMMAND $(MAKE) install - ) - -endif() +ExternalProject_Add(PROJ + PREFIX PROJ + URL "http://download.osgeo.org/proj/proj-4.9.3.tar.gz" + URL_MD5 d598336ca834742735137c5674b214a1 + BINARY_DIR ${PROJ_SB_SRC} + INSTALL_DIR ${SB_INSTALL_PREFIX} + DOWNLOAD_DIR ${DOWNLOAD_LOCATION} + CMAKE_CACHE_ARGS + ${SB_CMAKE_CACHE_ARGS} + -DBUILD_LIBPROJ_SHARED:BOOL=TRUE + -DVERSIONED_OUTPUT:BOOL=FALSE + -DBUILD_FRAMEWORKS_AND_BUNDLE:BOOL=FALSE + -DPROJ_LIB_SUBDIR:STRING=lib + -DPROJ_INCLUDE_SUBDIR:STRING=include + CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + ) SUPERBUILD_PATCH_SOURCE(PROJ) set(_SB_PROJ_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) if(WIN32) - set(_SB_PROJ_LIBRARY ${SB_INSTALL_PREFIX}/lib/proj_i.lib) + set(_SB_PROJ_LIBRARY ${SB_INSTALL_PREFIX}/lib/proj.lib) elseif(UNIX) set(_SB_PROJ_LIBRARY ${SB_INSTALL_PREFIX}/lib/libproj${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() diff --git a/SuperBuild/CMake/External_qt4.cmake b/SuperBuild/CMake/External_qt4.cmake index 8866464eba0bcdb6de152c762c2ae2a327cd247e..6d7c12cd52c00e83b0117ef97fd9814c7d20e193 100644 --- a/SuperBuild/CMake/External_qt4.cmake +++ b/SuperBuild/CMake/External_qt4.cmake @@ -40,7 +40,7 @@ endif() #NOTE: make sure your superbuild install directory does not contain any #Qt files from previous install of superbuild QT. # declare dependencies -ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(QT4 ZLIB PNG JPEG SQLITE FREETYPE) +ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(QT4 ZLIB PNG JPEG FREETYPE) #use system libs always for Qt4 as we build them from source or have already in system set(QT4_SB_CONFIG) @@ -55,10 +55,9 @@ if(UNIX) else() #Linux if(QT4_SB_ENABLE_GTK) message(WARNING "QT4_SB_ENABLE_GTK support is experimental") - set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -sm -xrender -xrandr -gtkstyle") else() - set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -no-gtkstyle") + set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -no-gtkstyle -no-glib -no-fontconfig") endif() endif() #common for all unix @@ -105,10 +104,12 @@ add_custom_target(QT4-uninstall COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtSvg" COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtTest" COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/QtXml" + COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/include/Qt" COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/mkspecs" COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/plugins" COMMAND ${CMAKE_COMMAND} -E remove_directory "${SB_INSTALL_PREFIX}/translations" COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/lib/libQt*" + COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/lib/pkgconfig/Qt*" COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/bin/qmake${QT4_BIN_EXT}" COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/bin/lrelease${QT4_BIN_EXT}" COMMAND ${CMAKE_COMMAND} -E remove -f "${SB_INSTALL_PREFIX}/bin/moc${QT4_BIN_EXT}" @@ -130,6 +131,7 @@ add_custom_target(QT4-uninstall DOWNLOAD_DIR ${DOWNLOAD_LOCATION} CONFIGURE_COMMAND ${QT4_CONFIGURE_COMMAND} DEPENDS ${QT4_DEPENDENCIES} + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 diff --git a/SuperBuild/CMake/External_qwt.cmake b/SuperBuild/CMake/External_qwt.cmake index b7c49bb46e25518ae261a006da3905c9a8746368..847d001b80bdc98c5a842e72acdaa0d7742c727f 100644 --- a/SuperBuild/CMake/External_qwt.cmake +++ b/SuperBuild/CMake/External_qwt.cmake @@ -45,7 +45,7 @@ endif() ExternalProject_Add(QWT PREFIX QWT - URL "http://sourceforge.net/projects/qwt/files/qwt/5.2.3/qwt-5.2.3.zip/download" + URL "http://downloads.sourceforge.net/project/qwt/qwt/5.2.3/qwt-5.2.3.zip" URL_MD5 310a1c8ab831f4b2219505dcb7691cf1 SOURCE_DIR ${QWT_SB_SRC} BINARY_DIR ${QWT_SB_BUILD_DIR} @@ -67,4 +67,4 @@ if(WIN32) set(_SB_QWT_LIBRARY ${SB_INSTALL_PREFIX}/lib/qwt5.lib) elseif(UNIX) set(_SB_QWT_LIBRARY ${SB_INSTALL_PREFIX}/lib/libqwt${CMAKE_SHARED_LIBRARY_SUFFIX}) -endif() \ No newline at end of file +endif() diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index f6a41acb569536fff64b9a3cedd68b18e37979dc..4fa164d29259d33037ad8c85ee6327ba6e8a0f85 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -46,6 +46,12 @@ ExternalProject_Add(SHARK -DENABLE_CBLAS:BOOL=OFF ${SHARK_SB_CONFIG} CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) +SUPERBUILD_PATCH_SOURCE(SHARK) + set(_SB_Shark_DIR ${SB_INSTALL_PREFIX}/lib/cmake/Shark) diff --git a/SuperBuild/CMake/External_sqlite.cmake b/SuperBuild/CMake/External_sqlite.cmake index 8a87e03d0e28bc4e89af98a3d21d9a50ce7bb80b..32d845fc3d434ae9b90b459500e55d854333a1d3 100644 --- a/SuperBuild/CMake/External_sqlite.cmake +++ b/SuperBuild/CMake/External_sqlite.cmake @@ -33,6 +33,10 @@ ExternalProject_Add(SQLITE PATCH_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/patches/SQLITE ${SQLITE_SB_SRC} CMAKE_CACHE_ARGS ${SB_CMAKE_CACHE_ARGS} CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) set(_SB_SQLITE_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) diff --git a/SuperBuild/CMake/External_swig.cmake b/SuperBuild/CMake/External_swig.cmake index 84c28823c7a64cc2ef82d2618ddfc5a153fe76d4..a21bac8410d123d711560da0ebffc5f0f50a58f8 100644 --- a/SuperBuild/CMake/External_swig.cmake +++ b/SuperBuild/CMake/External_swig.cmake @@ -43,7 +43,7 @@ if(MSVC) # Use pre-built swig executable (no linking is required, no install done) ExternalProject_Add(SWIG PREFIX SWIG - URL "http://sourceforge.net/projects/swig/files/swigwin/swigwin-3.0.7/swigwin-3.0.7.zip/download" + URL "http://downloads.sourceforge.net/project/swig/swigwin/swigwin-3.0.7/swigwin-3.0.7.zip" URL_MD5 d8b5a9ce49c819cc1bfc1e797b85ba7a INSTALL_DIR ${SB_INSTALL_PREFIX} DOWNLOAD_DIR ${DOWNLOAD_LOCATION} @@ -62,7 +62,7 @@ else() ExternalProject_Add(SWIG PREFIX SWIG - URL "http://sourceforge.net/projects/swig/files/swig/swig-3.0.7/swig-3.0.7.tar.gz/download" + URL "http://downloads.sourceforge.net/project/swig/swig/swig-3.0.7/swig-3.0.7.tar.gz" URL_MD5 7fff46c84b8c630ede5b0f0827e3d90a BINARY_DIR ${SWIG_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} @@ -76,6 +76,10 @@ else() BUILD_COMMAND $(MAKE) INSTALL_COMMAND $(MAKE) install DEPENDS ${SWIG_DEPENDENCIES} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) ExternalProject_Add_Step(SWIG copy_source diff --git a/SuperBuild/CMake/External_tiff.cmake b/SuperBuild/CMake/External_tiff.cmake index 296312b853baa1f2c8b98abff11e4a6e3c940d7f..d1d48880f29a7333d72e993f9abadf2c1e00d51c 100644 --- a/SuperBuild/CMake/External_tiff.cmake +++ b/SuperBuild/CMake/External_tiff.cmake @@ -25,77 +25,52 @@ SETUP_SUPERBUILD(TIFF) # declare dependencies ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(TIFF ZLIB JPEG) -ADD_SUPERBUILD_CMAKE_VAR(TIFF ZLIB_INCLUDE_DIR) -ADD_SUPERBUILD_CMAKE_VAR(TIFF ZLIB_LIBRARY) -ADD_SUPERBUILD_CMAKE_VAR(TIFF JPEG_INCLUDE_DIR) -ADD_SUPERBUILD_CMAKE_VAR(TIFF JPEG_LIBRARY) - if(MSVC) - STRING(REGEX REPLACE "/$" "" CMAKE_WIN_INSTALL_PREFIX ${SB_INSTALL_PREFIX}) - STRING(REGEX REPLACE "/" "\\\\" CMAKE_WIN_INSTALL_PREFIX ${CMAKE_WIN_INSTALL_PREFIX}) - configure_file(${CMAKE_SOURCE_DIR}/patches/TIFF/nmake.opt ${CMAKE_BINARY_DIR}/nmake_libtiff_extra.opt) - ExternalProject_Add(TIFF_build - PREFIX TIFF - URL "http://download.osgeo.org/libtiff/tiff-4.0.6.tar.gz" - URL_MD5 d1d2e940dea0b5ad435f21f03d96dd72 - SOURCE_DIR ${TIFF_SB_SRC} - BINARY_DIR ${TIFF_SB_SRC} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - DEPENDS ${TIFF_DEPENDENCIES} - PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/nmake_libtiff_extra.opt ${TIFF_SB_SRC}/nmake.opt - CONFIGURE_COMMAND "" - BUILD_COMMAND nmake /f ${TIFF_SB_SRC}/Makefile.vc - INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/patches/TIFF/CMakeLists.txt - ${CMAKE_BINARY_DIR}/TIFF/_install - ) - - ExternalProject_Add(TIFF - PREFIX TIFF/_install - DOWNLOAD_COMMAND "" - SOURCE_DIR TIFF/_install - BINARY_DIR ${TIFF_SB_BUILD_DIR} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - CMAKE_CACHE_ARGS - -DCMAKE_INSTALL_PREFIX:STRING=${SB_INSTALL_PREFIX} - -DCMAKE_BUILD_TYPE:STRING=Release - -DTIFF_BUILD_DIR:STRING=${TIFF_SB_SRC}/libtiff - DEPENDS TIFF_build - CMAKE_COMMAND - ) - -else() - ExternalProject_Add(TIFF - PREFIX TIFF - URL "http://download.osgeo.org/libtiff/tiff-4.0.6.tar.gz" - URL_MD5 d1d2e940dea0b5ad435f21f03d96dd72 - SOURCE_DIR ${TIFF_SB_SRC} - BINARY_DIR ${TIFF_SB_BUILD_DIR} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - DEPENDS ${TIFF_DEPENDENCIES} - CMAKE_CACHE_ARGS - ${SB_CMAKE_CACHE_ARGS} - -DCMAKE_INSTALL_LIBDIR:PATH=lib - -DCMAKE_INSTALL_BINDIR:PATH=bin - -DBUILD_TESTING:BOOL=OFF - -Djpeg:BOOL=TRUE - -Dlzma:BOOL=FALSE - -Djbig:BOOL=FALSE - -Dzlib:BOOL=TRUE - -DWITH_OPENGL:BOOL=FALSE - -Dpixarlog:BOOL=TRUE - ${TIFF_SB_CONFIG} - CMAKE_COMMAND ${SB_CMAKE_COMMAND} - ) + set(TIFF_C_FLAGS "/D_CRT_SECURE_NO_WARNINGS /DWIN32") endif() +ExternalProject_Add(TIFF + PREFIX TIFF + URL "http://download.osgeo.org/libtiff/tiff-4.0.8.tar.gz" + URL_MD5 2a7d1c1318416ddf36d5f6fa4600069b + SOURCE_DIR ${TIFF_SB_SRC} + BINARY_DIR ${TIFF_SB_BUILD_DIR} + INSTALL_DIR ${SB_INSTALL_PREFIX} + DOWNLOAD_DIR ${DOWNLOAD_LOCATION} + DEPENDS ${TIFF_DEPENDENCIES} + CMAKE_CACHE_ARGS + ${SB_CMAKE_CACHE_ARGS} + -DCMAKE_C_FLAGS:STRING=${TIFF_C_FLAGS} + -DCMAKE_INSTALL_LIBDIR:PATH=lib + -DCMAKE_INSTALL_BINDIR:PATH=bin + -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS:BOOL=TRUE + -DBUILD_TESTING:BOOL=FALSE + -Djpeg:BOOL=TRUE + -Dlzma:BOOL=FALSE + -Djbig:BOOL=FALSE + -Dzlib:BOOL=TRUE + -DWITH_OPENGL:BOOL=FALSE + -Dpixarlog:BOOL=TRUE + -Dcxx:BOOL=FALSE + -Dwith_opengl:BOOL=FALSE + -Dwith_tools:BOOL=FALSE + -Dwith_test:BOOL=FALSE + -Dwith_contrib:BOOL=FALSE + -Dwith_docs:BOOL=FALSE + ${TIFF_SB_CONFIG} + CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + ) + SUPERBUILD_PATCH_SOURCE(TIFF) +#do we really need these variables? set(_SB_TIFF_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) if(WIN32) - set(_SB_TIFF_LIBRARY ${SB_INSTALL_PREFIX}/lib/libtiff_i.lib) + set(_SB_TIFF_LIBRARY ${SB_INSTALL_PREFIX}/lib/tiff.lib) elseif(UNIX) set(_SB_TIFF_LIBRARY ${SB_INSTALL_PREFIX}/lib/libtiff${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() diff --git a/SuperBuild/CMake/External_tinyxml.cmake b/SuperBuild/CMake/External_tinyxml.cmake index d79b14ea6646d7c178dbcb20bf21c34e22a79f96..8952e1ea83147829c4cd3a1a491111ff9ccb0941 100644 --- a/SuperBuild/CMake/External_tinyxml.cmake +++ b/SuperBuild/CMake/External_tinyxml.cmake @@ -24,7 +24,7 @@ SETUP_SUPERBUILD(TINYXML) ExternalProject_Add(TINYXML PREFIX TINYXML - URL "http://sourceforge.net/projects/tinyxml/files/tinyxml/2.6.2/tinyxml_2_6_2.tar.gz/download" + URL "http://downloads.sourceforge.net/project/tinyxml/tinyxml/2.6.2/tinyxml_2_6_2.tar.gz" URL_MD5 c1b864c96804a10526540c664ade67f0 BINARY_DIR ${TINYXML_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} @@ -35,6 +35,10 @@ ExternalProject_Add(TINYXML ${TINYXML_SB_SRC} CMAKE_CACHE_ARGS ${SB_CMAKE_CACHE_ARGS} CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) SUPERBUILD_UPDATE_CMAKE_VARIABLES(TINYXML FALSE) diff --git a/SuperBuild/CMake/External_zlib.cmake b/SuperBuild/CMake/External_zlib.cmake index d19fe414172a5d15b5c9dcdacf12c7cfe708092c..6948e1f54244176e582864c1f958a139ea559402 100644 --- a/SuperBuild/CMake/External_zlib.cmake +++ b/SuperBuild/CMake/External_zlib.cmake @@ -26,21 +26,27 @@ SETUP_SUPERBUILD(ZLIB) # Try official release 1.2.8 ExternalProject_Add(ZLIB PREFIX ZLIB - URL "http://sourceforge.net/projects/libpng/files/zlib/1.2.8/zlib-1.2.8.tar.gz/download" + URL "http://downloads.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz" URL_MD5 44d667c142d7cda120332623eab69f40 BINARY_DIR ${ZLIB_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} DOWNLOAD_DIR ${DOWNLOAD_LOCATION} CMAKE_CACHE_ARGS ${SB_CMAKE_CACHE_ARGS} CMAKE_COMMAND ${SB_CMAKE_COMMAND} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) +#patch zlib cmake to disable static build on request if(UNIX) ExternalProject_Add_Step(ZLIB remove_static COMMAND ${CMAKE_COMMAND} -E remove ${SB_INSTALL_PREFIX}/lib/libz.a DEPENDEES install) endif() +#check who uses zdll.lib and remove this hack if(MSVC) ExternalProject_Add_Step(ZLIB msvc_copy_hell COMMAND ${CMAKE_COMMAND} -E copy ${ZLIB_SB_BUILD_DIR}/zlib.lib ${SB_INSTALL_PREFIX}/lib/zdll.lib diff --git a/SuperBuild/CMake/patch.cmake b/SuperBuild/CMake/patch.cmake index 651aec69583dd741b3130e5cfcae04df6bd5c1b4..db91ef224f2324afcde0c8f070644ae34ccd18f6 100644 --- a/SuperBuild/CMake/patch.cmake +++ b/SuperBuild/CMake/patch.cmake @@ -54,7 +54,8 @@ foreach(dot_diff_file ${DOT_DIFF_FILES}) endif() if(PATCHING_FAILED) - message(FATAL_ERROR "${PATCH_PROGRAM} returned non-zero exit status \n ${patch_ov} \n") + message(FATAL_ERROR + "${PATCH_PROGRAM} ${PATCH_ARGS} -p1 -i ${dot_diff_file} failed\n error: ${patch_ov} \n") else() message("${patch_ov}") endif() diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index 1275b0c197971e9f241a1f9203b6a6c069a78e76..6d47c1185ec61de953820d854367b956dfb3a960 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -18,7 +18,7 @@ # limitations under the License. # -cmake_minimum_required(VERSION 3.1.0) +cmake_minimum_required(VERSION 3.3.0) project(OTB-SuperBuild) @@ -42,6 +42,7 @@ include(ExternalProject) include(OTBCheckTargetSystemArch) option(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON) +option(BUILD_STATIC_LIBS "Build with static libraries." OFF) set(OTB_ADDITIONAL_CACHE "" CACHE STRING "Additional cmake option for OTB -DVAR:TYPE=VALUE ...") @@ -73,11 +74,11 @@ option(BUILD_TESTING "Build the testing tree." OFF) include(CTest) include(SuperBuild_Macro) -# Setup location where source tar-balls are downloaded -#set (install_location "${CMAKE_CURRENT_BINARY_DIR}/install") -set (DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/Downloads" - CACHE PATH "Location where source tar-balls are (to be) downloaded.") -mark_as_advanced(DOWNLOAD_LOCATION) +# Configure location where source tar-balls are downloaded +find_path(DOWNLOAD_LOCATION + NAMES OTBSuperBuild.readme + HINTS $ENV{DOWNLOAD_LOCATION} "${CMAKE_CURRENT_BINARY_DIR}/Downloads" + ) # General options option(OTB_DATA_USE_LARGEINPUT "Use Large inputs images test." OFF) @@ -145,15 +146,6 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() -if(MSVC) - set(BUILD_SHARED_LIBS OFF) - if(CMAKE_MAJOR_VERSION GREATER 2 AND CMAKE_MINOR_VERSION GREATER 2) - set(BUILD_SHARED_LIBS ON) - else() - message(WARNING "BUILD_SHARED_LIBS is set to OFF with CMake < 3.3") - endif() -endif() - if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /Ox /FC /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE") if(MSVC_VERSION GREATER 1310) @@ -249,6 +241,7 @@ option(USE_SYSTEM_GDAL "Use a system build of GDAL" OFF) option(USE_SYSTEM_FFTW "Use a system build of FFTW" OFF) option(USE_SYSTEM_ITK "Use a system build of ITK" OFF) option(USE_SYSTEM_OPENTHREADS "Use a system build of OpenThreads" OFF) +option(USE_SYSTEM_OSSIM "Use a system build of OSSIM" OFF) option(USE_SYSTEM_MUPARSER "Use a system build of muParser" OFF) option(USE_SYSTEM_MUPARSERX "Use a system build of muParserX" OFF) option(USE_SYSTEM_TINYXML "Use a system build of TinyXML" OFF) @@ -281,18 +274,19 @@ option(OTB_USE_MUPARSERX "Enable module muparserX in OTB" ON) option(OTB_USE_OPENCV "Enable module OpenCV in OTB" ON) option(OTB_USE_QT4 "Enable module QT4 in OTB" ON) option(OTB_USE_SIFTFAST "Enable module Siftfast in OTB" ON) -option(OTB_USE_OPENGL "Enable module OpenGL in OTB" OFF) -option(OTB_USE_GLEW "Enable module GLEW in OTB" OFF) -option(OTB_USE_GLFW "Enable module GLFW in OTB" OFF) -option(OTB_USE_GLUT "Enable module GLUT in OTB" OFF) -option(OTB_USE_SHARK "Enable module Shark in OTB" OFF) -option(OTB_USE_QWT "Enable module QWT in OTB" OFF) +option(OTB_USE_OPENGL "Enable module OpenGL in OTB" ON) +option(OTB_USE_GLEW "Enable module GLEW in OTB" ON) +option(OTB_USE_GLFW "Enable module GLFW in OTB" ON) -#Problem: below cmake setting will fail! -#-DOTB_USE_OPENGL=ON -DOTB_USE_GLEW=ON -DOTB_USE_QWT=ON -#This is because ENABLE_MONTEVERDI is OFF by default -# This brings a lot of twisted logic. so taking out this option +#Cannot activate GLUT on OSX. See manits issue #1194") +if(APPLE) + option(OTB_USE_GLUT "Enable module GLUT in OTB" OFF) +else() + option(OTB_USE_GLUT "Enable module GLUT in OTB" ON) +endif() +option(OTB_USE_SHARK "Enable module Shark in OTB" ON) +option(OTB_USE_QWT "Enable module QWT in OTB" ON) # set OTB_DATA_ROOT to run test find_path(OTB_DATA_ROOT README-OTB-Data PATHS $ENV{OTB_DATA_ROOT} ${OTB-SuperBuild_SOURCE_DIR}/../../OTB-Data) @@ -351,6 +345,12 @@ endif() message(STATUS "OTB_TARGET_SYSTEM_ARCH=${OTB_TARGET_SYSTEM_ARCH}") message(STATUS "OTB_TARGET_SYSTEM_ARCH_IS_X64=${OTB_TARGET_SYSTEM_ARCH_IS_X64}") +if(DOWNLOAD_LOCATION) + message(STATUS "DOWNLOAD_LOCATION=${DOWNLOAD_LOCATION}") + message(STATUS "Source archives for dependencies will be taken from '${DOWNLOAD_LOCATION}'") +else() + message(STATUS "DOWNLOAD_LOCATION is not set. We will download all source archives during build!") +endif() message(STATUS "SuperBuild will be installed to ${CMAKE_INSTALL_PREFIX}") message(STATUS "To install to a different directory, re-run cmake -DCMAKE_INSTALL_PREFIX=/your/preferred/path") diff --git a/SuperBuild/Packaging/PackageGlobals.cmake b/SuperBuild/Packaging/PackageGlobals.cmake index 9b94a74c1bade4cca2bbe6f69ea0e64a038e81dd..fdcfb3da3709c78e0b703ae99f296acced1aece7 100644 --- a/SuperBuild/Packaging/PackageGlobals.cmake +++ b/SuperBuild/Packaging/PackageGlobals.cmake @@ -91,6 +91,7 @@ set(LINUX_SYSTEM_DLLS libexpat.so.* libfontconfig.so* libfreetype.so* + libwebp.so* ) # libgcc_s.*dylib and other *.framework are dragged by QT diff --git a/SuperBuild/patches/CURL/curl-1-cmake-all.diff b/SuperBuild/patches/CURL/curl-1-cmake-all.diff new file mode 100755 index 0000000000000000000000000000000000000000..e2e0807143542ebb4a73c4fa5d6821cedaa6a4df --- /dev/null +++ b/SuperBuild/patches/CURL/curl-1-cmake-all.diff @@ -0,0 +1,67 @@ +diff -burN curl-7.40.0/CMake/CurlTests.c curl-7.40.0.orig/CMake/CurlTests.c +--- curl-7.40.0/CMake/CurlTests.c 2017-07-26 15:24:27.473903048 +0200 ++++ curl-7.40.0.orig/CMake/CurlTests.c 2017-07-26 15:22:05.268949035 +0200 +@@ -139,7 +139,7 @@ + rc = gethostbyname_r(address, &h, &hdata); + #elif defined(HAVE_GETHOSTBYNAME_R_5) || \ + defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) +- rc = gethostbyname_r(address, &h, buffer, 8192, 0, &h_errnop); ++ rc = gethostbyname_r(address, &h, buffer, 8192, &h_errnop); + (void)hp; /* not used for test */ + #elif defined(HAVE_GETHOSTBYNAME_R_6) || \ + defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT) +diff -burN curl-7.40.0.orig/CMake/OtherTests.cmake curl-7.40.0/CMake/OtherTests.cmake +--- curl-7.40.0.orig/CMake/OtherTests.cmake 2014-11-20 18:42:16.000000000 +0100 ++++ curl-7.40.0/CMake/OtherTests.cmake 2017-07-21 16:37:37.414343678 +0200 +@@ -10,6 +10,7 @@ + + set(signature_call_conv) + if(HAVE_WINDOWS_H) ++ set(_source_epilogue "${_source_epilogue}\n#define _WINSOCKAPI_") + add_header_include(HAVE_WINDOWS_H "windows.h") + add_header_include(HAVE_WINSOCK2_H "winsock2.h") + add_header_include(HAVE_WINSOCK_H "winsock.h") +@@ -163,7 +164,9 @@ + return 0; + }" HAVE_MSG_NOSIGNAL) + +-if(NOT HAVE_WINDOWS_H) ++if(HAVE_WINDOWS_H) ++add_header_include(HAVE_WINSOCK2_H "winsock2.h") ++else() + add_header_include(HAVE_SYS_TIME_H "sys/time.h") + add_header_include(TIME_WITH_SYS_TIME "time.h") + add_header_include(HAVE_TIME_H "time.h") +diff -burN curl-7.40.0.orig/src/CMakeLists.txt curl-7.40.0/src/CMakeLists.txt +--- curl-7.40.0.orig/src/CMakeLists.txt 2014-11-20 18:42:17.000000000 +0100 ++++ curl-7.40.0/src/CMakeLists.txt 2017-07-21 16:37:41.082367733 +0200 +@@ -25,14 +25,21 @@ + "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h" + VERBATIM) + else() +- add_custom_command( +- OUTPUT tool_hugehelp.c +- COMMAND echo "/* built-in manual is disabled, blank function */" > tool_hugehelp.c +- COMMAND echo "#include \"tool_hugehelp.h\"" >> tool_hugehelp.c +- COMMAND echo "void hugehelp(void) {}" >> tool_hugehelp.c +- DEPENDS +- "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h" +- VERBATIM) ++file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tool_hugehelp.c ++"/*built-in manual is disabled, blank function */\n" ++) ++file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/tool_hugehelp.c ++"#include \"tool_hugehelp.h\"\nvoid hugehelp(void) {}\n" ++) ++ ++ # add_custom_command( ++ # OUTPUT tool_hugehelp.c ++ # COMMAND echo "/* built-in manual is disabled, blank function */" > tool_hugehelp.c ++ # COMMAND echo "#include \"tool_hugehelp.h\"" >> tool_hugehelp.c ++ # COMMAND echo "void hugehelp(void) {}" >> tool_hugehelp.c ++ # DEPENDS ++ # "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h" ++ # VERBATIM) + endif() + + transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") diff --git a/SuperBuild/patches/GDAL/gdal-2-enviRotation-all.diff b/SuperBuild/patches/GDAL/gdal-2-enviRotation-all.diff new file mode 100644 index 0000000000000000000000000000000000000000..8c7f7acdce6b34c908a9a10580f2697157534658 --- /dev/null +++ b/SuperBuild/patches/GDAL/gdal-2-enviRotation-all.diff @@ -0,0 +1,32 @@ +diff -burN gdal-2.2.1-orig/frmts/raw/envidataset.cpp gdal-2.2.1/frmts/raw/envidataset.cpp +--- gdal-2.2.1-orig/frmts/raw/envidataset.cpp 2017-06-23 14:18:43.000000000 +0200 ++++ gdal-2.2.1/frmts/raw/envidataset.cpp 2017-07-20 18:25:05.373655046 +0200 +@@ -620,10 +620,13 @@ + adfGeoTransform[4] != 0.0 || adfGeoTransform[5] != 1.0; + if( bHasNonDefaultGT ) + { ++ const double dfDet = adfGeoTransform[1] * adfGeoTransform[5] - ++ adfGeoTransform[2] * adfGeoTransform[4]; ++ const double dfSign = (dfDet>0.0 ? 1.0 : -1.0); + const double dfRotation1 = +- -atan2(-adfGeoTransform[2], adfGeoTransform[1]) * kdfRadToDeg; ++ -atan2(dfSign * adfGeoTransform[2], adfGeoTransform[1]) * kdfRadToDeg; + const double dfRotation2 = +- -atan2(-adfGeoTransform[4], -adfGeoTransform[5]) * kdfRadToDeg; ++ -atan2(-adfGeoTransform[4], dfSign * adfGeoTransform[5]) * kdfRadToDeg; + const double dfRotation = (dfRotation1 + dfRotation2) / 2.0; + + if( fabs(dfRotation1 - dfRotation2) > 1e-5 ) +@@ -1534,7 +1537,12 @@ + + // Fallback to localcs if we don't recognise things. + if( oSRS.GetRoot() == NULL ) ++ { + oSRS.SetLocalCS(papszFields[0]); ++ // assume that the Y axis isn't flipped ++ adfGeoTransform[2] *= -1.0; ++ adfGeoTransform[5] *= -1.0; ++ } + + // Try to set datum from projection info line if we have a + // projected coordinate system without a GEOGCS. diff --git a/SuperBuild/patches/GDAL/nmake_gdal_extra.opt.in b/SuperBuild/patches/GDAL/nmake_gdal_extra.opt.in index 87f6bcd7b43280ad18f51db294000b68bcb1cbb8..72824d4104ed4ef7ae04e073ea4e264a9945be2d 100644 --- a/SuperBuild/patches/GDAL/nmake_gdal_extra.opt.in +++ b/SuperBuild/patches/GDAL/nmake_gdal_extra.opt.in @@ -11,60 +11,60 @@ JPEG_SUPPORTED = 1 # This will enable 12bit libjpeg - use only with internal jpeg builds. #JPEG12_SUPPORTED = 1 -GDAL_HOME="@CMAKE_WIN_INSTALL_PREFIX@" +GDAL_HOME="@SB_INSTALL_PREFIX_NATIVE@" #if using an external jpeg library uncomment the follwing lines JPEG_EXTERNAL_LIB = 1 -JPEGDIR = @CMAKE_WIN_INSTALL_PREFIX@\include -JPEG_LIB = @CMAKE_WIN_INSTALL_PREFIX@\lib\jpeg.lib +JPEGDIR = @SB_INSTALL_PREFIX_NATIVE@\include +JPEG_LIB = @SB_INSTALL_PREFIX_NATIVE@\lib\jpeg.lib #if using an external png library uncomment the follwing lines PNG_EXTERNAL_LIB = 1 -PNGDIR = @CMAKE_WIN_INSTALL_PREFIX@\include -PNG_LIB = @CMAKE_WIN_INSTALL_PREFIX@\lib\libpng.lib +PNGDIR = @SB_INSTALL_PREFIX_NATIVE@\include +PNG_LIB = @SB_INSTALL_PREFIX_NATIVE@\lib\libpng.lib # if using an external libtiff library -TIFF_INC = -I@CMAKE_WIN_INSTALL_PREFIX@\include -TIFF_LIB = @CMAKE_WIN_INSTALL_PREFIX@\lib\libtiff_i.lib +TIFF_INC = -I@SB_INSTALL_PREFIX_NATIVE@\include +TIFF_LIB = @SB_INSTALL_PREFIX_NATIVE@\lib\tiff.lib # uncomment following line, if you have libtiff version >= 4.0 to enable BigTIFF support TIFF_OPTS= -DBIGTIFF_SUPPORT # if using an external libgeotiff library -GEOTIFF_INC = -I@CMAKE_WIN_INSTALL_PREFIX@\include -GEOTIFF_LIB = @CMAKE_WIN_INSTALL_PREFIX@\lib\geotiff_i.lib +GEOTIFF_INC = -I@SB_INSTALL_PREFIX_NATIVE@\include +GEOTIFF_LIB = @SB_INSTALL_PREFIX_NATIVE@\lib\geotiff_i.lib -EXPAT_DIR = @CMAKE_WIN_INSTALL_PREFIX@ +EXPAT_DIR = @SB_INSTALL_PREFIX_NATIVE@ EXPAT_INCLUDE = -I$(EXPAT_DIR)\include EXPAT_LIB = $(EXPAT_DIR)\lib\expat.lib # SQLite Libraries -SQLITE_INC=-I@CMAKE_WIN_INSTALL_PREFIX@\include -SQLITE_LIB=@CMAKE_WIN_INSTALL_PREFIX@\lib\sqlite3.lib +SQLITE_INC=-I@SB_INSTALL_PREFIX_NATIVE@\include +SQLITE_LIB=@SB_INSTALL_PREFIX_NATIVE@\lib\sqlite3.lib # Uncomment following line if libsqlite3 has been compiled with SQLITE_HAS_COLUMN_METADATA=yes SQLITE_HAS_COLUMN_METADATA=yes # PROJ.4 stuff -PROJ_INCLUDE = -I@CMAKE_WIN_INSTALL_PREFIX@\include -PROJ_LIBRARY = @CMAKE_WIN_INSTALL_PREFIX@\lib\proj_i.lib +PROJ_INCLUDE = -I@SB_INSTALL_PREFIX_NATIVE@\include +PROJ_LIBRARY = @SB_INSTALL_PREFIX_NATIVE@\lib\proj.lib # Uncomment to use libcurl (DLL by default) # The cURL library is used for WCS, WMS, GeoJSON, SRS call importFromUrl(), WFS, GFT, CouchDB, /vsicurl/ etc. -CURL_DIR=@CMAKE_WIN_INSTALL_PREFIX@ +CURL_DIR=@SB_INSTALL_PREFIX_NATIVE@ CURL_INC = -I$(CURL_DIR)\include # Uncoment following line to use libcurl as dynamic library -CURL_LIB = $(CURL_DIR)\lib\libcurl.lib wsock32.lib wldap32.lib winmm.lib +CURL_LIB = $(CURL_DIR)\lib\libcurl_imp.lib wsock32.lib wldap32.lib winmm.lib # Uncomment for GEOS support (GEOS >= 3.1.0 required) -GEOS_DIR=@CMAKE_WIN_INSTALL_PREFIX@ +GEOS_DIR=@SB_INSTALL_PREFIX_NATIVE@ GEOS_CFLAGS = -I$(GEOS_DIR)\include -I$(GEOS_DIR)\include\geos -DHAVE_GEOS -GEOS_LIB = $(GEOS_DIR)\lib\geos_i.lib $(GEOS_DIR)\lib\geos_c_i.lib +GEOS_LIB = $(GEOS_DIR)\lib\geos.lib $(GEOS_DIR)\lib\geos_c.lib # Uncomment for OpenJpeg support HAVE_OPENJPEG = YES OPENJPEG_ENABLED = YES OPENJPEG_VERSION = 20100 -OPENJPEG_CFLAGS = -I@CMAKE_WIN_INSTALL_PREFIX@\include -OPENJPEG_LIB = @CMAKE_WIN_INSTALL_PREFIX@\lib\openjp2.lib +OPENJPEG_CFLAGS = -I@SB_INSTALL_PREFIX_NATIVE@\include +OPENJPEG_LIB = @SB_INSTALL_PREFIX_NATIVE@\lib\openjp2.lib ################################################################## @@ -86,6 +86,10 @@ OPENJPEG_LIB = @CMAKE_WIN_INSTALL_PREFIX@\lib\openjp2.lib # $(LIBKML_DIR)/third_party\zlib-1.2.3.win32/lib/minizip.lib \ # $(LIBKML_DIR)/third_party\zlib-1.2.3.win32/lib/zlib.lib +#we use external zlib on windows +ZLIB_EXTERNAL_LIB = 1 +ZLIB_INC = -I@SB_INSTALL_PREFIX_NATIVE@\include +ZLIB_LIB = @SB_INSTALL_PREFIX_NATIVE@\lib\zlib.lib # Uncomment the following and update to enable NCSA HDF Release 4 support. #HDF4_PLUGIN = NO diff --git a/SuperBuild/patches/GEOS/CMakeLists.txt b/SuperBuild/patches/GEOS/CMakeLists.txt deleted file mode 100644 index a89103afaecae9441d1095ccab4d97bb094148eb..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/GEOS/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -cmake_minimum_required(VERSION 2.8) - -project(GEOS_SUPERBUILD) - -add_custom_target(build_with_nmake -ALL DEPENDS -COMMAND -nmake /f ${GEOS_SB_SRC}/makefile.vc -WORKING_DIRECTORY ${GEOS_SB_SRC} -) - -install(FILES ${GEOS_SB_SRC}/capi/geos_c.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include) -install(FILES ${GEOS_SB_SRC}/include/geos.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include) -install(DIRECTORY ${GEOS_SB_SRC}/include/geos DESTINATION ${CMAKE_INSTALL_PREFIX}/include) -install(FILES ${GEOS_SB_SRC}/src/geos.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) -install(FILES ${GEOS_SB_SRC}/src/geos_c.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) -install(FILES ${GEOS_SB_SRC}/src/geos.lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) -install(FILES ${GEOS_SB_SRC}/src/geos_i.lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) -install(FILES ${GEOS_SB_SRC}/src/geos_c_i.lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) diff --git a/SuperBuild/patches/GEOS/geos-1-fixes-all.diff b/SuperBuild/patches/GEOS/geos-1-fixes-all.diff index 4a516fe4697128ff5f81bbecc25568e62a46bceb..ca7663fffbf52a566124f57daf25d52e378d2da9 100644 --- a/SuperBuild/patches/GEOS/geos-1-fixes-all.diff +++ b/SuperBuild/patches/GEOS/geos-1-fixes-all.diff @@ -1,93 +1,22 @@ -diff -burN geos-3.5.0.orig/CMakeLists.txt geos-3.5.0/CMakeLists.txt ---- geos-3.5.0.orig/CMakeLists.txt 2016-09-02 11:02:28.833742143 +0200 -+++ geos-3.5.0/CMakeLists.txt 2016-09-02 11:05:05.897748116 +0200 -@@ -55,6 +55,9 @@ - # Check custom global options - ################################################################################# - -+option(GEOS_BUILD_STATIC -+ "Set to OFF|ON (default) to control build of GEOS tests package" OFF) -+ - option(GEOS_ENABLE_TESTS - "Set to OFF|ON (default) to control build of GEOS tests package" ON) - -@@ -317,18 +320,18 @@ - - # Define "make check" as alias for "make test" - add_custom_target(check COMMAND ctest) -- -+add_subdirectory(tests) - endif() - - ################################################################################# - # Configure subdirectories - ################################################################################# --include(GenerateSourceGroups) -+#include(GenerateSourceGroups) - - add_subdirectory(include) - add_subdirectory(src) - add_subdirectory(capi) --add_subdirectory(tests) -+ - add_subdirectory(tools) - - ################################################################################# -diff -burN geos-3.5.0.orig/include/CMakeLists.txt geos-3.5.0/include/CMakeLists.txt ---- geos-3.5.0.orig/include/CMakeLists.txt 2016-09-02 11:02:28.837742143 +0200 -+++ geos-3.5.0/include/CMakeLists.txt 2016-09-02 11:03:03.581743464 +0200 -@@ -54,4 +54,4 @@ - ################################################################################# - # Group source files for IDE source explorers (e.g. Visual Studio) - ################################################################################# --GenerateSourceGroups(include) -+#GenerateSourceGroups(include) -diff -burN geos-3.5.0.orig/src/CMakeLists.txt geos-3.5.0/src/CMakeLists.txt ---- geos-3.5.0.orig/src/CMakeLists.txt 2016-09-02 11:02:28.869742144 +0200 -+++ geos-3.5.0/src/CMakeLists.txt 2016-09-02 11:05:14.621748447 +0200 -@@ -62,7 +62,18 @@ - else() - - add_library(geos SHARED ${geos_SOURCES} ${geos_ALL_HEADERS}) -+ if(GEOS_BUILD_STATIC) - add_library(geos-static STATIC ${geos_SOURCES} ${geos_ALL_HEADERS}) -+ set_target_properties(geos-static -+ PROPERTIES -+ OUTPUT_NAME "geos" -+ PREFIX "lib" -+ CLEAN_DIRECT_OUTPUT 1) -+ install(TARGETS geos geos-static -+ RUNTIME DESTINATION bin -+ LIBRARY DESTINATION lib -+ ARCHIVE DESTINATION lib) -+endif() - - set_target_properties(geos - PROPERTIES -@@ -70,11 +81,6 @@ - VERSION ${VERSION} - CLEAN_DIRECT_OUTPUT 1) - -- set_target_properties(geos-static -- PROPERTIES -- OUTPUT_NAME "geos" -- PREFIX "lib" -- CLEAN_DIRECT_OUTPUT 1) - - endif() - -@@ -90,7 +96,7 @@ - ################################################################################# - - if(NOT GEOS_ENABLE_MACOSX_FRAMEWORK) -- install(TARGETS geos geos-static -+ install(TARGETS geos - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) -@@ -99,4 +105,4 @@ - ################################################################################# - # Group source files for IDE source explorers (e.g. Visual Studio) - ################################################################################# --GenerateSourceGroups(src) -+#GenerateSourceGroups(src) +diff -burN geos-3.6.1.orig/cmake/modules/GenerateSourceGroups.cmake geos-3.6.1/cmake/modules/GenerateSourceGroups.cmake +--- geos-3.6.1.orig/cmake/modules/GenerateSourceGroups.cmake 1970-01-01 01:00:00.000000000 +0100 ++++ geos-3.6.1/cmake/modules/GenerateSourceGroups.cmake 2017-06-19 11:19:32.143054641 +0200 +@@ -0,0 +1,17 @@ ++# ++# Macro generates tree of IDE source groups based on folders structure ++# Source: http://www.cmake.org/pipermail/cmake/2013-November/056332.html ++# ++macro(GenerateSourceGroups curdir) ++ file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*) ++ foreach(child ${children}) ++ if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child}) ++ GenerateSourceGroups(${curdir}/${child}) ++ else() ++ string(REPLACE "/" "\\" groupname ${curdir}) ++ # I would like to call the src root folder in a different name, only in visual studio (not mandatory requirement) ++ string(REPLACE "src" "Source Files" groupname ${groupname}) ++ source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child}) ++ endif() ++ endforeach() ++endmacro() +\ Pas de fin de ligne à la fin du fichier diff --git a/SuperBuild/patches/GEOS/nmake.opt b/SuperBuild/patches/GEOS/nmake.opt deleted file mode 100644 index ca21bd252387c8b166343bc966871399a2b36abd..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/GEOS/nmake.opt +++ /dev/null @@ -1,250 +0,0 @@ -# -# nmake.opt - main configuration file for NMAKE makefiles -# -!MESSAGE ********************************************************************** -!MESSAGE *** GEOS Build Configuration *** - -# TODO: Confirm as redundant and remove, nmake /P displays _NMAKE_VER anyway. -#!INCLUDE <ntwin32.mak> - -############################################################################### -# For convenience, user may put custom settings to private mynmake.opt -# and use EXT_NMAKE_OPT option while calling nmake.exe, as follows: -# -# nmake -f makefile.vc EXT_NMAKE_OPT=mynmake.opt - -!IFDEF EXT_NMAKE_OPT -!MESSAGE *** Setting EXT_NMAKE_OPT $(EXT_NMAKE_OPT) -!INCLUDE $(EXT_NMAKE_OPT) -!ENDIF - -############################################################################### -# Set BUILD_DEBUG to YES if you want to make debug build -# and to prepare not optimized binaries. - -!IFNDEF BUILD_DEBUG -BUILD_DEBUG = NO -!ENDIF - -!MESSAGE *** Setting BUILD_DEBUG $(BUILD_DEBUG) - -############################################################################### -# Set ENABLE_INLINE to YES if you want to make debug build -# and to prepare not optimized binaries. - -!IFNDEF ENABLE_INLINE -ENABLE_INLINE = NO -!ENDIF - -!MESSAGE *** Setting ENABLE_INLINE $(ENABLE_INLINE) - -############################################################################### -# Set BUILD_BATCH to YES if you want feed compiler with all -# source .c and .cpp files in single batch. - -!IFNDEF BUILD_BATCH -BUILD_BATCH = NO -!ENDIF - -!MESSAGE *** Setting BUILD_BATCH $(BUILD_BATCH) - -############################################################################### -# Set WIN64=YES if you are building for 64-bit windows (x64). -# Alternatively, pass WIN64=YES as NMAKE command line argument. -############################################################################### -!IFNDEF WIN64 -WIN64 = NO -!ENDIF - -!MESSAGE *** Setting WIN64 $(WIN64) - -############################################################################### -# Derive version of Visual C++ being used from NMAKE if not specified -# -# WARNING: -# If we should expect variety of NMAKE build versions, tests below may fail -# and we will need to fall back to setting GEOS_MSVC as command line parameter. - -!IF "$(_NMAKE_VER)" == "" -GEOS_MSVC = 4.0 -!ERROR *** Failed to determine version of Visual C++ -!ELSEIF "$(_NMAKE_VER)" == "162" -GEOS_MSVC = 5.0 -!ERROR *** Detected Visual C++ 5.0 - NOT SUPPORTED -!ELSEIF "$(_NMAKE_VER)" == "6.00.8168.0" -GEOS_MSVC = 6.0 -GEOS_MSC = 1200 -!ERROR *** Detected Visual C++ 6.0 - NOT SUPPORTED -!ELSEIF "$(_NMAKE_VER)" == "7.00.9466" -GEOS_MSVC = 7.0 -GEOS_MSC = 1300 -!ELSEIF "$(_NMAKE_VER)" == "7.10.3077" -GEOS_MSVC = 7.1 -GEOS_MSC = 1310 -!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.42" -GEOS_MSVC = 8.0 -GEOS_MSC = 1400 -!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.762" -GEOS_MSVC = 8.0 -GEOS_MSC = 1400 -!ELSEIF "$(_NMAKE_VER)" == "9.00.21022.08" -GEOS_MSVC = 9.0 -GEOS_MSC = 1500 -!ELSEIF "$(_NMAKE_VER)" == "9.00.30729.01" -GEOS_MSVC = 9.0 -GEOS_MSC = 1500 -!ELSEIF "$(_NMAKE_VER)" == "10.00.30128.01" -GEOS_MSVC = 10.0 -GEOS_MSC = 1600 -!ELSEIF "$(_NMAKE_VER)" == "10.00.30319.01" -GEOS_MSVC = 10.0 -GEOS_MSC = 1600 -!ELSEIF "$(_NMAKE_VER)" == "11.00.40825.2" -GEOS_MSVC = 11.0 -GEOS_MSC = 1700 -!ELSEIF "$(_NMAKE_VER)" == "11.00.50522.1" -GEOS_MSVC = 11.0 -GEOS_MSC = 1700 -!ELSEIF "$(_NMAKE_VER)" == "11.00.50727.1" -GEOS_MSVC = 11.0 -GEOS_MSC = 1700 -!ELSEIF "$(_NMAKE_VER)" == "11.00.51106.1" -GEOS_MSVC = 11.0 -GEOS_MSC = 1700 -!ELSEIF "$(_NMAKE_VER)" == "11.00.60315.1" -GEOS_MSVC = 11.0 -GEOS_MSC = 1700 -!ELSEIF "$(_NMAKE_VER)" == "11.00.60430.2" -GEOS_MSVC = 11.0 -GEOS_MSC = 1700 -!ELSEIF "$(_NMAKE_VER)" == "11.00.60521.0" -GEOS_MSVC = 11.0 -GEOS_MSC = 1700 -!ELSEIF "$(_NMAKE_VER)" == "11.00.60610.1" -GEOS_MSVC = 11.0 -GEOS_MSC = 1700 -!ELSEIF "$(_NMAKE_VER)" == "11.00.61030.0" -GEOS_MSVC = 11.0 -GEOS_MSC = 1700 -!ELSEIF "$(_NMAKE_VER)" == "12.00.21005.1" -GEOS_MSVC = 12.0 -GEOS_MSC = 1800 -!ELSEIF "$(_NMAKE_VER)" == "14.00.22816.0" -GEOS_MSVC = 14.0 -GEOS_MSC = 1900 -!ELSEIF "$(_NMAKE_VER)" == "14.00.23026.0" -GEOS_MSVC = 14.0 -GEOS_MSC = 1900 -!ELSEIF "$(_NMAKE_VER)" == "14.00.23918.0" -GEOS_MSVC = 14.0 -GEOS_MSC = 1900 -!ELSEIF "$(_NMAKE_VER)" == "14.00.24210.0" -GEOS_MSVC = 14.0 -GEOS_MSC = 1900 -!ELSE -GEOS_MSVC = 0.0 -GEOS_MSC = 0 -!ENDIF - -!IF "$(GEOS_MSVC)" == "0.0" && "$(GEOS_MSC)" == "0" -!MESSAGE *** Cannot determine Visual C++ version -!ERROR *** Aborting make job -!ELSE -!MESSAGE *** Using Microsoft NMAKE version $(_NMAKE_VER) -!MESSAGE *** Using Microsoft Visual C++ version $(GEOS_MSVC) -!MESSAGE *** Using Microsoft C/C++ version $(GEOS_MSC) -!ENDIF - -############################################################################### -# Optional use of Visual Leak Detector (VLD) http://vld.codeplex.com/ -# Uncomment this line to use VLD in debug configuration only: -#MSVC_VLD_DIR=$(EXTLIBDIR)\Source\vld\vld - -!IF "$(BUILD_DEBUG)" == "YES" -!IFDEF MSVC_VLD_DIR -MSVC_VLD_FLAGS=-DMSVC_USE_VLD=1 -I$(MSVC_VLD_DIR)\include -!IFDEF WIN64 -MSVC_VLD_LIB=/LIBPATH:$(MSVC_VLD_DIR)/lib/Win64 -!ELSE -MSVC_VLD_LIB=/LIBPATH:$(MSVC_VLD_DIR)/lib/Win32 -!ENDIF -!ENDIF -!ENDIF - -############################################################################### -# Include directories - -GEOS_INCLUDE = -I..\include -I..\capi - -!MESSAGE *** Setting GEOS_INCLUDE $(GEOS_INCLUDE) -!MESSAGE *** Setting INCLUDE $(INCLUDE) - -############################################################################### -# Compilation flags for Release and Debug modes - -GEOS_CPPFLAGS = /D "NOMINMAX" /D "WIN32_LEAN_AND_MEAN" /D "NOGDI" -GEOS_CPPFLAGS = $(GEOS_CPPFLAGS) /D "GEOS_DLL_EXPORT" $(MSVC_VLD_FLAGS) - -!IF "$(BUILD_DEBUG)" == "YES" -BUILD_PREFIX=_d -GEOS_CFLAGS = /nologo /MDd /GR /Od /W4 /Zi -GEOS_CPPFLAGS = /D "DEBUG" /D "_DEBUG" $(GEOS_CPPFLAGS) -!ELSE -GEOS_CFLAGS = /nologo /MD /GR /O2 /W3 -GEOS_CPPFLAGS = /D "NDEBUG" $(GEOS_CPPFLAGS) -!ENDIF - -# Compiler version specific flags -!IF $(GEOS_MSC) >= 1400 -GEOS_CFLAGS = $(GEOS_CFLAGS) /EHs -GEOS_CPPFLAGS = $(GEOS_CPPFLAGS) /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "_SCL_SECURE_NO_DEPRECATE" -!ELSE -GEOS_CFLAGS = $(GEOS_CFLAGS) /GX -!ENDIF - -# For Visual C++ 9.0+ use multiple process build -!IF "$(BUILD_BATCH)" == "YES" -!IF $(GEOS_MSC) > 1400 -MPFLAGS = /MP -!MESSAGE *** Setting /MP flag to number of effective processors -!ENDIF -!ENDIF - -!IF "$(ENABLE_INLINE)" == "YES" -GEOS_CFLAGS = /D "GEOS_INLINE" -!ENDIF - -!MESSAGE *** Using GEOS_CFLAGS $(GEOS_CFLAGS) -!MESSAGE *** Using GEOS_CPPFLAGS $(GEOS_CPPFLAGS) - -CFLAGS=$(MPFLAGS) $(GEOS_CFLAGS) $(GEOS_CPPFLAGS) $(GEOS_INCLUDE) - -!MESSAGE *** Complete CFLAGS $(CFLAGS) - -############################################################################### -# Output location - -LIBNAME = geos$(BUILD_PREFIX).lib -DLLNAME = geos$(BUILD_PREFIX).dll -SLIBNAME = geos_i$(BUILD_PREFIX).lib -CDLLNAME = geos_c$(BUILD_PREFIX).dll -CLIBNAME = geos_c_i$(BUILD_PREFIX).lib - -############################################################################### -# Building toolset programs - -MAKE = nmake -CC = cl -RM = del -CP = copy - -# Linker executable -# - Dynamic-Linked Libraries -# $(LINK) /dll -# - Static Libraries (use of lib.exe wrapper is not portable, see VC++ Toolkit 2003) -# $(LINK) /lib -LINK = link.exe -LINKER_FLAGS = $(MSVC_VLD_LIB) - -!MESSAGE ********************************************************************** -# EOF diff --git a/SuperBuild/patches/GEOTIFF/geotiff-1-fix-rpath-macx.diff b/SuperBuild/patches/GEOTIFF/geotiff-1-fix-rpath-macx.diff new file mode 100644 index 0000000000000000000000000000000000000000..64b0cfcc5278ebfe0e04afee03f083afc4cf8bc0 --- /dev/null +++ b/SuperBuild/patches/GEOTIFF/geotiff-1-fix-rpath-macx.diff @@ -0,0 +1,22 @@ +diff -burN libgeotiff-1.4.2.orig/CMakeLists.txt libgeotiff-1.4.2/CMakeLists.txt +--- libgeotiff-1.4.2.orig/CMakeLists.txt Tue Jul 25 17:16:02 2017 ++++ libgeotiff-1.4.2/CMakeLists.txt Tue Jul 25 17:16:40 2017 +@@ -451,12 +451,12 @@ + VERSION ${LINK_VERSION} + SOVERSION ${LINK_SOVERSION} + CLEAN_DIRECT_OUTPUT 1 ) +- if (APPLE) +- set_target_properties( +- ${GEOTIFF_LIBRARY_TARGET} +- PROPERTIES +- INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") +- endif() ++ # if (APPLE) ++ # set_target_properties( ++ # ${GEOTIFF_LIBRARY_TARGET} ++ # PROPERTIES ++ # INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") ++ # endif() + + ELSE(UNIX) + # Default: diff --git a/SuperBuild/patches/GEOTIFF/geotiff-fix-configure-for-macx.diff b/SuperBuild/patches/GEOTIFF/geotiff-fix-configure-for-macx.diff deleted file mode 100755 index 32c001b68d59f51198d6264b5173ec282cd5e270..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/GEOTIFF/geotiff-fix-configure-for-macx.diff +++ /dev/null @@ -1,30 +0,0 @@ -diff -burN libgeotiff-1.4.1.orig/configure libgeotiff-1.4.1/configure ---- libgeotiff-1.4.1.orig/configure 2016-04-15 17:57:22.000000000 +0200 -+++ libgeotiff-1.4.1/configure 2016-04-19 09:33:34.000000000 +0200 -@@ -10079,9 +10079,9 @@ - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=func_echo_all -- archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" -+ archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \@rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" -- archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" -+ archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \@rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - - else -@@ -16101,7 +16101,7 @@ - - PROJ_CONFIG="yes" - -- elif test \( -f "$PROJ_HOME/lib/libproj.a" -o -f "$PROJ_HOME/lib/libproj.so" \) -a -f "$PROJ_HOME/include/proj_api.h"; then -+ elif test \( -f "$PROJ_HOME/lib/libproj.a" -o -f "$PROJ_HOME/lib/libproj.so" -o -f "$PROJ_HOME/lib/libproj.dylib" \) -a -f "$PROJ_HOME/include/proj_api.h"; then - PROJ_LIB="-L$PROJ_HOME/lib -lproj" - PROJ_INC=$PROJ_HOME/include - -@@ -21017,5 +21017,3 @@ - - - echo "" -- -- diff --git a/SuperBuild/patches/GLFW/glfw-1-fixes-win.diff b/SuperBuild/patches/GLFW/glfw-1-fixes-all.diff similarity index 100% rename from SuperBuild/patches/GLFW/glfw-1-fixes-win.diff rename to SuperBuild/patches/GLFW/glfw-1-fixes-all.diff diff --git a/SuperBuild/patches/OSSIM/ossim-5-compat_geos36-all.diff b/SuperBuild/patches/OSSIM/ossim-5-compat_geos36-all.diff new file mode 100644 index 0000000000000000000000000000000000000000..53f7312b8cac596f909c9e2a36e33d278637d120 --- /dev/null +++ b/SuperBuild/patches/OSSIM/ossim-5-compat_geos36-all.diff @@ -0,0 +1,36 @@ +diff -burN OSSIM.orig/ossim/src/ossim/base/ossimPolyArea2d.cpp OSSIM/ossim/src/ossim/base/ossimPolyArea2d.cpp +--- OSSIM.orig/ossim/src/ossim/base/ossimPolyArea2d.cpp 2017-07-04 15:16:30.659669941 +0200 ++++ OSSIM/ossim/src/ossim/base/ossimPolyArea2d.cpp 2017-07-05 09:46:23.142041689 +0200 +@@ -28,19 +28,13 @@ + #include <exception> + #include <vector> + +-class ossimGeometryFactoryWrapper : public ossimReferenced ++class ossimGeometryFactoryWrapper : public ossimReferenced, public geos::geom::GeometryFactory + { + public: + ossimGeometryFactoryWrapper() +- : m_geomFactory(0) +- { +- geos::geom::PrecisionModel *pm = +- new geos::geom::PrecisionModel(geos::geom::PrecisionModel::FLOATING); +- m_geomFactory = new geos::geom::GeometryFactory(pm, -1); +- } +- virtual ~ossimGeometryFactoryWrapper(){if(m_geomFactory) delete m_geomFactory;m_geomFactory=0;} +- +- geos::geom::GeometryFactory* m_geomFactory; ++ : geos::geom::GeometryFactory(new geos::geom::PrecisionModel(geos::geom::PrecisionModel::FLOATING),-1) ++ {} ++ virtual ~ossimGeometryFactoryWrapper(){} + }; + + class OssimPolyArea2dPrivate +@@ -55,7 +49,7 @@ + void deleteGeometry() { if(m_geometry) { delete m_geometry; m_geometry = 0; }} + void setGeometry(const ossimPolygon& polygon, const vector<ossimPolygon>& holes = vector<ossimPolygon>()); + void setGeometry(GeometryPtr geom){deleteGeometry();m_geometry=geom;} +- geos::geom::GeometryFactory* geomFactory(){{return m_globalFactory.valid()?m_globalFactory->m_geomFactory:0;}} ++ geos::geom::GeometryFactory* geomFactory(){{return m_globalFactory.valid()?m_globalFactory.get():0;}} + GeometryPtr m_geometry; + static ossimRefPtr<ossimGeometryFactoryWrapper> m_globalFactory; + }; diff --git a/SuperBuild/patches/PROJ/proj-1-cmakefixes-all.diff b/SuperBuild/patches/PROJ/proj-1-cmakefixes-all.diff new file mode 100644 index 0000000000000000000000000000000000000000..a95c58fbfe34ecdfd12073c1132f9a68811c1f6e --- /dev/null +++ b/SuperBuild/patches/PROJ/proj-1-cmakefixes-all.diff @@ -0,0 +1,34 @@ +diff -burN proj-4.9.3.orig/CMakeLists.txt proj-4.9.3/CMakeLists.txt +--- proj-4.9.3.orig/CMakeLists.txt 2016-08-29 20:47:58.000000000 +0200 ++++ proj-4.9.3/CMakeLists.txt 2017-07-26 12:34:26.071721900 +0200 +@@ -34,6 +34,7 @@ + proj_version(MAJOR 4 MINOR 9 PATCH 3) + set(PROJ_API_VERSION "12") + set(PROJ_BUILD_VERSION "12.0.0") ++option(VERSIONED_OUTPUT "suffix version into output name of binaries." ON) + + ################################################################################# + # Build features and variants +diff -burN proj-4.9.3.orig/src/lib_proj.cmake proj-4.9.3/src/lib_proj.cmake +--- proj-4.9.3.orig/src/lib_proj.cmake 2016-08-29 20:47:58.000000000 +0200 ++++ proj-4.9.3/src/lib_proj.cmake 2017-07-26 12:28:51.098731200 +0200 +@@ -274,11 +274,19 @@ + + + if(WIN32) ++if(VERSIONED_OUTPUT) + set_target_properties(${PROJ_CORE_TARGET} + PROPERTIES + VERSION "${${PROJECT_INTERN_NAME}_BUILD_VERSION}" + OUTPUT_NAME "${PROJ_CORE_TARGET_OUTPUT_NAME}" + CLEAN_DIRECT_OUTPUT 1) ++ else() ++ set_target_properties(${PROJ_CORE_TARGET} ++ PROPERTIES ++ VERSION "${${PROJECT_INTERN_NAME}_BUILD_VERSION}" ++ CLEAN_DIRECT_OUTPUT 1) ++ endif() #VERSIONED_OUTPUT ++ + elseif(BUILD_FRAMEWORKS_AND_BUNDLE) + set_target_properties(${PROJ_CORE_TARGET} + PROPERTIES diff --git a/SuperBuild/patches/PROJ/proj-fix-rpath-for-macx.diff b/SuperBuild/patches/PROJ/proj-fix-rpath-for-macx.diff deleted file mode 100644 index 1ab4acdab9cde44e6aef0930affcdcd525c7cee6..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/PROJ/proj-fix-rpath-for-macx.diff +++ /dev/null @@ -1,20 +0,0 @@ -diff -burN proj-4.8.0.orig/configure proj-4.8.0/configure ---- proj-4.8.0.orig/configure 2016-04-18 17:31:49.000000000 +0200 -+++ proj-4.8.0/configure 2016-04-18 17:32:47.000000000 +0200 -@@ -9044,9 +9044,9 @@ - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=func_echo_all -- archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" -+ archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \@rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" -- archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" -+ archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \@rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - - else -@@ -16296,4 +16296,3 @@ - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 - $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} - fi -- diff --git a/SuperBuild/patches/QT4/configure_qt4.bat.in b/SuperBuild/patches/QT4/configure_qt4.bat.in index ce92ad480dce9d657b13a155cf2296568ddebc68..0439a883f043d14e36b2714fe150268641e7738b 100755 --- a/SuperBuild/patches/QT4/configure_qt4.bat.in +++ b/SuperBuild/patches/QT4/configure_qt4.bat.in @@ -4,7 +4,7 @@ set SB_SAVE_LIB=%LIB% set INCLUDE=%INCLUDE%;@QT4_INCLUDE_PREFIX_NATIVE@;@QT4_INCLUDE_PREFIX_NATIVE@\freetype2 set LIB=%LIB%;@QT4_LIB_PREFIX_NATIVE@ -@QT4_CONFIGURE_SCRIPT@ -prefix @QT4_INSTALL_PREFIX_NATIVE@ -L @QT4_LIB_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@\freetype2 -opensource -confirm-license -release -shared -nomake demos -nomake examples -nomake tools -no-phonon-backend -no-phonon -no-script -no-scripttools -no-multimedia -no-audio-backend -no-webkit -no-declarative -no-qt3support -no-xmlpatterns -system-sqlite -qt-sql-sqlite -plugin-sql-sqlite -no-openssl -no-libtiff -no-libmng -system-libpng -system-libjpeg -system-zlib @QT4_SB_CONFIG@ +@QT4_CONFIGURE_SCRIPT@ -prefix @QT4_INSTALL_PREFIX_NATIVE@ -L @QT4_LIB_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@\freetype2 -opensource -confirm-license -release -shared -nomake demos -nomake examples -nomake tools -no-phonon-backend -no-phonon -no-script -no-scripttools -no-multimedia -no-audio-backend -no-webkit -no-declarative -no-qt3support -no-xmlpatterns -no-sql-sqlite -no-openssl -no-libtiff -no-libmng -system-libpng -system-libjpeg -system-zlib @QT4_SB_CONFIG@ set INCLUDE=%SB_SAVE_INCLUDE% set LIB=%SB_SAVE_LIB% diff --git a/SuperBuild/patches/QT4/configure_qt4.sh.in b/SuperBuild/patches/QT4/configure_qt4.sh.in index 8f8a01a3d3b41bf303a9cbd0deccbd9ac44fff72..1ed3ef3f981f0bb5343f9d2202b5d5cd5150bc70 100755 --- a/SuperBuild/patches/QT4/configure_qt4.sh.in +++ b/SuperBuild/patches/QT4/configure_qt4.sh.in @@ -1 +1 @@ -@QT4_CONFIGURE_SCRIPT@ -prefix @QT4_INSTALL_PREFIX_NATIVE@ -L @QT4_LIB_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@/freetype2 -opensource -confirm-license -release -shared -nomake demos -nomake examples -nomake tools -no-phonon-backend -no-phonon -no-script -no-scripttools -no-multimedia -no-audio-backend -no-webkit -no-declarative -no-qt3support -no-xmlpatterns -system-sqlite -qt-sql-sqlite -plugin-sql-sqlite -no-openssl -no-libtiff -no-libmng -system-libpng -system-libjpeg -system-zlib @QT4_SB_CONFIG@ +@QT4_CONFIGURE_SCRIPT@ -prefix @QT4_INSTALL_PREFIX_NATIVE@ -L @QT4_LIB_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@/freetype2 -opensource -confirm-license -release -shared -nomake demos -nomake examples -nomake tools -no-phonon-backend -no-phonon -no-script -no-scripttools -no-multimedia -no-audio-backend -no-webkit -no-declarative -no-qt3support -no-xmlpatterns -no-sql-sqlite -no-openssl -no-libtiff -no-libmng -system-libpng -system-libjpeg -system-zlib @QT4_SB_CONFIG@ diff --git a/SuperBuild/patches/README.md b/SuperBuild/patches/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f912b067aafc01467b1d278f7005259492412261 --- /dev/null +++ b/SuperBuild/patches/README.md @@ -0,0 +1,20 @@ +## Synopsis + +Illustrates how to include a patch to the superbuild sources. This patch will be apply before the compilation of the external project. + +## Example + +Here is how to make a patch for superbuild. The example is here used libgeos but it can be done for any external projects in the OTB Superbuild. + +- cd /tmp +- wget http://download.osgeo.org/geos/geos-3.6.1.tar.bz2 +- tar xjf geos-3.6.1.tar.bz2 +- cp -r geos-3.6.1 geos-3.6.1.orig + +(make changes to geos-3.6.1) + +And prepare diff between two directories + +- diff -burN geos-3.6.1.orig geos-3.6.1 > geos-1-fixes-all.diff + +diff file naming is <project>-<number for applying in correct order>-<all/win/linux/macx>.diff diff --git a/SuperBuild/patches/SHARK/shark-1-disable-hdf5-all.diff b/SuperBuild/patches/SHARK/shark-1-disable-hdf5-all.diff new file mode 100755 index 0000000000000000000000000000000000000000..e7fba1953d4d93c79ac864fc175ad957d97774e6 --- /dev/null +++ b/SuperBuild/patches/SHARK/shark-1-disable-hdf5-all.diff @@ -0,0 +1,21 @@ +diff -burN Shark.orig/CMakeLists.txt Shark/CMakeLists.txt +--- Shark.orig/CMakeLists.txt 2016-09-02 17:04:54.000000000 +0200 ++++ Shark/CMakeLists.txt 2017-07-31 16:41:18.563473752 +0200 +@@ -194,6 +194,8 @@ + ##################################################################### + # HDF5 configuration + ##################################################################### ++option(ENABLE_HDF5 "Use HDF5" ON) ++if(ENABLE_HDF5) + find_package(HDF5 COMPONENTS C CXX HL QUIET) + mark_as_advanced(HDF5_DIR) + if(HDF5_FOUND) +@@ -215,7 +217,7 @@ + else() + message(STATUS "HDF5 not found, skip") + endif() +- ++endif() #ENABLE_HDF5 + ##################################################################### + # ATLAS configuration + ##################################################################### diff --git a/SuperBuild/patches/SHARK/shark-1-disable-hdf5-linux.diff b/SuperBuild/patches/SHARK/shark-1-disable-hdf5-linux.diff deleted file mode 100644 index d0b3df4d7f8355a0da6f4a26ff4d0c4187bca1df..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/SHARK/shark-1-disable-hdf5-linux.diff +++ /dev/null @@ -1,258 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index df8be65..c6c3020 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -191,29 +191,32 @@ endif() - ##################################################################### - # HDF5 configuration - ##################################################################### --find_package(HDF5 COMPONENTS C CXX HL QUIET) --mark_as_advanced(HDF5_DIR) --if(HDF5_FOUND) -- if(HDF5_C_COMPILER_EXECUTABLE AND HDF5_CXX_COMPILER_EXECUTABLE) -- message(STATUS "Checking HDF5 installation: HDF5 installation seems ok.") -- include_directories( ${HDF5_INCLUDE_DIR} ) -- link_directories( ${HDF5_LIBRARY_DIR} ) -- list(APPEND LINK_LIBRARIES ${HDF5_LIBRARIES}) -- else() -- message(STATUS "Checking HDF5 installation:HDF5 package might be broken.") -- if(NOT( HDF5_C_COMPILER_EXECUTABLE)) -- message(STATUS " C Compiler Extension not found.") -- endif() -- if(NOT( HDF5_CXX_COMPILER_EXECUTABLE)) -- message(STATUS " CXX Compiler Extension not found.") -- endif() -- message(STATUS "Disabling HDF5.") -- unset( HDF5_FOUND ) -- endif() --else() -- message(STATUS "HDF5 not found, skip") -+option(ENABLE_HDF5 "Use HDF5" ON) -+ -+if(ENABLE_HDF5) -+ find_package(HDF5 COMPONENTS C CXX HL QUIET) -+ mark_as_advanced(HDF5_DIR) -+ if(HDF5_FOUND) -+ if(HDF5_C_COMPILER_EXECUTABLE AND HDF5_CXX_COMPILER_EXECUTABLE) -+ message(STATUS "Checking HDF5 installation: HDF5 installation seems ok.") -+ include_directories( ${HDF5_INCLUDE_DIR} ) -+ link_directories( ${HDF5_LIBRARY_DIR} ) -+ list(APPEND LINK_LIBRARIES ${HDF5_LIBRARIES}) -+ else() -+ message(STATUS "Checking HDF5 installation:HDF5 package might be broken.") -+ if(NOT( HDF5_C_COMPILER_EXECUTABLE)) -+ message(STATUS " C Compiler Extension not found.") -+ endif() -+ if(NOT( HDF5_CXX_COMPILER_EXECUTABLE)) -+ message(STATUS " CXX Compiler Extension not found.") -+ endif() -+ message(STATUS "Disabling HDF5.") -+ unset( HDF5_FOUND ) -+ endif() -+ else() -+ message(STATUS "HDF5 not found, skip") -+ endif() - endif() -- - ##################################################################### - # ATLAS configuration - ##################################################################### -@@ -222,104 +225,104 @@ endif() - option( ENABLE_CBLAS "Use Installed Linear Algebra Library" ON ) - - if( ENABLE_CBLAS ) -- set(CBLAS_VENDOR FALSE) -- if( APPLE ) -- set(CBLAS_VENDOR "Accelerate") -- set(CBLAS_INCLUDES "") -- set(CBLAS_LIBRARIES "-framework Accelerate" ) -- else() -- #todo: do a propper vendor check -- find_library(OPENBLAS_LIBRARY openblas -- HINTS ${CBLAS_ROOT}/lib /opt/local/lib -- ) -- find_library(CBLAS_LIBRARY cblas -- HINTS ${ATLAS_ROOT}/lib ${CBLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/ -- ) -- find_library(CLAPACK_LIBRARY lapack -- HINTS ${ATLAS_ROOT}/lib ${CBLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/ -- ) -- find_library(ATLAS_LIBRARY atlas -- HINTS ${ATLAS_ROOT}/lib ${CBLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/ -- ) -- mark_as_advanced( -- OPENBLAS_LIBRARY -- CBLAS_LIBRARY -- CLAPACK_LIBRARY -- ATLAS_LIBRARY -- ) -- #find the cblas.h include path -- if(CBLAS_LIBRARY ) -- get_filename_component(CBLAS_LIB_PATH ${CBLAS_LIBRARY} PATH ) -- elseif( OPENBLAS_LIBRARY) -- get_filename_component(CBLAS_LIB_PATH ${OPENBLAS_LIBRARY} PATH ) -- endif() -- if(CBLAS_LIB_PATH) -- find_file(CBLAS_INCLUDES cblas.h -- PATHS ${CBLAS_LIB_PATH} ${CBLAS_LIB_PATH}/../include -- ) -- get_filename_component(CBLAS_INCLUDES ${CBLAS_INCLUDES} PATH ) -- endif() -- if(ATLAS_LIBRARY) -- get_filename_component(ATLAS_LIBRARY_PATH ${ATLAS_LIBRARY} PATH ) -- find_file(CLAPACK_INCLUDES clapack.h -- PATHS -- ${ATLAS_LIBRARY_PATH} -- ${ATLAS_LIBRARY_PATH}/../include -- ${ATLAS_LIBRARY_PATH}/../include/atlas -- ${ATLAS_LIBRARY_PATH}/../../include/atlas -- ) -- get_filename_component(CLAPACK_INCLUDES ${CLAPACK_INCLUDES} PATH ) -- set(CBLAS_INCLUDES ${CBLAS_INCLUDES} ${CLAPACK_INCLUDES}) -- endif() -- -- if( OPENBLAS_LIBRARY AND CBLAS_INCLUDES) -- set(CBLAS_VENDOR "OpenBLAS") -- set(CBLAS_LIBRARIES ${OPENBLAS_LIBRARY}) -- elseif( CBLAS_LIBRARY AND CLAPACK_LIBRARY AND ATLAS_LIBRARY AND CBLAS_INCLUDES) -- set(CBLAS_VENDOR "ATLAS") -- set(CBLAS_LIBRARIES ${CLAPACK_LIBRARY} ${CBLAS_LIBRARY} ${ATLAS_LIBRARY}) -- elseif( CBLAS_LIBRARY AND CBLAS_INCLUDES) -- #check that we can compile a basic program with the libraries we have found -- #vendor versions might come with additional libraries which would be bad. -- try_compile(CBLAS_COMPILE -- "${PROJECT_BINARY_DIR}/cBlasCheck" -- "${CMAKE_SOURCE_DIR}/cBlasCheck.cpp" -- CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CBLAS_INCLUDES}" -- LINK_LIBRARIES ${CBLAS_LIBRARY} -- ) -- if(CBLAS_COMPILE) -- set(CBLAS_VENDOR "GENERIC") -- set(CBLAS_LIBRARIES ${CBLAS_LIBRARY}) -- else() -- message(WARNING "Unknown CBLAS. Can not use it") -- endif() -- endif() -- endif() -+ set(CBLAS_VENDOR FALSE) -+ if( APPLE ) -+ set(CBLAS_VENDOR "Accelerate") -+ set(CBLAS_INCLUDES "") -+ set(CBLAS_LIBRARIES "-framework Accelerate" ) -+ else() -+ #todo: do a propper vendor check -+ find_library(OPENBLAS_LIBRARY openblas -+ HINTS ${CBLAS_ROOT}/lib /opt/local/lib -+ ) -+ find_library(CBLAS_LIBRARY cblas -+ HINTS ${ATLAS_ROOT}/lib ${CBLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/ -+ ) -+ find_library(CLAPACK_LIBRARY lapack -+ HINTS ${ATLAS_ROOT}/lib ${CBLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/ -+ ) -+ find_library(ATLAS_LIBRARY atlas -+ HINTS ${ATLAS_ROOT}/lib ${CBLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/ -+ ) -+ mark_as_advanced( -+ OPENBLAS_LIBRARY -+ CBLAS_LIBRARY -+ CLAPACK_LIBRARY -+ ATLAS_LIBRARY -+ ) -+ #find the cblas.h include path -+ if(CBLAS_LIBRARY ) -+ get_filename_component(CBLAS_LIB_PATH ${CBLAS_LIBRARY} PATH ) -+ elseif( OPENBLAS_LIBRARY) -+ get_filename_component(CBLAS_LIB_PATH ${OPENBLAS_LIBRARY} PATH ) -+ endif() -+ if(CBLAS_LIB_PATH) -+ find_file(CBLAS_INCLUDES cblas.h -+ PATHS ${CBLAS_LIB_PATH} ${CBLAS_LIB_PATH}/../include -+ ) -+ get_filename_component(CBLAS_INCLUDES ${CBLAS_INCLUDES} PATH ) -+ endif() -+ if(ATLAS_LIBRARY) -+ get_filename_component(ATLAS_LIBRARY_PATH ${ATLAS_LIBRARY} PATH ) -+ find_file(CLAPACK_INCLUDES clapack.h -+ PATHS -+ ${ATLAS_LIBRARY_PATH} -+ ${ATLAS_LIBRARY_PATH}/../include -+ ${ATLAS_LIBRARY_PATH}/../include/atlas -+ ${ATLAS_LIBRARY_PATH}/../../include/atlas -+ ) -+ get_filename_component(CLAPACK_INCLUDES ${CLAPACK_INCLUDES} PATH ) -+ set(CBLAS_INCLUDES ${CBLAS_INCLUDES} ${CLAPACK_INCLUDES}) -+ endif() -+ -+ if( OPENBLAS_LIBRARY AND CBLAS_INCLUDES) -+ set(CBLAS_VENDOR "OpenBLAS") -+ set(CBLAS_LIBRARIES ${OPENBLAS_LIBRARY}) -+ elseif( CBLAS_LIBRARY AND CLAPACK_LIBRARY AND ATLAS_LIBRARY AND CBLAS_INCLUDES) -+ set(CBLAS_VENDOR "ATLAS") -+ set(CBLAS_LIBRARIES ${CLAPACK_LIBRARY} ${CBLAS_LIBRARY} ${ATLAS_LIBRARY}) -+ elseif( CBLAS_LIBRARY AND CBLAS_INCLUDES) -+ #check that we can compile a basic program with the libraries we have found -+ #vendor versions might come with additional libraries which would be bad. -+ try_compile(CBLAS_COMPILE -+ "${PROJECT_BINARY_DIR}/cBlasCheck" -+ "${CMAKE_SOURCE_DIR}/cBlasCheck.cpp" -+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CBLAS_INCLUDES}" -+ LINK_LIBRARIES ${CBLAS_LIBRARY} -+ ) -+ if(CBLAS_COMPILE) -+ set(CBLAS_VENDOR "GENERIC") -+ set(CBLAS_LIBRARIES ${CBLAS_LIBRARY}) -+ else() -+ message(WARNING "Unknown CBLAS. Can not use it") -+ endif() -+ endif() -+ endif() - -- if(CBLAS_VENDOR) -- message(STATUS "CBLAS FOUND: " ${CBLAS_VENDOR} " with include directory " ${CBLAS_INCLUDES} ) -- set(SHARK_USE_CBLAS 1) -- list(APPEND EXTRA_INCLUDE_DIRECTORIES ${CBLAS_INCLUDES} ) -- list(APPEND LINK_LIBRARIES ${CBLAS_LIBRARIES}) -- include_directories ( ${CBLAS_INCLUDES} ) -- else() -- message(STATUS "No usable CBLAS Library found. No fast linear Algebra used.") -- endif() -+ if(CBLAS_VENDOR) -+ message(STATUS "CBLAS FOUND: " ${CBLAS_VENDOR} " with include directory " ${CBLAS_INCLUDES} ) -+ set(SHARK_USE_CBLAS 1) -+ list(APPEND EXTRA_INCLUDE_DIRECTORIES ${CBLAS_INCLUDES} ) -+ list(APPEND LINK_LIBRARIES ${CBLAS_LIBRARIES}) -+ include_directories ( ${CBLAS_INCLUDES} ) -+ else() -+ message(STATUS "No usable CBLAS Library found. No fast linear Algebra used.") -+ endif() - -- #Special setup for ATLAS -- if( CBLAS_VENDOR MATCHES "ATLAS" ) -- set( SHARK_USE_ATLAS_LAPACK 1) # ATLAS always contains some LAPACK methods that we can use -+ #Special setup for ATLAS -+ if( CBLAS_VENDOR MATCHES "ATLAS" ) -+ set( SHARK_USE_ATLAS_LAPACK 1) # ATLAS always contains some LAPACK methods that we can use - -- #check for full lapack -- set(CMAKE_REQUIRE_QUIET 1) -- set(CMAKE_REQUIRED_LIBRARIES ${CBLAS_LIBRARIES}) -- check_function_exists(dsyev_ ATLAS_FULL_LAPACK) -+ #check for full lapack -+ set(CMAKE_REQUIRE_QUIET 1) -+ set(CMAKE_REQUIRED_LIBRARIES ${CBLAS_LIBRARIES}) -+ check_function_exists(dsyev_ ATLAS_FULL_LAPACK) - -- if( ATLAS_FULL_LAPACK ) -- set( SHARK_USE_LAPACK 1) -- message(STATUS "Detected ATLAS with full LAPACK package. Using it!") -- endif() -- endif() -+ if( ATLAS_FULL_LAPACK ) -+ set( SHARK_USE_LAPACK 1) -+ message(STATUS "Detected ATLAS with full LAPACK package. Using it!") -+ endif() -+ endif() - endif() - ##################################################################### - # Static Code Analysis diff --git a/SuperBuild/patches/TIFF/CMakeLists.txt b/SuperBuild/patches/TIFF/CMakeLists.txt deleted file mode 100644 index 287ba9ceba8ccc92673fcc929496438f557a6050..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/TIFF/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -cmake_minimum_required(VERSION 2.8.3) - -project(tiff_install) - -file(GLOB ${PROJECT_NAME}_HEADERS "${TIFF_BUILD_DIR}/tif*.h" ) -file(GLOB ${PROJECT_NAME}_LIBS "${TIFF_BUILD_DIR}/libtiff*.lib" ) -file(GLOB ${PROJECT_NAME}_DLLS "${TIFF_BUILD_DIR}/libtiff*.dll" ) - -foreach(${PROJECT_NAME}_HEADER ${${PROJECT_NAME}_HEADERS}) -install(FILES ${${PROJECT_NAME}_HEADER} - DESTINATION include - COMPONENT Development) -endforeach() - -foreach(${PROJECT_NAME}_LIB ${${PROJECT_NAME}_LIBS}) -install(FILES ${${PROJECT_NAME}_LIB} - DESTINATION lib - COMPONENT Development) -endforeach() - -foreach(${PROJECT_NAME}_DLL ${${PROJECT_NAME}_DLLS}) -install(FILES ${${PROJECT_NAME}_DLL} - DESTINATION bin - COMPONENT Development) -endforeach() \ No newline at end of file diff --git a/SuperBuild/patches/TIFF/nmake.opt b/SuperBuild/patches/TIFF/nmake.opt deleted file mode 100644 index cb1c9ea849db145f3ce36c0e00aeeecfaa6ea0ff..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/TIFF/nmake.opt +++ /dev/null @@ -1,218 +0,0 @@ -# $Id: nmake.opt,v 1.18 2006/06/07 16:33:45 dron Exp $ -# -# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# Compile time parameters for MS Visual C++ compiler. -# You may edit this file to specify building options. - -# -###### Edit the following lines to choose a feature set you need. ####### -# - -# -# Select WINMODE_CONSOLE to build a library which reports errors to stderr, or -# WINMODE_WINDOWED to build such that errors are reported via MessageBox(). -# -WINMODE_CONSOLE = 1 -#WINMODE_WINDOWED = 1 - -# -# Comment out the following lines to disable internal codecs. -# -# Support for CCITT Group 3 & 4 algorithms -CCITT_SUPPORT = 1 -# Support for Macintosh PackBits algorithm -PACKBITS_SUPPORT = 1 -# Support for LZW algorithm -LZW_SUPPORT = 1 -# Support for ThunderScan 4-bit RLE algorithm -THUNDER_SUPPORT = 1 -# Support for NeXT 2-bit RLE algorithm -NEXT_SUPPORT = 1 -# Support for LogLuv high dynamic range encoding -LOGLUV_SUPPORT = 1 - -# -# Uncomment and edit following lines to enable JPEG support. -# -JPEG_SUPPORT = 1 -JPEGDIR = @CMAKE_WIN_INSTALL_PREFIX@ -JPEG_INCLUDE = -I$(JPEGDIR)\include -JPEG_LIB = $(JPEGDIR)\lib\jpeg.lib - -# -# Uncomment and edit following lines to enable ZIP support -# (required for Deflate compression and Pixar log-format) -# -ZIP_SUPPORT = 1 -ZLIBDIR = @CMAKE_WIN_INSTALL_PREFIX@ -ZLIB_INCLUDE = -I$(ZLIBDIR)\include -ZLIB_LIB = $(ZLIBDIR)\lib\zlib.lib - -# -# Uncomment and edit following lines to enable ISO JBIG support -# -#JBIG_SUPPORT = 1 -#JBIGDIR = d:/projects/jbigkit -#JBIG_INCLUDE = -I$(JBIGDIR)/libjbig -#JBIG_LIB = $(JBIGDIR)/libjbig/jbig.lib - -# -# Uncomment following line to enable Pixar log-format algorithm -# (Zlib required). -# -#PIXARLOG_SUPPORT = 1 - -# -# Comment out the following lines to disable strip chopping -# (whether or not to convert single-strip uncompressed images to mutiple -# strips of specified size to reduce memory usage). Default strip size -# is 8192 bytes, it can be configured via the STRIP_SIZE_DEFAULT parameter -# -STRIPCHOP_SUPPORT = 1 -STRIP_SIZE_DEFAULT = 8192 - -# -# Comment out the following lines to disable treating the fourth sample with -# no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA -# files but don't mark the alpha properly. -# -EXTRASAMPLE_AS_ALPHA_SUPPORT = 1 - -# -# Comment out the following lines to disable picking up YCbCr subsampling -# info from the JPEG data stream to support files lacking the tag. -# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details. -# -CHECK_JPEG_YCBCR_SUBSAMPLING = 1 - -# -####################### Compiler related options. ####################### -# - -# -# Pick debug or optimized build flags. We default to an optimized build -# with no debugging information. -# NOTE: /EHsc option required if you want to build the C++ stream API -# -OPTFLAGS = /Ox /MD /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE -DHAVE_SNPRINTF -#OPTFLAGS = /Zi - -# -# Uncomment following line to enable using Windows Common RunTime Library -# instead of Windows specific system calls. See notes on top of tif_unix.c -# module for details. -# -USE_WIN_CRT_LIB = 1 - -# Compiler specific options. You may probably want to adjust compilation -# parameters in CFLAGS variable. Refer to your compiler documentation -# for the option reference. -# -MAKE = nmake /nologo -CC = cl /nologo -CXX = cl /nologo -AR = lib /nologo -LD = link /nologo - -CFLAGS = $(OPTFLAGS) $(INCL) $(EXTRAFLAGS) -CXXFLAGS = $(OPTFLAGS) $(INCL) $(EXTRAFLAGS) -EXTRAFLAGS = -LIBS = - -# Name of the output shared library -DLLNAME = libtiff.dll - -# -########### There is nothing to edit below this line normally. ########### -# - -# Set the native cpu bit order -EXTRAFLAGS = -DFILLODER_LSB2MSB $(EXTRAFLAGS) - -!IFDEF WINMODE_WINDOWED -EXTRAFLAGS = -DTIF_PLATFORM_WINDOWED $(EXTRAFLAGS) -LIBS = user32.lib $(LIBS) -!ELSE -EXTRAFLAGS = -DTIF_PLATFORM_CONSOLE $(EXTRAFLAGS) -!ENDIF - -# Codec stuff -!IFDEF CCITT_SUPPORT -EXTRAFLAGS = -DCCITT_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF PACKBITS_SUPPORT -EXTRAFLAGS = -DPACKBITS_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF LZW_SUPPORT -EXTRAFLAGS = -DLZW_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF THUNDER_SUPPORT -EXTRAFLAGS = -DTHUNDER_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF NEXT_SUPPORT -EXTRAFLAGS = -DNEXT_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF LOGLUV_SUPPORT -EXTRAFLAGS = -DLOGLUV_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF JPEG_SUPPORT -LIBS = $(LIBS) $(JPEG_LIB) -EXTRAFLAGS = -DJPEG_SUPPORT -DOJPEG_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF ZIP_SUPPORT -LIBS = $(LIBS) $(ZLIB_LIB) -EXTRAFLAGS = -DZIP_SUPPORT $(EXTRAFLAGS) -!IFDEF PIXARLOG_SUPPORT -EXTRAFLAGS = -DPIXARLOG_SUPPORT $(EXTRAFLAGS) -!ENDIF -!ENDIF - -!IFDEF JBIG_SUPPORT -LIBS = $(LIBS) $(JBIG_LIB) -EXTRAFLAGS = -DJBIG_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF STRIPCHOP_SUPPORT -EXTRAFLAGS = -DSTRIPCHOP_DEFAULT=TIFF_STRIPCHOP -DSTRIP_SIZE_DEFAULT=$(STRIP_SIZE_DEFAULT) $(EXTRAFLAGS) -!ENDIF - -!IFDEF EXTRASAMPLE_AS_ALPHA_SUPPORT -EXTRAFLAGS = -DDEFAULT_EXTRASAMPLE_AS_ALPHA $(EXTRAFLAGS) -!ENDIF - -!IFDEF CHECK_JPEG_YCBCR_SUBSAMPLING -EXTRAFLAGS = -DCHECK_JPEG_YCBCR_SUBSAMPLING $(EXTRAFLAGS) -!ENDIF - -!IFDEF USE_WIN_CRT_LIB -EXTRAFLAGS = -DAVOID_WIN32_FILEIO $(EXTRAFLAGS) -!ELSE -EXTRAFLAGS = -DUSE_WIN32_FILEIO $(EXTRAFLAGS) -!ENDIF diff --git a/SuperBuild/patches/TIFF/tiff-1-cmakefixes-all.diff b/SuperBuild/patches/TIFF/tiff-1-cmakefixes-all.diff new file mode 100644 index 0000000000000000000000000000000000000000..a0c3b6f08bcaa234f96f07d266cf1bdbaae189bc --- /dev/null +++ b/SuperBuild/patches/TIFF/tiff-1-cmakefixes-all.diff @@ -0,0 +1,163 @@ +diff -burN tiff-4.0.8.orig/CMakeLists.txt tiff-4.0.8/CMakeLists.txt +--- tiff-4.0.8.orig/CMakeLists.txt Thu Jul 20 12:53:54 2017 ++++ tiff-4.0.8/CMakeLists.txt Thu Jul 20 13:17:05 2017 +@@ -601,21 +601,35 @@ + set(CXX_SUPPORT TRUE) + endif() + +-# OpenGL and GLUT +-find_package(OpenGL) +-find_package(GLUT) +-set(HAVE_OPENGL FALSE) +-if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) ++# OpenGL support ++option(with_opengl "Enable opengl support (requires opengl and glut packages)" ON) ++if(with_opengl) ++ # OpenGL and GLUT ++ find_package(OpenGL) ++ find_package(GLUT) ++ set(HAVE_OPENGL FALSE) ++ if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) + set(HAVE_OPENGL TRUE) +-endif() +-# Purely to satisfy the generated headers: +-check_include_file(GL/gl.h HAVE_GL_GL_H) +-check_include_file(GL/glu.h HAVE_GL_GLU_H) +-check_include_file(GL/glut.h HAVE_GL_GLUT_H) +-check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) +-check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) +-check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) ++ endif() ++ # Purely to satisfy the generated headers: ++ check_include_file(GL/gl.h HAVE_GL_GL_H) ++ check_include_file(GL/glu.h HAVE_GL_GLU_H) ++ check_include_file(GL/glut.h HAVE_GL_GLUT_H) ++ check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) ++ check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) ++ check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) ++else() #with_opengl ++ set(HAVE_OPENGL FALSE) ++ #force opengl headers check to FALSE. ++ set(HAVE_GL_GL_H FALSE) ++ set(HAVE_GL_GLU_H FALSE) ++ set(HAVE_GL_GLUT_H FALSE) ++ set(HAVE_GLUT_GLUT_H FALSE) ++ set(HAVE_OPENGL_GL_H FALSE) ++ set(HAVE_OPENGL_GLU_H FALSE) ++endif() #with_opengl + ++ + # Win32 IO + set(win32_io FALSE) + if(WIN32) +@@ -713,19 +727,38 @@ + if(LIBLZMA_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${LIBLZMA_LIBRARIES}) + endif() +- + #report_values(TIFF_INCLUDES TIFF_LIBRARY_DEPS) + ++# NEED_LIBPORT is later updated in port/CMakeLists.txt and ++# used in libtiff/CMakeLists.txt to generate tif_config.h. ++# see libtiff/tif_config.h.cmake.in for usage ++set(NEED_LIBPORT FALSE) ++ + # Process subdirectories + add_subdirectory(port) + add_subdirectory(libtiff) +-add_subdirectory(tools) +-add_subdirectory(test) +-add_subdirectory(contrib) ++ ++option(with_tools "build executables in tools directory" ON) ++if(with_tools) ++ add_subdirectory(tools) ++endif() ++option(with_test "build executables in tests directory" ON) ++if(with_test) ++ add_subdirectory(test) ++endif() ++ ++option(with_contrib "build executables in contrib directory" ON) ++if(with_contrib) ++ add_subdirectory(contrib) ++endif() ++ + add_subdirectory(build) +-add_subdirectory(man) +-add_subdirectory(html) +- ++ ++option(with_docs "build html and man docs" ON) ++if(with_docs) ++ add_subdirectory(man) ++ add_subdirectory(html) ++endif() + #message(STATUS "EXTRA_DIST: ${EXTRA_DIST}") + + message(STATUS "") +diff -burN tiff-4.0.8.orig/contrib/iptcutil/iptcutil.c tiff-4.0.8/contrib/iptcutil/iptcutil.c +--- tiff-4.0.8.orig/contrib/iptcutil/iptcutil.c Thu Jul 20 12:53:54 2017 ++++ tiff-4.0.8/contrib/iptcutil/iptcutil.c Thu Jul 20 13:14:55 2017 +@@ -19,7 +19,7 @@ + # include <fcntl.h> + #endif + +-#ifdef WIN32 ++#ifdef _MSC_VER + #define STRNICMP strnicmp + #else + #define STRNICMP strncasecmp +diff -burN tiff-4.0.8.orig/libtiff/tif_config.h.cmake.in tiff-4.0.8/libtiff/tif_config.h.cmake.in +--- tiff-4.0.8.orig/libtiff/tif_config.h.cmake.in Thu Jul 20 12:53:54 2017 ++++ tiff-4.0.8/libtiff/tif_config.h.cmake.in Thu Jul 20 13:15:21 2017 +@@ -259,3 +259,9 @@ + + /* Define to `unsigned int' if <sys/types.h> does not define. */ + #undef size_t ++ ++#ifdef _MSC_VER ++#pragma warning(disable : 4996) /* function deprecation warnings */ ++#endif ++ ++#cmakedefine NEED_LIBPORT 1 +diff -burN tiff-4.0.8.orig/port/CMakeLists.txt tiff-4.0.8/port/CMakeLists.txt +--- tiff-4.0.8.orig/port/CMakeLists.txt Thu Jul 20 12:53:54 2017 ++++ tiff-4.0.8/port/CMakeLists.txt Thu Jul 20 13:15:32 2017 +@@ -32,25 +32,35 @@ + strtoull.c) + + set(port_USED_FILES ${port_SOURCES} ${port_HEADERS}) +- ++ set(LIBPORT_USED FALSE) + if(NOT HAVE_GETOPT) + list(APPEND port_USED_FILES getopt.c) ++ set(LIBPORT_USED TRUE) + endif() + if(NOT HAVE_LFIND) + list(APPEND port_USED_FILES lfind.c) ++ set(LIBPORT_USED TRUE) + endif() + if(MSVC AND NOT HAVE_SNPRINTF) + list(APPEND port_USED_FILES snprintf.c) ++ set(LIBPORT_USED TRUE) + endif() + if(NOT HAVE_STRCASECMP) + list(APPEND port_USED_FILES strcasecmp.c) ++ set(LIBPORT_USED TRUE) + endif() + if(NOT HAVE_STRTOUL) + list(APPEND port_USED_FILES strtoul.c) ++ set(LIBPORT_USED TRUE) + endif() + if(NOT HAVE_STRTOULL) + list(APPEND port_USED_FILES strtoull.c) ++ set(LIBPORT_USED TRUE) + endif() ++ ++# We set NEED_LIBPORT with PARENT_SCOPE ++# because it is used in libtiff/CMakeLists.txt ++set(NEED_LIBPORT ${LIBPORT_USED} PARENT_SCOPE) + + add_library(port STATIC ${port_USED_FILES}) + diff --git a/SuperBuild/patches/TIFF/tiff-1-noopengl-linux.diff b/SuperBuild/patches/TIFF/tiff-1-noopengl-linux.diff deleted file mode 100755 index 04b1ef4f181fe243c5d9413e76a129e57981689d..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/TIFF/tiff-1-noopengl-linux.diff +++ /dev/null @@ -1,38 +0,0 @@ -diff -burN tiff-4.0.6.orig/CMakeLists.txt tiff-4.0.6/CMakeLists.txt ---- tiff-4.0.6.orig/CMakeLists.txt 2016-10-27 17:24:17.000000000 +0200 -+++ tiff-4.0.6/CMakeLists.txt 2016-10-27 17:25:43.000000000 +0200 -@@ -602,19 +602,23 @@ - endif() - - # OpenGL and GLUT --find_package(OpenGL) --find_package(GLUT) --set(HAVE_OPENGL FALSE) --if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) -+option(WITH_OPENGL "Enable opengl and glut support" ON) -+ -+if(WITH_OPENGL) -+ find_package(OpenGL) -+ find_package(GLUT) -+ set(HAVE_OPENGL FALSE) -+ if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) - set(HAVE_OPENGL TRUE) -+ endif() -+ # Purely to satisfy the generated headers: -+ check_include_file(GL/gl.h HAVE_GL_GL_H) -+ check_include_file(GL/glu.h HAVE_GL_GLU_H) -+ check_include_file(GL/glut.h HAVE_GL_GLUT_H) -+ check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) -+ check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) -+ check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) - endif() --# Purely to satisfy the generated headers: --check_include_file(GL/gl.h HAVE_GL_GL_H) --check_include_file(GL/glu.h HAVE_GL_GLU_H) --check_include_file(GL/glut.h HAVE_GL_GLUT_H) --check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) --check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) --check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) - - # Win32 IO - set(win32_io FALSE) diff --git a/SuperBuild/patches/TIFF/tiff-1-noopengl-macx.diff b/SuperBuild/patches/TIFF/tiff-1-noopengl-macx.diff deleted file mode 100755 index 04b1ef4f181fe243c5d9413e76a129e57981689d..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/TIFF/tiff-1-noopengl-macx.diff +++ /dev/null @@ -1,38 +0,0 @@ -diff -burN tiff-4.0.6.orig/CMakeLists.txt tiff-4.0.6/CMakeLists.txt ---- tiff-4.0.6.orig/CMakeLists.txt 2016-10-27 17:24:17.000000000 +0200 -+++ tiff-4.0.6/CMakeLists.txt 2016-10-27 17:25:43.000000000 +0200 -@@ -602,19 +602,23 @@ - endif() - - # OpenGL and GLUT --find_package(OpenGL) --find_package(GLUT) --set(HAVE_OPENGL FALSE) --if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) -+option(WITH_OPENGL "Enable opengl and glut support" ON) -+ -+if(WITH_OPENGL) -+ find_package(OpenGL) -+ find_package(GLUT) -+ set(HAVE_OPENGL FALSE) -+ if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) - set(HAVE_OPENGL TRUE) -+ endif() -+ # Purely to satisfy the generated headers: -+ check_include_file(GL/gl.h HAVE_GL_GL_H) -+ check_include_file(GL/glu.h HAVE_GL_GLU_H) -+ check_include_file(GL/glut.h HAVE_GL_GLUT_H) -+ check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) -+ check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) -+ check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) - endif() --# Purely to satisfy the generated headers: --check_include_file(GL/gl.h HAVE_GL_GL_H) --check_include_file(GL/glu.h HAVE_GL_GLU_H) --check_include_file(GL/glut.h HAVE_GL_GLUT_H) --check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) --check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) --check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) - - # Win32 IO - set(win32_io FALSE) diff --git a/Utilities/Maintenance/SuperbuildDownloadList.sh b/Utilities/Maintenance/SuperbuildDownloadList.sh index 6b09c62d4173125b529c295ed58ebea2bda67d7e..d7bd8c493517194cf2ef22accbc6b0e4565d3291 100755 --- a/Utilities/Maintenance/SuperbuildDownloadList.sh +++ b/Utilities/Maintenance/SuperbuildDownloadList.sh @@ -20,77 +20,62 @@ # -export LC_ALL=C -if [ $# -eq 2 ]; then -DOWNLOAD_DIR=$(readlink -f $1) -OUTPUT_DIR=$(readlink -f $2) -else -echo 'Usage: '$0' <download_directory> <archive_output_directory>' -exit 1 + +if [ $# -lt 2 ]; then + echo "Usage: $0 <download_directory> <archive_output_directory>" + exit 1 fi -WGET="wget -nv -q" +export LC_ALL=C -SB_CMAKE_DIR_REL=$(dirname $0)/../../SuperBuild/CMake -SB_CMAKE_DIR=$(readlink -f ${SB_CMAKE_DIR_REL}) +DOWNLOAD_DIR=$(readlink -f "$1") +OUTPUT_DIR=$(readlink -f "$2") +WGET=$(which wget) -cd $(dirname $0)/../../ -GIT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') +CUR_DIR="$( cd "$( dirname "$0" )" && pwd )" +SB_CMAKE_DIR_REL=$CUR_DIR/../../SuperBuild/CMake +SB_CMAKE_DIR=$(readlink -f "${SB_CMAKE_DIR_REL}") +cd "$CUR_DIR/../../" || echo "cannot cd to CUR_DIR/../../" +GIT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') #if a branch contains release-X.Y then xdk is taken from packages/xdk/OTB-X.Y if [[ "$GIT_BRANCH" =~ release-* ]]; then - VERSION=$(echo ${GIT_BRANCH}| sed 's/.*release-//'| cut -d'-' -f 1) + VERSION=$(echo "${GIT_BRANCH}"| sed 's/.*release-//'| cut -d'-' -f 1) else VERSION="develop" fi -DOWNLOAD_LIST=$(grep -h -E "^[^#]*\"https?://.*(\.tar\.gz|\.tar\.bz2|\.tgz|\.tar\.xz|\.zip|export=download).*\"" ${SB_CMAKE_DIR}/*.cmake | grep -o -E "https?://[^\"]*" | sed "s/\/\(download\)\?$//" | sort | uniq) +CMAKE_FILES=$(find $SB_CMAKE_DIR -maxdepth 1 -type f -name "External_*") +DOWNLOAD_LIST=$(grep -h -E '^[^#]*\"https?://.*(\.tar\.gz|\.tar\.bz2|\.tgz|\.tar\.xz|\.zip|export=download).*\"' ${CMAKE_FILES} | + grep -o -E 'https?://[^\"]*' | sort | uniq) DOWNLOAD_NAMES= -mkdir -p ${DOWNLOAD_DIR} -cd ${DOWNLOAD_DIR} +#echo "DOWNLOAD_LIST=$DOWNLOAD_LIST" +mkdir -p "${DOWNLOAD_DIR}" +cd "${DOWNLOAD_DIR}" || echo "cannot cd to DOWNLOAD_DIR" echo "Downloading files to ${DOWNLOAD_DIR}/" - for url in ${DOWNLOAD_LIST}; do - # clean log file - - file_name=$(echo "${url}" | grep -o -E "[^\/]+$") - docs_google=$(echo "${file_name}" | grep -F "export=download") - if [ "${docs_google}" = "" ]; then - if [ -f "$file_name" ]; then - echo "$file_name exists, skipping" - fi; - $WGET -N ${url} - ret="$?" - if [ $ret -gt 0 -a $ret -ne 8 ]; then - echo "Download failed for URL: '${url}'. wget finished with exit status '$ret'." - exit 1; - fi - else - # look into the original file for a valid download name - file_name=$(grep -h -A 3 -B 3 -F "${url}" ${SB_CMAKE_DIR}/*.cmake | grep -E "^[^#]*DOWNLOAD_NAME" | grep -o -E "[^ ]*\.(tar\.gz|tar\.bz2|tar\.xz|zip)" | uniq) - if [ -z "$file_name" ]; then - echo "Can't find correct filename for url ${url} : skip download" - exit 1; - else - # echo "Download ${file_name}..." - $WGET ${url} -O ${file_name} - fi + file_name=$(echo "${url}" | grep -o -E '[^\/]+$') + $WGET -N "${url}" + ret="$?" + if [ $ret -gt 0 ] && [ $ret -ne 8 ]; then + echo "Download failed for URL: '${url}'. wget finished with exit status '$ret'." + exit 1; fi if [ "$file_name" != "" ]; then - DOWNLOAD_NAMES="${DOWNLOAD_NAMES} ${file_name}" + DOWNLOAD_NAMES="${DOWNLOAD_NAMES} ${file_name}" + else + echo "invalid filename for url=${url}" && exit 1; fi - done ARCHIVE_NAME="SuperBuild-archives-$VERSION" echo "Creating archive ${OUTPUT_DIR}/$ARCHIVE_NAME.tar.bz2" - -cd ${OUTPUT_DIR} -tar -cjf $ARCHIVE_NAME.tar.bz2 -C ${DOWNLOAD_DIR} ${DOWNLOAD_NAMES} - +cd "${OUTPUT_DIR}" || echo "cannot cd to OUTPUT_DIR" +touch "${DOWNLOAD_DIR}/OTBSuperBuild.readme" +tar -cjf "$ARCHIVE_NAME.tar.bz2" -C "${DOWNLOAD_DIR}" ${DOWNLOAD_NAMES} OTBSuperBuild.readme echo "Saving md5sum to ${OUTPUT_DIR}/$ARCHIVE_NAME.md5" -md5sum $ARCHIVE_NAME.tar.bz2 > $ARCHIVE_NAME.md5 +md5sum "$ARCHIVE_NAME.tar.bz2" > "$ARCHIVE_NAME.md5"