1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
3 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
5 * Copyright (C) 2014, Rob Norris <rw_norris@hotmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <sys/types.h>
34 int main ( int argc
, char *argv
[] )
36 const int tile_max
= METATILE_MAX_SIZE
;
37 char err_msg
[PATH_MAX
];
42 // Could extend to get values from the command-line.
46 //char dir[] = "/var/lib/mod_tile/default";
47 char dir
[] = "metatile_example";
48 // Example defaults to a metatile that was pre generated using mod_tile
49 // Equates to 'metatile_example/13/0/0/250/220/0.meta'
50 // which is Brownsea Island, Dorset, UK (50.69N, 1.96W)
52 buf
= malloc(tile_max
);
60 len
= metatile_read(argv
[1], x
, y
, z
, buf
, tile_max
, &compressed
, err_msg
);
62 len
= metatile_read(dir
, x
, y
, z
, buf
, tile_max
, &compressed
, err_msg
);
65 // Do something with buf
66 // Just dump to a file
69 fp
= fopen( "tilefrommeta.gz" , "w" );
71 fp
= fopen( "tilefrommeta.png" , "w" );
74 fwrite(buf
, 1 , len
, fp
);
78 fprintf(stderr
, "Failed to open file because: %s\n", strerror(errno
));
84 fprintf(stderr
, "FAILED: %s\n", err_msg
);