[Git][debian-gis-team/gdal-grass][upstream] New upstream version 3.1.3~rc1
Bas Couwenberg
gitlab at salsa.debian.org
Tue Sep 1 13:07:15 BST 2020
Bas Couwenberg pushed to branch upstream at Debian GIS Project / gdal-grass
Commits:
0b1c56fa by Bas Couwenberg at 2020-09-01T11:56:35+02:00
New upstream version 3.1.3~rc1
- - - - -
2 changed files:
- VERSION
- grass57dataset.cpp
Changes:
=====================================
VERSION
=====================================
@@ -1 +1 @@
-3.1.2
+3.1.3
=====================================
grass57dataset.cpp
=====================================
@@ -63,7 +63,7 @@ char *GPJ_grass_to_wkt( struct Key_Value *,
#define GRASS_MAX_COLORS 100000 // what is the right value
-CPL_CVSID("$Id: grass57dataset.cpp a5d5ed208537a05de4437e97b6a09b7ba44f76c9 2020-03-24 08:27:48 +0100 Kai Pastor $")
+CPL_CVSID("$Id: grass57dataset.cpp 7aa76ba75c2c4c1b814cf1489838533b56a1946e 2020-08-21 19:19:23 +0200 Markus Metz $")
#if GRASS_VERSION_MAJOR >= 7
#define G_get_cellhd Rast_get_cellhd
@@ -193,6 +193,7 @@ class GRASSRasterBand final: public GDALRasterBand
double GetNoDataValue( int *pbSuccess = NULL ) override;
private:
+ void SetWindow( struct Cell_head * );
CPLErr ResetReading( struct Cell_head * );
};
@@ -300,10 +301,8 @@ GRASSRasterBand::GRASSRasterBand( GRASSDataset *poDSIn, int nBandIn,
nBlockYSize = 1;
G_set_window( &(poDSIn->sCellInfo) );
- if ( (hCell = G_open_cell_old((char *) pszCellName, (char *) pszMapset)) < 0 ) {
- CPLError( CE_Warning, CPLE_AppDefined, "GRASS: Cannot open raster '%s'", pszCellName );
- return;
- }
+ // open the raster only for actual reading
+ hCell = -1;
G_copy((void *) &sOpenWindow, (void *) &(poDSIn->sCellInfo), sizeof(struct Cell_head));
/* -------------------------------------------------------------------- */
@@ -413,11 +412,38 @@ GRASSRasterBand::~GRASSRasterBand()
}
/************************************************************************/
-/* ResetReading */
+/* SetWindow */
/* */
-/* Reset current window and reopen cell if the window has changed, */
+/* Helper for ResetReading */
+/* close the current GRASS raster band, actually set the new window, */
/* reset GRASS variables */
/* */
+/* Returns nothing */
+/************************************************************************/
+void GRASSRasterBand::SetWindow ( struct Cell_head *sNewWindow )
+{
+ if( hCell >= 0 ) {
+ G_close_cell( hCell );
+ hCell = -1;
+ }
+
+ /* Set window */
+ G_set_window( sNewWindow );
+
+ /* Set GRASS env to the current raster, don't open the raster */
+ G__setenv( "GISDBASE", ((GRASSDataset *)poDS)->pszGisdbase );
+ G__setenv( "LOCATION_NAME", ((GRASSDataset *)poDS)->pszLocation );
+ G__setenv( "MAPSET", pszMapset);
+ G_reset_mapsets();
+ G_add_mapset_to_search_path ( pszMapset );
+}
+
+/************************************************************************/
+/* ResetReading */
+/* */
+/* Reset current window for a new reading request, */
+/* close the current GRASS raster band, reset GRASS variables */
+/* */
/* Returns CE_Failure if fails, otherwise CE_None */
/************************************************************************/
CPLErr GRASSRasterBand::ResetReading ( struct Cell_head *sNewWindow )
@@ -429,27 +455,7 @@ CPLErr GRASSRasterBand::ResetReading ( struct Cell_head *sNewWindow )
sNewWindow->ew_res != sOpenWindow.ew_res || sNewWindow->ns_res != sOpenWindow.ns_res ||
sNewWindow->rows != sOpenWindow.rows || sNewWindow->cols != sOpenWindow.cols )
{
- if( hCell >= 0 ) {
- G_close_cell( hCell );
- hCell = -1;
- }
-
- /* Set window */
- G_set_window( sNewWindow );
-
- /* Open raster */
- G__setenv( "GISDBASE", ((GRASSDataset *)poDS)->pszGisdbase );
- G__setenv( "LOCATION_NAME", ((GRASSDataset *)poDS)->pszLocation );
- G__setenv( "MAPSET", pszMapset);
- G_reset_mapsets();
- G_add_mapset_to_search_path ( pszMapset );
-
- if ( (hCell = G_open_cell_old( pszCellName, pszMapset)) < 0 ) {
- CPLError( CE_Warning, CPLE_AppDefined, "GRASS: Cannot open raster '%s'", pszCellName );
- this->valid = false;
- return CE_Failure;
- }
-
+ SetWindow ( sNewWindow );
G_copy((void *) &sOpenWindow, (void *) sNewWindow, sizeof(struct Cell_head));
}
else
@@ -465,8 +471,7 @@ CPLErr GRASSRasterBand::ResetReading ( struct Cell_head *sNewWindow )
sNewWindow->rows != sCurrentWindow.rows || sNewWindow->cols != sCurrentWindow.cols
)
{
- /* Reset window */
- G_set_window( sNewWindow );
+ SetWindow ( sNewWindow );
}
}
@@ -488,6 +493,13 @@ CPLErr GRASSRasterBand::IReadBlock( int /*nBlockXOff*/, int nBlockYOff,
if ( ResetReading ( &(((GRASSDataset *)poDS)->sCellInfo) ) != CE_None ) {
return CE_Failure;
}
+ // open for reading
+ if (hCell < 0) {
+ if ( (hCell = G_open_cell_old((char *) pszCellName, (char *) pszMapset)) < 0 ) {
+ CPLError( CE_Failure, CPLE_AppDefined, "GRASS: Cannot open raster '%s'", pszCellName );
+ return CE_Failure;
+ }
+ }
if ( eDataType == GDT_Byte || eDataType == GDT_UInt16 ) {
CELL *cbuf = G_allocate_c_raster_buf();
@@ -518,6 +530,10 @@ CPLErr GRASSRasterBand::IReadBlock( int /*nBlockXOff*/, int nBlockYOff,
G_get_d_raster_row ( hCell, (DCELL *) pImage, nBlockYOff );
}
+ // close to avoid confusion with other GRASS raster bands
+ G_close_cell( hCell );
+ hCell = -1;
+
return CE_None;
}
@@ -563,6 +579,13 @@ CPLErr GRASSRasterBand::IRasterIO ( GDALRWFlag eRWFlag,
{
return CE_Failure;
}
+ // open for reading
+ if (hCell < 0) {
+ if ( (hCell = G_open_cell_old((char *) pszCellName, (char *) pszMapset)) < 0 ) {
+ CPLError( CE_Failure, CPLE_AppDefined, "GRASS: Cannot open raster '%s'", pszCellName );
+ return CE_Failure;
+ }
+ }
/* Read Data */
CELL *cbuf = NULL;
@@ -635,6 +658,10 @@ CPLErr GRASSRasterBand::IRasterIO ( GDALRWFlag eRWFlag,
if ( fbuf ) G_free ( fbuf );
if ( dbuf ) G_free ( dbuf );
+ // close to avoid confusion with other GRASS raster bands
+ G_close_cell( hCell );
+ hCell = -1;
+
return CE_None;
}
View it on GitLab: https://salsa.debian.org/debian-gis-team/gdal-grass/-/commit/0b1c56fa52ea9239ba699db73f69b8fbb3865248
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/gdal-grass/-/commit/0b1c56fa52ea9239ba699db73f69b8fbb3865248
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20200901/6ff7a97d/attachment-0001.html>
More information about the Pkg-grass-devel
mailing list