Skip to content

Commit a7300f7

Browse files
authored
Add support for GDAL 3.6.0 (fixes #12) (#13)
1 parent e7e07b0 commit a7300f7

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

grass.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,15 @@ class GRASSDataset final: public GDALDataset
9595

9696
struct Cell_head sCellInfo; /* raster region */
9797

98-
char *pszProjection;
98+
OGRSpatialReference m_oSRS{};
9999

100100
double adfGeoTransform[6];
101101

102102
public:
103103
GRASSDataset();
104104
~GRASSDataset() override;
105105

106-
const char *_GetProjectionRef(void) override;
107-
const OGRSpatialReference* GetSpatialRef() const override {
108-
return GetSpatialRefFromOldGetProjectionRef();
109-
}
106+
const OGRSpatialReference* GetSpatialRef() const override;
110107
CPLErr GetGeoTransform( double * ) override;
111108

112109
static GDALDataset *Open( GDALOpenInfo * );
@@ -718,7 +715,7 @@ double GRASSRasterBand::GetNoDataValue( int *pbSuccess )
718715

719716
GRASSDataset::GRASSDataset()
720717
{
721-
pszProjection = NULL;
718+
m_oSRS.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
722719

723720
adfGeoTransform[0] = 0.0;
724721
adfGeoTransform[1] = 1.0;
@@ -746,20 +743,15 @@ GRASSDataset::~GRASSDataset()
746743

747744
if ( pszElement )
748745
G_free ( pszElement );
749-
750-
G_free( pszProjection );
751746
}
752747

753748
/************************************************************************/
754-
/* GetProjectionRef() */
749+
/* GetSpatialRef() */
755750
/************************************************************************/
756751

757-
const char *GRASSDataset::_GetProjectionRef()
752+
const OGRSpatialReference *GRASSDataset::GetSpatialRef() const
758753
{
759-
if( pszProjection == NULL )
760-
return "";
761-
else
762-
return pszProjection;
754+
return m_oSRS.IsEmpty() ? nullptr : &m_oSRS;
763755
}
764756

765757
/************************************************************************/
@@ -974,9 +966,12 @@ GDALDataset *GRASSDataset::Open( GDALOpenInfo * poOpenInfo )
974966

975967
projinfo = G_get_projinfo();
976968
projunits = G_get_projunits();
977-
poDS->pszProjection = GPJ_grass_to_wkt ( projinfo, projunits, 0, 0);
969+
char* pszWKT = GPJ_grass_to_wkt ( projinfo, projunits, 0, 0);
978970
if (projinfo) G_free_key_value(projinfo);
979971
if (projunits) G_free_key_value(projunits);
972+
if( pszWKT )
973+
poDS->m_oSRS.importFromWkt(pszWKT);
974+
G_free( pszWKT );
980975

981976
/* -------------------------------------------------------------------- */
982977
/* Create band information objects. */

0 commit comments

Comments
 (0)