~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/g3d/changeprecision.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdio.h>
2
 
#include <stdlib.h>
3
 
#include <sys/types.h>
4
 
#include <unistd.h>
5
 
#include <grass/G3d.h>
6
 
 
7
 
/*---------------------------------------------------------------------------*/
8
 
 
9
 
 
10
 
/*!
11
 
 * \brief 
12
 
 *
13
 
 *  Makes a copy of <em>map</em> with name <em>nameOut</em> which is
14
 
 *  written with <em>precision</em>.
15
 
 * The source code can be found in <em>changeprecision.c</em>.
16
 
 *
17
 
 *  \param map
18
 
 *  \param precision
19
 
 *  \param nameOut
20
 
 *  \return void
21
 
 */
22
 
 
23
 
void G3d_changePrecision(void *map, int precision, const char *nameOut)
24
 
{
25
 
    void *map2;
26
 
    int x, y, z, savePrecision, saveCompression, saveLzw, saveRle;
27
 
    char *data;
28
 
    G3D_Region region;
29
 
    int typeIntern;
30
 
    int nx, ny, nz;
31
 
    int tileXsave, tileYsave, tileZsave, tileX, tileY, tileZ, saveType;
32
 
 
33
 
    saveType = G3d_getFileType();
34
 
    /*   G3d_setFileType (G3d_fileTypeMap (map)); */
35
 
    G3d_getCompressionMode(&saveCompression, &saveLzw, &saveRle,
36
 
                           &savePrecision);
37
 
    G3d_setCompressionMode(G3D_COMPRESSION, saveLzw, saveRle, precision);
38
 
    G3d_getTileDimension(&tileXsave, &tileYsave, &tileZsave);
39
 
    G3d_getTileDimensionsMap(map, &tileX, &tileY, &tileZ);
40
 
    G3d_setTileDimension(tileX, tileY, tileZ);
41
 
 
42
 
    typeIntern = G3d_tileTypeMap(map);
43
 
    G3d_getRegionStructMap(map, &region);
44
 
 
45
 
    map2 =
46
 
        G3d_openCellNew(nameOut, typeIntern, G3D_USE_CACHE_DEFAULT, &region);
47
 
    if (map2 == NULL)
48
 
        G3d_fatalError("G3d_changePrecision: error in G3d_openCellNew");
49
 
 
50
 
    G3d_setFileType(saveType);
51
 
    G3d_setCompressionMode(saveCompression, saveLzw, saveRle, savePrecision);
52
 
    G3d_setTileDimension(tileXsave, tileYsave, tileZsave);
53
 
 
54
 
    data = G3d_allocTiles(map, 1);
55
 
    if (data == NULL)
56
 
        G3d_fatalError("G3d_changePrecision: error in G3d_allocTiles");
57
 
    G3d_getNofTilesMap(map2, &nx, &ny, &nz);
58
 
 
59
 
    for (z = 0; z < nz; z++)
60
 
        for (y = 0; y < ny; y++)
61
 
            for (x = 0; x < nx; x++) {
62
 
                if (!G3d_readTile(map, G3d_tile2tileIndex(map, x, y, z), data,
63
 
                                  typeIntern))
64
 
                    G3d_fatalError
65
 
                        ("G3d_changePrecision: error in G3d_readTile");
66
 
                if (!G3d_writeTile
67
 
                    (map2, G3d_tile2tileIndex(map2, x, y, z), data,
68
 
                     typeIntern))
69
 
                    G3d_fatalError
70
 
                        ("G3d_changePrecision: error in G3d_writeTile");
71
 
            }
72
 
 
73
 
    G3d_freeTiles(data);
74
 
    if (!G3d_closeCell(map2))
75
 
        G3d_fatalError("G3d_changePrecision: error in G3d_closeCell");
76
 
}