static CSF_CONV_FUNC ConvFuncBool(CSF_CR cr) { PRECOND(CSF_UNIQ_CR_MASK(cr) < 12); PRECOND(convTableIndex[CSF_UNIQ_CR_MASK(cr)] != -1); return boolConvTable[(int)convTableIndex[CSF_UNIQ_CR_MASK(cr)]]; }
static int HasInFileCellReprType2(CSF_CR cr) { char type2[12] = { 1 /* UINT1 */, 0 /* UINT2 */, 0 /* UINT4 */, 0 /* 0x03 */, 0 /* INT1 */, 0 /* INT2 */, 1 /* INT4 */, 0 /* 0x07 */, 0 /* 0x08 */, 0 /* 0x09 */, 1 /* REAL4 */, 1 /* REAL8 */}; PRECOND(CSF_UNIQ_CR_MASK(cr) < 12); return (int)type2[CSF_UNIQ_CR_MASK(cr)]; }
/* write a stream of cells * RputSomeCells views a raster as one linear stream of * cells, with row i+1 placed after row i. * In this stream any sequence can be written by specifying an * offset and the number of cells to be written * returns the number of cells written, just as fwrite * * example * .so examples/somecell.tr */ size_t RputSomeCells( MAP *map, /* map handle */ size_t offset, /* offset from pixel (row,col) = (0,0) */ size_t nrCells, /* number of cells to be read */ void *buf)/* read-write. Buffer large enough to * hold nrCells cells in the in-file cell representation * or the in-app cell representation. * If these types are not equal then the buffer is * converted from the in-app to the in-file * cell representation. */ { CSF_FADDR writeAt; CSF_CR cr = map->raster.cellRepr; /* convert */ map->app2file(nrCells, buf); if (map->minMaxStatus == MM_KEEPTRACK) { const DF detMinMaxFunc[12] = { (DF)DetMinMaxUINT1, (DF)DetMinMaxUINT2, (DF)DetMinMaxUINT4, NULL /* 0x03 */ , (DF)DetMinMaxINT1 , (DF)DetMinMaxINT2 , (DF)DetMinMaxINT4 , NULL /* 0x07 */ , NULL /* 0x08 */ , NULL /* 0x09 */ , (DF)DetMinMaxREAL4, (DF)DetMinMaxREAL8 }; void *min = &(map->raster.minVal); void *max = &(map->raster.maxVal); PRECOND(CSF_UNIQ_CR_MASK(cr) < 12); PRECOND(detMinMaxFunc[CSF_UNIQ_CR_MASK(cr)] != NULL); detMinMaxFunc[CSF_UNIQ_CR_MASK(cr)](min, max, nrCells, buf); } else map->minMaxStatus = MM_WRONGVALUE; writeAt = ((CSF_FADDR)offset) << LOG_CELLSIZE(cr); writeAt += ADDR_DATA; if( csf_fseek(map->fp, writeAt, SEEK_SET) != 0 ) return 0; return(map->write(buf, (size_t)CELLSIZE(cr), (size_t)nrCells, map->fp)); }
static CSF_CONV_FUNC ConvFunc(CSF_CR destType, CSF_CR srcType) { PRECOND(CSF_UNIQ_CR_MASK(destType) < 12); PRECOND(CSF_UNIQ_CR_MASK(srcType) < 12); PRECOND(convTableIndex[CSF_UNIQ_CR_MASK(srcType)] != -1); PRECOND(convTableIndex[CSF_UNIQ_CR_MASK(destType)] != -1); /* don't complain on illegal, it can be attached * to a app2file while there's no WRITE_MODE * if it's an error then it's catched in RputSomeCells */ return ConvTable[(int)convTableIndex[CSF_UNIQ_CR_MASK(srcType)]] [(int)convTableIndex[CSF_UNIQ_CR_MASK(destType)]]; }