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];
43 // Could extend to get values from the command-line.
47 //char dir[] = "/var/lib/mod_tile/default";
48 char dir[] = "metatile_example";
49 // Example defaults to a metatile that was pre generated using mod_tile
50 // Equates to 'metatile_example/13/0/0/250/220/0.meta'
51 // which is Brownsea Island, Dorset, UK (50.69N, 1.96W)
53 buf = malloc(tile_max);
61 len = metatile_read(argv[1], x, y, z, buf, tile_max, &compressed, err_msg);
63 len = metatile_read(dir, x, y, z, buf, tile_max, &compressed, err_msg);
66 // Do something with buf
67 // Just dump to a file
70 fp = fopen( "tilefrommeta.gz" , "w" );
72 fp = fopen( "tilefrommeta.png" , "w" );
75 fwrite(buf, 1 , len, fp);
79 fprintf(stderr, "Failed to open file because: \n", strerror(errno));
85 fprintf(stderr, "FAILED: %s\n", err_msg);