Commit b8f5ab2b authored by Cédric Traizet's avatar Cédric Traizet

COMP: added retro compatibility for gdal 2

parent 363a9fb3
Pipeline #1640 passed with stage
in 10 minutes and 39 seconds
......@@ -151,8 +151,13 @@ 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.
......
......@@ -292,11 +292,11 @@ void SpatialReference::UTMFromGeoPoint(double lon, double lat, unsigned int & zo
assert(zone<=60);
}
#if GDAL_VERSION_NUM >= 3000000
void SpatialReference::SetAxisMappingStrategy(OSRAxisMappingStrategy strategy)
{
m_SR.get()->SetAxisMappingStrategy(strategy);
};
#endif
}
......@@ -70,8 +70,10 @@ 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)
{
......
......@@ -128,8 +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 );
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
}
......
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