Commit 5cd447b7 authored by Cédric Traizet's avatar Cédric Traizet

ENH: remove checks for gdal version 1.8 or 1.9, as support for gdal 1.X will be dropped

parent c20fd869
......@@ -727,12 +727,7 @@ OGREnvelope otb::ogr::DataSource::GetGlobalExtent(bool force/* = false */, std::
cExtent.MaxX = real_maxx;
cExtent.MaxY = real_maxy;
#if GDAL_VERSION_NUM >= 1700
OGRCoordinateTransformation::DestroyCT(coordTransformation);
#else
#warning the following resource release may crash, please update your version of GDAL
delete coordTransformation; // note there is no garanty
#endif
}
// else: If srs are invalid, we assume that extent are coherent
......
......@@ -78,16 +78,11 @@ void otb::ogr::Feature::UncheckedSetFrom(Feature const& rhs, bool mustForgive)
void otb::ogr::Feature::UncheckedSetFrom(Feature const& rhs, int * map, bool mustForgive)
{
#if GDAL_VERSION_NUM >= 1900
const OGRErr res = m_Feature->SetFrom(&rhs.ogr(), map, mustForgive);
if (res != OGRERR_NONE)
{
itkGenericExceptionMacro(<<"Cannot assign from another feature: " << CPLGetLastErrorMsg());
}
#else
itkGenericExceptionMacro("OGRLayer::SetFrom(feature, fieldmap, forgive) is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.9.0, and recompile OTB.")
#endif
}
/*===========================================================================*/
......
......@@ -25,10 +25,6 @@
#include "otbOGRGeometryWrapper.h"
#include "ogr_geometry.h"
#if GDAL_VERSION_NUM < 1900
# include "itkMacro.h"
#endif
#ifdef _MSC_VER
// warning conversion int -> bool
#pragma warning ( disable : 4800 )
......@@ -105,12 +101,7 @@ otb::ogr::UniqueGeometryPtr otb::ogr::Union(OGRGeometry const& lhs, OGRGeometry
otb::ogr::UniqueGeometryPtr otb::ogr::UnionCascaded(OGRGeometry const& this_)
{
#if GDAL_VERSION_NUM >= 1800
return UniqueGeometryPtr(this_.UnionCascaded());
#else
itkGenericExceptionMacro("OGRGeometry::UnionCascaded is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.8.0, and recompile OTB.");
#endif
}
otb::ogr::UniqueGeometryPtr otb::ogr::Difference(OGRGeometry const& lhs, OGRGeometry const& rhs)
......@@ -120,41 +111,20 @@ otb::ogr::UniqueGeometryPtr otb::ogr::Difference(OGRGeometry const& lhs, OGRGeom
otb::ogr::UniqueGeometryPtr otb::ogr::SymDifference(OGRGeometry const& lhs, OGRGeometry const& rhs)
{
#if GDAL_VERSION_NUM >= 1800
return UniqueGeometryPtr(lhs.SymDifference(&rhs));
#else
return UniqueGeometryPtr(lhs.SymmetricDifference(&rhs));
#endif
}
otb::ogr::UniqueGeometryPtr otb::ogr::SimplifyDontPreserveTopology(OGRGeometry const& g, double tolerance)
{
#if GDAL_VERSION_NUM >= 1800
return UniqueGeometryPtr(g.Simplify(tolerance));
#else
itkGenericExceptionMacro("OGRGeometry::Simplify is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.8.0, and recompile OTB.");
#endif
}
otb::ogr::UniqueGeometryPtr otb::ogr::SimplifyPreserveTopology(OGRGeometry const& g, double tolerance)
{
#if GDAL_VERSION_NUM >= 1900
return UniqueGeometryPtr(g.SimplifyPreserveTopology(tolerance));
#else
itkGenericExceptionMacro("OGRGeometry::Simplify is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.9.0, and recompile OTB.");
#endif
}
otb::ogr::UniqueGeometryPtr otb::ogr::Simplify(OGRGeometry const& g, double tolerance)
{
#if GDAL_VERSION_NUM >= 1900
return UniqueGeometryPtr(g.SimplifyPreserveTopology(tolerance));
#elif GDAL_VERSION_NUM >= 1800
return UniqueGeometryPtr(g.Simplify(tolerance));
#else
itkGenericExceptionMacro("OGRGeometry::Simplify(PreserveTopology) is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.9.0, and recompile OTB.");
#endif
}
......@@ -192,11 +192,7 @@ void otb::ogr::Layer::SetFeature(Feature feature)
std::string otb::ogr::Layer::GetName() const
{
assert(m_Layer && "null layer");
#if GDAL_VERSION_NUM >= 1800
return m_Layer->GetName();
#else
return GetLayerDefn().GetName();
#endif
}
OGREnvelope otb::ogr::Layer::GetExtent(bool force/* = false */) const
......@@ -339,17 +335,12 @@ void otb::ogr::Layer::DeleteField(int fieldIndex)
<<GetName()<<">: layer is not modifiable");
}
#if GDAL_VERSION_NUM < 1900
itkGenericExceptionMacro("OGRLayer::DeleteField is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.9.0, and recompile OTB.")
#else
const OGRErr res = m_Layer->DeleteField(fieldIndex);
if (res != OGRERR_NONE)
{
itkGenericExceptionMacro(<< "Cannot delete the "<<fieldIndex << "th field in the layer <"
<<GetName() <<">: " << CPLGetLastErrorMsg());
}
#endif
}
void otb::ogr::Layer::AlterFieldDefn(
......@@ -363,10 +354,6 @@ void otb::ogr::Layer::AlterFieldDefn(
<<GetName()<<">: layer is not modifiable");
}
#if GDAL_VERSION_NUM < 1900
itkGenericExceptionMacro("OGRLayer::AlterFieldDefn is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.9.0, and recompile OTB.")
#else
const OGRErr res = m_Layer->AlterFieldDefn(
int(fieldIndex),
&newFieldDefn.ogr(),
......@@ -376,7 +363,6 @@ void otb::ogr::Layer::AlterFieldDefn(
itkGenericExceptionMacro(<< "Cannot alter the "<<fieldIndex << "th field in the layer <"
<<GetName() <<">: " << CPLGetLastErrorMsg());
}
#endif
}
void otb::ogr::Layer::ReorderField(size_t oldPos, size_t newPos)
......@@ -389,17 +375,12 @@ void otb::ogr::Layer::ReorderField(size_t oldPos, size_t newPos)
<<GetName()<<">: layer is not modifiable");
}
#if GDAL_VERSION_NUM < 1900
itkGenericExceptionMacro("OGRLayer::ReorderField is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.9.0, and recompile OTB.")
#else
const OGRErr res = m_Layer->ReorderField(int(oldPos), int(newPos));
if (res != OGRERR_NONE)
{
itkGenericExceptionMacro(<< "Cannot move the "<<oldPos << "th field to the "
<< newPos << "th position in the layer <" <<GetName() <<">: " << CPLGetLastErrorMsg());
}
#endif
}
void otb::ogr::Layer::ReorderFields(int * map)
......@@ -412,42 +393,28 @@ void otb::ogr::Layer::ReorderFields(int * map)
<<GetName()<<">: layer is not modifiable");
}
#if GDAL_VERSION_NUM < 1900
itkGenericExceptionMacro("OGRLayer::ReorderField is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.9.0, and recompile OTB.")
#else
const OGRErr res = m_Layer->ReorderFields(map);
if (res != OGRERR_NONE)
{
itkGenericExceptionMacro(<< "Cannot reorder the fields of the layer <"
<<GetName() <<">: " << CPLGetLastErrorMsg());
}
#endif
}
void otb::ogr::Layer::SetIgnoredFields(char const** fieldNames)
{
assert(m_Layer && "OGRLayer not initialized");
#if GDAL_VERSION_NUM >= 1900
const OGRErr res = m_Layer->SetIgnoredFields(fieldNames);
if (res != OGRERR_NONE)
{
itkGenericExceptionMacro(<< "Cannot set fields to ignore on the layer <"
<<GetName() <<">: " << CPLGetLastErrorMsg());
}
#else
itkGenericExceptionMacro("OGRLayer::SetIgnoredFields is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.9.0, and recompile OTB.")
#endif
}
OGRwkbGeometryType otb::ogr::Layer::GetGeomType() const
{
assert(m_Layer && "OGRLayer not initialized");
#if GDAL_VERSION_NUM < 1800
return GetLayerDefn().GetGeomType();
#else
return m_Layer->GetGeomType();
#endif
}
......@@ -681,7 +681,6 @@ BOOST_AUTO_TEST_CASE(Add_n_Del_Fields)
BOOST_CHECK_EQUAL(defn.GetFieldDefn(6), (void*)nullptr);
}
#if GDAL_VERSION_NUM >= 1900
l.DeleteField(1);
BOOST_CHECK_EQUAL(defn.GetFieldCount(), 5);
......@@ -697,7 +696,6 @@ BOOST_AUTO_TEST_CASE(Add_n_Del_Fields)
ogr::FieldDefn f4(*defn.GetFieldDefn(4));
BOOST_CHECK_EQUAL(f4, k_f5);
}
#endif
// todo: add reoder tests
}
......@@ -725,9 +723,7 @@ BOOST_AUTO_TEST_CASE(Add_n_Read_Fields)
// ----[ int
ogr::Field f0 = g0[0];
#if GDAL_VERSION_NUM >= 1800
BOOST_CHECK_EQUAL(f0.GetName(), k_f0.GetName());
#endif
f0.SetValue(42);
BOOST_ASSERT(f0.HasBeenSet());
BOOST_CHECK_EQUAL(f0.GetValue<int>(), 42);
......@@ -737,9 +733,7 @@ BOOST_AUTO_TEST_CASE(Add_n_Read_Fields)
// ----[ double
ogr::Field f1 = g0["OFTReal"];
#if GDAL_VERSION_NUM >= 1800
BOOST_CHECK_EQUAL(f1.GetName(), k_f1.GetName());
#endif
// f1.SetValue(42); // need to support types promotion
f1.SetValue(42.0); // need to support types promotion
BOOST_ASSERT(f1.HasBeenSet());
......@@ -747,9 +741,7 @@ BOOST_AUTO_TEST_CASE(Add_n_Read_Fields)
// ----[ string
ogr::Field f2 = g0["OFTString"];
#if GDAL_VERSION_NUM >= 1800
BOOST_CHECK_EQUAL(f2.GetName(), k_f2.GetName());
#endif
f2.SetValue(("foobar")); // need to support types promotion
BOOST_ASSERT(f2.HasBeenSet());
BOOST_CHECK_EQUAL(f2.GetValue<std::string>(), "foobar");
......
......@@ -24,10 +24,6 @@
#include "otbOGRDataSourceWrapper.h"
#include "otbMacro.h"
//#if(GDAL_VERSION_NUM < 1800)
//#error OGRLayerStreamStitchingFilter requires GDAL version >= 1.8.0
//#endif
#include "itkProgressReporter.h"
#include <algorithm>
......
......@@ -291,12 +291,8 @@ OGRLayerStreamStitchingFilter<TInputImage>
}
else if (intersection->getGeometryType() == wkbMultiLineString)
{
#if(GDAL_VERSION_NUM < 1800)
fusion.overlap = GetLengthOGRGeometryCollection(dynamic_cast<OGRGeometryCollection *> (intersection.get()));
#else
fusion.overlap = dynamic_cast<OGRMultiLineString *>(intersection.get())->get_Length();
#endif
}
}
/** -Wunused-variable
long upperFID = upper.feat.GetFID();
......
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