1 #include "csf.h"
2 #include "csfimpl.h"
3
4
5 /* create a new map by cloning another one
6 * Rdup creates a new empty map from the specifications of another map.
7 * No cell values are copied. It uses a call to Rcreate to create the
8 * map. See Rcreate for legal values of the args cellRepr and valueScale.
9 * returns the map handle of the newly created map or NULL in case of an
10 * error
11 *
12 * Merrno
13 * NOT_RASTER plus the Merrno codes of Rcreate
14 *
15 * EXAMPLE
16 * .so examples/dupbool.tr
17 */
Rdup(const char * toFile,const MAP * from,CSF_CR cellRepr,CSF_VS dataType)18 MAP *Rdup(
19 const char *toFile, /* file name of map to be created */
20 const MAP *from, /* map to clone from */
21 CSF_CR cellRepr, /* cell representation of new map */
22 CSF_VS dataType) /* datatype/valuescale of new map */
23 {
24 MAP *newMap = NULL; /* set NULL for goto error */
25
26 CHECKHANDLE_GOTO(from, error);
27
28 /* check if mapType is T_RASTER */
29 if (from->main.mapType != T_RASTER)
30 {
31 M_ERROR(NOT_RASTER);
32 goto error;
33 }
34
35 newMap = Rcreate(toFile,
36 (size_t)from->raster.nrRows,
37 (size_t)from->raster.nrCols,
38 cellRepr,
39 dataType,
40 from->main.projection,
41 from->raster.xUL,
42 from->raster.yUL,
43 from->raster.angle,
44 from->raster.cellSize);
45
46 error:
47 return newMap ;
48 }
49