Commit 53e66458 authored by Cédric Traizet's avatar Cédric Traizet

Merge branch 'develop' into upgrade_gdal_superbuild

parents fa0ba183 b300873c
Pipeline #1778 canceled with stages
in 29 minutes and 47 seconds
......@@ -71,8 +71,7 @@ if(XDK_PATH)
set(cmake_configure_option
"${cmake_configure_option}
CMAKE_PREFIX_PATH=${XDK_PATH}")
# DiapOTBModule disabled until documentation can build it
foreach(remote_module OTBTemporalGapFilling Mosaic SertitObject)#otbGRM #Mosaic # #SertitObject #DiapOTBModule
foreach(remote_module OTBTemporalGapFilling Mosaic SertitObject DiapOTBModule)#otbGRM
set(cmake_configure_option
"${cmake_configure_option}
Module_${remote_module}:BOOL=ON")
......
......@@ -45,3 +45,4 @@ set( CTEST_ENVIRONMENT
# PROJ_LIB= PROJ_LIB
include( "${CMAKE_CURRENT_LIST_DIR}/main_ci.cmake" )
......@@ -24,8 +24,7 @@ set ( cmake_configure_option
CMAKE_INSTALL_PREFIX:PATH=${CTEST_INSTALL_DIRECTORY}")
set ( temporary_option
"OTB_USE_LIBKML=OFF
OTB_USE_MPI=OFF")
"OTB_USE_MPI=OFF")
set(concat_options
"${cmake_configure_option}
......
......@@ -117,7 +117,7 @@ find_package ( PythonLibs )
# Configure the default OTB_DATA_ROOT for the location of OTB Data.
find_path(OTB_DATA_ROOT
NAMES README-OTB-Data
HINTS ${OTB_SOURCE_DIR}/Data $ENV{OTB_DATA_ROOT}
HINTS ${OTB_SOURCE_DIR}/Data
)
#mark_as_advanced(OTB_DATA_ROOT)
......
PROJCS["UTM Zone 31, Northern Hemisphere",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
Forward projection:
[1.44, 43.605] -> [374100.828760369, 4829184.80636283]
PROJCS["UTM Zone 31, Northern Hemisphere",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
Inverse projection:
[374100.8, 4829184.8] -> [1.43999964524438, 43.6049999378673]
PROJCS["WGS 84 / UTM zone 31N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32631"]]
Forward projection:
[1.44, 43.605] -> [374100.828760369, 4829184.80636283]
PROJCS["WGS 84 / UTM zone 31N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32631"]]
Inverse projection:
[374100.8, 4829184.8] -> [1.43999964524438, 43.6049999378673]
PROJCS["UTM Zone 31, Northern Hemisphere",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AXIS["Lat",NORTH],AXIS["Long",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
Forward projection:
[1.44, 43.605] -> [374100.8287608, 4829184.80641377]
PROJCS["UTM Zone 31, Northern Hemisphere",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AXIS["Lat",NORTH],AXIS["Long",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
Inverse projection:
[374100.8, 4829184.8] -> [1.439999645251, 43.6049999374087]
ProjRef: GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AXIS["Latitude",NORTH],
AXIS["Longitude",EAST],
AUTHORITY["EPSG","4326"]]
Origin: [1943.5, 2364.5]
Spacing: [1, 1]
......@@ -29,7 +29,7 @@ register two images. This process can be easily extended to perform
image series registration.
The aim of this example is to describe how to register a Level 1
QuickBird image over an orthorectify Pleiades image over the area of
QuickBird image over an orthorectified Pleiades image over the area of
Toulouse, France.
|image1| |image2|
......@@ -40,35 +40,30 @@ Extract metadata from the image reference
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We first dump geometry metadata of the image we want to refine in a text
file. In OTB, we use the extension *.geom* for this type of file. As you
will see the application which will estimate a refine geometry only
file. In OTB, we use the extension *.geom* for this type of file.
The application to estimate a refined geometry only
needs as input this metadata and a set of homologous points. The
refinement application will create a new *.geom* file containing refined
geometry parameters which can be used after for reprojection for
example.
The use of external *.geom* file is available in OTB since release
:math:`3.16`. See
`here <http://wiki.orfeo-toolbox.org/index.php/ExtendedFileName>`__ for
more information.
External *.geom* files can also be used with :ref:`extended filenames<extended-filenames>`.
::
otbcli_ReadImageInfo -in slave_image
-outkwl TheGeom.geom
otbcli_ReadImageInfo -in slave_image
-outkwl TheGeom.geom
Extract homologous points from images
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The main idea of the residual registration is to estimate an second
The main idea of the residual registration is to estimate a second
transformation (after the application of sensors model).
The homologous point application uses an interest point detection method to
get a set of points with matches in both images.
The homologous point application use interest point detection method to
get a set of point which match in both images.
The basic idea is to use this set of homologous points and estimate with
them a residual transformation between the two images.
The basic idea is to use this set of homologous points to estimate
a residual transformation between the two images.
There is a wide variety of keypoint detectors in the literature, and they
allow for the detection and description of local features in images. These algorithms
......
......@@ -21,6 +21,7 @@
#define otbSpatialReference_h
#include "OTBGdalAdaptersExport.h"
#include "ogr_spatialref.h"
#include <memory>
#include <string>
......@@ -150,6 +151,14 @@ public:
*/
unsigned int ToEPSG() const;
#if GDAL_VERSION_NUM >= 3000000
/** Set the Axis mapping strategy
* proxy to the eponym ogr spatial reference method
* \param strategy Axis mapping stategy
*/
void SetAxisMappingStrategy(OSRAxisMappingStrategy strategy);
#endif
/**
* Find which UTM zone a given (lat,lon) point falls in.
* \pre -180<=lon<=180
......
......@@ -291,4 +291,12 @@ void SpatialReference::UTMFromGeoPoint(double lon, double lat, unsigned int & zo
// post conditions
assert(zone<=60);
}
#if GDAL_VERSION_NUM >= 3000000
void SpatialReference::SetAxisMappingStrategy(OSRAxisMappingStrategy strategy)
{
m_SR.get()->SetAxisMappingStrategy(strategy);
};
#endif
}
......@@ -70,6 +70,11 @@ GenericMapProjection<TDirectionOfMapping, TScalarType, NInputDimensions, NOutput
SpatialReference wgs84 = SpatialReference::FromWGS84();
SpatialReference wktSpatialReference = SpatialReference::FromDescription(projectionRefWkt);
#if GDAL_VERSION_NUM >= 3000000
wgs84.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
wktSpatialReference.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
#endif
if(DirectionOfMapping == TransformDirection::INVERSE)
{
std::unique_ptr<CoordinateTransformation> newMapProjection(new CoordinateTransformation(wktSpatialReference,wgs84));
......
......@@ -23,7 +23,7 @@
#include <iomanip>
#include "otbGenericMapProjection.h"
#include "ogr_spatialref.h"
int otbGenericMapProjection(int itkNotUsed(argc), char* argv[])
{
const char * outFileName = argv[1];
......@@ -35,11 +35,19 @@ int otbGenericMapProjection(int itkNotUsed(argc), char* argv[])
/** Test the ability to instantiate a projection from a string*/
std::string projectionRefWkt =
"PROJCS[\"UTM Zone 31, Northern Hemisphere\", GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\",\"9108\"]], AXIS[\"Lat\", NORTH], AXIS[\"Long\", EAST], AUTHORITY[\"EPSG\",\"4326\"]], PROJECTION[\"Transverse_Mercator\"], PARAMETER[\"latitude_of_origin\", 0], PARAMETER[\"central_meridian\", 3], PARAMETER[\"scale_factor\", 0.9996], PARAMETER[\"false_easting\", 500000], PARAMETER[\"false_northing\", 0], UNIT[\"Meter\", 1]]";
auto baselineSpatialReference = otb::SpatialReference::FromDescription(projectionRefWkt);
typedef otb::GenericMapProjection<otb::TransformDirection::FORWARD> GenericMapProjection;
GenericMapProjection::Pointer genericMapProjection = GenericMapProjection::New();
genericMapProjection->SetWkt(projectionRefWkt);
file << genericMapProjection->GetWkt() << std::endl << std::endl;
auto testSpatialReferenceForward = otb::SpatialReference::FromDescription(genericMapProjection->GetWkt());
if (testSpatialReferenceForward!=baselineSpatialReference)
{
std::cerr << "The spatial reference used in the forward test is different from the input spatial reference" << std::endl;
return EXIT_FAILURE;
}
itk::Point<double, 2> point;
point[0] = 1.44;
......@@ -52,7 +60,14 @@ int otbGenericMapProjection(int itkNotUsed(argc), char* argv[])
typedef otb::GenericMapProjection<otb::TransformDirection::INVERSE> GenericMapProjectionInverse;
GenericMapProjectionInverse::Pointer genericMapProjectionInverse = GenericMapProjectionInverse::New();
genericMapProjectionInverse->SetWkt(projectionRefWkt);
file << genericMapProjectionInverse->GetWkt() << std::endl << std::endl;
auto testSpatialReferenceReverse = otb::SpatialReference::FromDescription(genericMapProjectionInverse->GetWkt());
if (testSpatialReferenceForward!=baselineSpatialReference)
{
std::cerr << "The spatial reference used in the reverse test is different from the input spatial reference" << std::endl;
return EXIT_FAILURE;
}
point[0] = 374100.8;
point[1] = 4829184.8;
......
......@@ -828,9 +828,13 @@ unsigned int OGRIOHelper
// Get the key of the Nth OGRFieldRefn
const char * key = kwl.GetNthField(i).first->GetNameRef();
// Edit the value of the field and add it to the current feature
int fIndex = ogrFeature->GetFieldIndex(key);
if (fIndex >= 0)
ogrFeature->SetField(fIndex , kwl.GetFieldAsString(key).c_str());
if (std::string(key) != "FID")
{
int fIndex = ogrFeature->GetFieldIndex(key);
if (fIndex >= 0)
ogrFeature->SetField(fIndex , kwl.GetFieldAsString(key).c_str());
}
}
// ogrFeature->SetField("Name", dataNode->GetNodeId());
......@@ -916,10 +920,13 @@ unsigned int OGRIOHelper
const char * key = kwl.GetNthField(i).first->GetNameRef();
// Edit the value of the field and add it to the current feature
int fIndex = ogrFeature->GetFieldIndex(key);
if (fIndex >= 0)
ogrFeature->SetField(fIndex , kwl.GetFieldAsString(key).c_str());
if (std::string(key) != "FID")
{
if (fIndex >= 0)
ogrFeature->SetField(fIndex , kwl.GetFieldAsString(key).c_str());
}
}
ogrFeature->SetGeometry(ogrPolygon);
if (ogrCurrentLayer->CreateFeature(ogrFeature) != OGRERR_NONE)
......@@ -1049,7 +1056,6 @@ std::vector<OGRLayer*> OGRIOHelper
GDT_Unknown,
0);
}
std::vector<OGRLayer*> ogrLayerVector;
//unsigned int kept = 0;
bool fieldsAddedToOGRLayer = false;
......@@ -1188,7 +1194,12 @@ std::vector<OGRLayer*> OGRIOHelper
// Get the key of the Nth OGRFieldRefn
const char * key = kwl.GetNthField(i).first->GetNameRef();
// Edit the value of the field and add it to the current feature
ogrFeature->SetField(ogrFeature->GetFieldIndex(key) , kwl.GetFieldAsString(key).c_str());
if (std::string(key) != "FID")
{
// Edit the value of the field and add it to the current feature
ogrFeature->SetField(ogrFeature->GetFieldIndex(key) , kwl.GetFieldAsString(key).c_str());
}
}
ogrFeature->SetGeometry(&ogrLine);
......@@ -1259,8 +1270,11 @@ std::vector<OGRLayer*> OGRIOHelper
{
// Get the key of the Nth OGRFieldRefn
const char * key = kwl.GetNthField(i).first->GetNameRef();
// Edit the value of the field and add it to the current feature
ogrFeature->SetField(ogrFeature->GetFieldIndex(key) , kwl.GetFieldAsString(key).c_str());
if (std::string(key) != "FID")
{
// Edit the value of the field and add it to the current feature
ogrFeature->SetField(ogrFeature->GetFieldIndex(key) , kwl.GetFieldAsString(key).c_str());
}
}
ogrFeature->SetGeometry(ogrPolygon);
......
......@@ -289,6 +289,9 @@ void OGRVectorDataIO::Write(const itk::DataObject* datag, char ** /** unused */)
if (projectionInformationAvailable)
{
oSRS = static_cast<OGRSpatialReference *>(OSRNewSpatialReference(projectionRefWkt.c_str()));
#if GDAL_VERSION_NUM >= 3000000
oSRS->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
#endif
}
// Retrieving root node
......
......@@ -2613,26 +2613,37 @@ void TestHelper::ogrReportOnLayer(OGRLayer * ref_poLayer,
CheckValueTolerance("Extent: MaxX", ref_oExt.MaxX, test_oExt.MaxX, nbdiff, m_ReportErrors, epsilon);
CheckValueTolerance("Extent: MaxY", ref_oExt.MaxY, test_oExt.MaxY, nbdiff, m_ReportErrors, epsilon);
}
/// Spatial reference comparison :
/// We use the IsSame GDAL method to determine if the spatial references are equivalent,
/// if they're not, a wkt string comparison is done for error reporting.
/// Note that two spatial references might be equivalent without having the same
/// wkt representation.
if ((ref_poLayer->GetSpatialRef() == nullptr) ||
(test_poLayer->GetSpatialRef() == nullptr) ||
( ! ref_poLayer->GetSpatialRef()->IsSame( test_poLayer->GetSpatialRef() ) ))
{
char *ref_pszWKT;
char *test_pszWKT;
char *ref_pszWKT;
char *test_pszWKT;
if (ref_poLayer->GetSpatialRef() == nullptr) ref_pszWKT = CPLStrdup("(unknown)");
else
{
ref_poLayer->GetSpatialRef()->exportToPrettyWkt(&ref_pszWKT);
}
if (test_poLayer->GetSpatialRef() == nullptr) test_pszWKT = CPLStrdup("(unknown)");
else
{
test_poLayer->GetSpatialRef()->exportToPrettyWkt(&test_pszWKT);
}
otbCheckStringValue("Layer SRS WKT", ref_pszWKT, test_pszWKT, nbdiff, m_ReportErrors);
CPLFree(ref_pszWKT);
CPLFree(test_pszWKT);
if (ref_poLayer->GetSpatialRef() == nullptr) ref_pszWKT = CPLStrdup("(unknown)");
else
{
ref_poLayer->GetSpatialRef()->exportToPrettyWkt(&ref_pszWKT);
}
if (test_poLayer->GetSpatialRef() == nullptr) test_pszWKT = CPLStrdup("(unknown)");
else
{
test_poLayer->GetSpatialRef()->exportToPrettyWkt(&test_pszWKT);
}
otbCheckStringValue("Layer SRS WKT", ref_pszWKT, test_pszWKT, nbdiff, m_ReportErrors);
CPLFree(ref_pszWKT);
CPLFree(test_pszWKT);
}
otbCheckStringValue("FID Column", ref_poLayer->GetFIDColumn(), test_poLayer->GetFIDColumn(), nbdiff, m_ReportErrors);
otbCheckStringValue("Geometry Column", ref_poLayer->GetGeometryColumn(),
test_poLayer->GetGeometryColumn(), nbdiff, m_ReportErrors);
......
......@@ -128,9 +128,16 @@ PersistentImageSampleExtractorFilter<TInputImage>
if(projectionInformationAvailable)
{
OGRSpatialReference imgSRS;
#if GDAL_VERSION_NUM >= 3000000 // importFromWkt is const-correct in GDAL 3
const char *projWktCstr = projectionRefWkt.c_str();
OGRErr err = imgSRS.importFromWkt( &projWktCstr );
#else
const char *projWktCstr = projectionRefWkt.c_str();
char **projWktPointer = const_cast<char**>(&projWktCstr);
OGRErr err = imgSRS.importFromWkt( projWktPointer );
#endif
if (err == OGRERR_NONE)
{
// get input layer
......
......@@ -335,7 +335,11 @@ void Multi3DMapToDEMFilter<T3DImage, TMaskImage, TOutputDEMImage>::GenerateOutpu
if (!m_ProjectionRef.empty())
{
OGRSpatialReference oSRS;
#if GDAL_VERSION_NUM >= 3000000 // importFromWkt is const-correct in GDAL 3
const char *wkt = m_ProjectionRef.c_str();
#else
char *wkt = const_cast<char *> (m_ProjectionRef.c_str());
#endif
oSRS.importFromWkt(&wkt);
m_IsGeographic = oSRS.IsGeographic(); // TODO check if this test is valid for all projection systems
}
......
......@@ -34,8 +34,8 @@ ADD_SUPERBUILD_CMAKE_VAR(LIBKML Boost_INCLUDE_DIR)
ExternalProject_Add(LIBKML
PREFIX LIBKML
URL "http://ftp.de.debian.org/debian/pool/main/libk/libkml/libkml_1.3.0~r863.orig.tar.gz"
URL_MD5 211ed5fdf2dd45aeb9c0abc8e1fe42be
URL "http://ftp.de.debian.org/debian/pool/main/libk/libkml/libkml_1.3.0~r864+dfsg.orig.tar.gz"
URL_MD5 487e3c8dd1ad03551e361ab6a1b4e083
BINARY_DIR ${LIBKML_SB_BUILD_DIR}
INSTALL_DIR ${SB_INSTALL_PREFIX}
DOWNLOAD_DIR ${DOWNLOAD_LOCATION}
......
......@@ -346,10 +346,10 @@ option(OTB_USE_MPI "Enable MPI in OTB" OFF)
option(OTB_USE_SPTW "Enable Simple Parallel Tiff Writer in OTB" OFF)
# 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)
find_path(OTB_DATA_ROOT
NAMES README-OTB-Data
HINTS ${OTB-SuperBuild_SOURCE_DIR}/../Data
)
# SWIG Wrapping
option(OTB_WRAP_PYTHON "Enable python wrappers for OTB applications (requires SWIG)" ON)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment