source: trunk/main.c @ 14

Last change on this file since 14 was 14, checked in by marius, 6 years ago

better function for strlist

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Date Author Id Revision HeadURL"
  • Property svn:mime-type set to text/plain
File size: 2.9 KB
Line 
1/*
2 * Memphis - Cairo Rederer for OSM in C
3 * Copyright (C) 2008  <marius.rieder@durchmesser.ch>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 */
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <unistd.h>
23#include <string.h>
24#include <expat.h>
25
26#include "main.h"
27#include "osm05.h"
28#include "renderer.h"
29#include "ruleset.h"
30#include "strlist.h"
31
32// Global Vars
33strList     *keyStrings;
34strList     *valStrings;
35strList     *patternStrings;
36memphisOpt  *opts;
37
38void banner() {
39    fprintf(stdout,"Memphis OSM Renderer\n");
40}
41
42void usage(char *prog) {
43    banner();
44    fprintf(stdout,"%s [-v|-q] [-m|-t <X> <Y>] <configfile> <datafile>\n", prog);
45}
46
47int main(int argc, char **argv) {   
48    cfgRules *ruleset;
49    osmFile *osm;
50   
51    opts = malloc(sizeof(memphisOpt));
52    opts->debug = 1;
53    opts->cfgfn = NULL;
54    opts->osmfn = NULL;
55    opts->mode = MODE_MAP;
56    opts->minlayer = 12;
57    opts->maxlayer = 17;
58   
59    int i;
60    for (i = 1; i < argc ; i++) {
61        if ((!strcmp(argv[i], "-q")) || (!strcmp(argv[i], "--quiet"))) {
62            opts->debug--;
63        } else if ((!strcmp(argv[i], "-v")) || (!strcmp(argv[i], "--verbose"))) {
64            opts->debug++;
65        } else if ((!strcmp(argv[i], "-m")) || (!strcmp(argv[i], "--map"))) {
66            opts->mode = MODE_MAP;
67        } else if ((!strcmp(argv[i], "-t")) || (!strcmp(argv[i], "--tile"))) {
68            if(sscanf(argv[i+1],"%hi",&opts->tile_x)!=1 ||
69               sscanf(argv[i+2],"%hi",&opts->tile_y)!=1 ) {
70                usage((char *) *argv);
71                exit(-1);
72            }
73            i+=2;
74        } else if (opts->cfgfn == NULL) {
75            opts->cfgfn = argv[i];
76        } else if (opts->osmfn == NULL) {
77            opts->osmfn = argv[i];
78        } else {
79            usage((char *) *argv);
80            exit(-1);
81        }
82    }
83   
84    if (argc < 2 || opts->cfgfn == NULL || opts->osmfn == NULL) {
85        usage((char *) *argv);
86        exit(-1);
87    }
88   
89    keyStrings = strlist_init();
90    valStrings = strlist_init();
91    patternStrings = strlist_init();
92                       
93    banner();
94   
95    ruleset = (cfgRules *) rulesetRead(opts->cfgfn);
96    if(ruleset == NULL)
97        return(-1);
98
99    osm = (osmFile *) osmRead(opts->osmfn);
100    if(ruleset == NULL)
101        return(-1);
102   
103    renderCairo(ruleset, osm);
104   
105    return(0);
106}
107
Note: See TracBrowser for help on using the repository browser.