]> err.no Git - mapper/blob - src/osm.c
GpsBluez: cleanups
[mapper] / src / osm.c
1 /*
2  * This file is part of mapper
3  *
4  * Copyright (C) 2007 Kaj-Michael Lang
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 /*
22  * A simple CLI interface to the mapper planet2sqlite import code.
23  */
24
25 #include <stdio.h>
26 #include <unistd.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 #include <glib/gstdio.h>
31
32 #include "osm.h"
33 #include "latlon.h"
34 #include "db.h"
35 #include "osm-db-import.h"
36
37 #define OSM_DB_FILE "osm-planet.db"
38
39 static gint
40 print_fail(const gchar *msg, gint ret)
41 {
42 g_printerr("ERROR: %s\n", msg);
43 return ret;
44 }
45
46 int main (int argc, char **argv)
47 {
48 gchar *in_file;
49 gchar *out_file;
50
51 if (argc<2)
52         return print_fail("Give bzip2 compressed planet XML file as argument", 1);
53
54 out_file=OSM_DB_FILE;
55 in_file=argv[1];
56 g_printf("Using file: %s\n", in_file);
57
58 if (argc==6) {
59         osm_import_set_bbox(TRUE, atof(argv[2]), atof(argv[3]), atof(argv[4]), atof(argv[5]));
60 } else {
61         osm_import_set_bbox(FALSE, 0, 0, 0, 0);
62 }
63
64 if (osm_import(in_file, out_file)==FALSE) {
65         return print_fail("Import failed", 4);
66 }
67 return 0;
68 }