1 |
1 |
/******************************************************************************
|
2 |
|
* $Id: grass57dataset.cpp,v 1.6 2006/02/13 17:39:31 rblazek Exp $
|
|
2 |
* $Id: grass57dataset.cpp,v 1.7 2006/11/09 15:30:45 rblazek Exp $
|
3 |
3 |
*
|
4 |
4 |
* Project: GRASS Driver
|
5 |
5 |
* Purpose: Implement GRASS raster read/write support
|
... | ... | |
31 |
31 |
******************************************************************************
|
32 |
32 |
*
|
33 |
33 |
* $Log: grass57dataset.cpp,v $
|
|
34 |
* Revision 1.7 2006/11/09 15:30:45 rblazek
|
|
35 |
* check if ResetReading failed
|
|
36 |
*
|
34 |
37 |
* Revision 1.6 2006/02/13 17:39:31 rblazek
|
35 |
38 |
* header files moved to grass
|
36 |
39 |
*
|
... | ... | |
73 |
76 |
|
74 |
77 |
#define GRASS_MAX_COLORS 100000 // what is the right value
|
75 |
78 |
|
76 |
|
CPL_CVSID("$Id: grass57dataset.cpp,v 1.6 2006/02/13 17:39:31 rblazek Exp $");
|
|
79 |
CPL_CVSID("$Id: grass57dataset.cpp,v 1.7 2006/11/09 15:30:45 rblazek Exp $");
|
77 |
80 |
|
78 |
81 |
CPL_C_START
|
79 |
82 |
void GDALRegister_GRASS(void);
|
... | ... | |
409 |
412 |
sNewWindow->ew_res != sOpenWindow.ew_res || sNewWindow->ns_res != sOpenWindow.ns_res ||
|
410 |
413 |
sNewWindow->rows != sOpenWindow.rows || sNewWindow->cols != sOpenWindow.cols )
|
411 |
414 |
{
|
412 |
|
G_close_cell( hCell );
|
|
415 |
if( hCell >= 0 ) {
|
|
416 |
G_close_cell( hCell );
|
|
417 |
hCell = -1;
|
|
418 |
}
|
413 |
419 |
|
414 |
420 |
/* Set window */
|
415 |
421 |
G_set_window( sNewWindow );
|
... | ... | |
423 |
429 |
|
424 |
430 |
if ( (hCell = G_open_cell_old( pszCellName, pszMapset)) < 0 ) {
|
425 |
431 |
CPLError( CE_Warning, CPLE_AppDefined, "GRASS: Cannot open raster '%s'", pszCellName );
|
|
432 |
this->valid = false;
|
426 |
433 |
return CE_Failure;
|
427 |
434 |
}
|
428 |
435 |
|
... | ... | |
459 |
466 |
CPLErr GRASSRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, void * pImage )
|
460 |
467 |
|
461 |
468 |
{
|
|
469 |
if ( ! this->valid ) return CE_Failure;
|
|
470 |
|
462 |
471 |
// Reset window because IRasterIO could be previosly called
|
463 |
472 |
if ( ResetReading ( &(((GRASSDataset *)poDS)->sCellInfo) ) != CE_None ) {
|
464 |
473 |
return CE_Failure;
|
... | ... | |
510 |
519 |
/* Calculate the region */
|
511 |
520 |
struct Cell_head sWindow;
|
512 |
521 |
struct Cell_head *psDsWindow;
|
|
522 |
|
|
523 |
if ( ! this->valid ) return CE_Failure;
|
513 |
524 |
|
514 |
525 |
psDsWindow = &(((GRASSDataset *)poDS)->sCellInfo);
|
515 |
526 |
|
... | ... | |
526 |
537 |
/* Reset resolution */
|
527 |
538 |
G_adjust_Cell_head ( &sWindow, 1, 1);
|
528 |
539 |
|
529 |
|
ResetReading ( &sWindow );
|
|
540 |
if ( ResetReading ( &sWindow ) != CE_None )
|
|
541 |
{
|
|
542 |
return CE_Failure;
|
|
543 |
}
|
530 |
544 |
|
531 |
545 |
/* Read Data */
|
532 |
546 |
CELL *cbuf = NULL;
|