source: subversion/applications/utils/import/srtm2wayinfo/main.cpp

Last change on this file was 17101, checked in by herm, 8 years ago

Support different storage systems for ways.

File size: 1.8 KB
Line 
1/* Copyright (c) 2009 Hermann Kraus
2 * This software is available under a "MIT Style" license
3 * (see COPYING).
4 */
5/** \file
6  * Main function
7  *
8  * Handles command line processing, etc.
9  */
10
11#include "srtm.h"
12#include "osm-parse.h"
13#include "relations.h"
14#include "settings.h"
15
16#include <curl/curl.h>
17#include <QDebug>
18#include <QLocale>
19
20/** Main function. */
21int main(int argc, char **argv)
22{
23    global_settings.parseSettings(argc, argv);
24
25    OsmWayStorage *ways;
26    OsmNodeStorage *nodes;
27    if (global_settings.getDatasetSize() == size_small) {
28        nodes = new OsmNodeStorageSmall();
29        ways = new OsmWayStorageMem();
30    } else if (global_settings.getDatasetSize() == size_medium) {
31        nodes = new OsmNodeStorageMedium();
32        ways = new OsmWayStorageDisk(".");
33    } else {
34        nodes = new OsmNodeStorageLarge();
35        ways = new OsmWayStorageDisk(".");
36    }
37
38    curl_global_init(CURL_GLOBAL_DEFAULT);
39    /* Setting the locale should not be required but it can't harm.
40     * QString::arg() is safe.
41     * QString::toDouble first tries converting using the locale, then using the "C" locale.*/
42    QLocale::setDefault(QLocale::C);
43
44    //Download file lists first, so we can stop here if we notice an error
45    SrtmDownloader downloader(global_settings.getSrtmServer(), global_settings.getCacheDir());
46
47    QFile output(global_settings.getOutput());
48    if (!output.open(QIODevice::WriteOnly)) {
49        qCritical() << "Could not open output file" << global_settings.getOutput();
50        exit(1);
51    }
52
53    OsmData data(ways, nodes);
54    data.parse(global_settings.getInput());
55
56    RelationWriter writer(&data, &output, &downloader);
57    writer.writeRelations();
58
59    output.close();
60    delete nodes;
61    delete ways;
62    curl_global_cleanup();
63}
Note: See TracBrowser for help on using the repository browser.