Changeset View
Changeset View
Standalone View
Standalone View
tools/osm-simplify/main.cpp
1 | // | ||||
---|---|---|---|---|---|
2 | // This file is part of the Marble Virtual Globe. | ||||
3 | // | ||||
4 | // This program is free software licensed under the GNU LGPL. You can | ||||
5 | // find a copy of this license in LICENSE.txt in the top directory of | ||||
6 | // the source code. | ||||
7 | // | ||||
8 | // Copyright 2016 David Kolozsvari <freedawson@gmail.com> | ||||
9 | // | ||||
10 | | ||||
1 | #include "OsmParser.h" | 11 | #include "OsmParser.h" | ||
2 | #include "GeoWriter.h" | 12 | #include "GeoWriter.h" | ||
3 | 13 | | |||
nienhueser: osm-addresses => osm-simplify | |||||
Context not available. | |||||
46 | } | 56 | } | ||
47 | void usage() | 57 | void usage() | ||
48 | { | 58 | { | ||
49 | qDebug() << "Usage: osm-addresses [options] input.osm output.osm"; | 59 | qDebug() << "Usage: osm-simplify [options] input.osm output.osm"; | ||
50 | qDebug() << "\t-q quiet"; | 60 | qDebug() << "\t-q quiet"; | ||
51 | qDebug() << "\t-v debug output"; | 61 | qDebug() << "\t-v debug output"; | ||
52 | } | 62 | } | ||
could also use https://doc.qt.io/qt-4.8/qfileinfo.html#suffix instead of endsWith. nienhueser: could also use https://doc.qt.io/qt-4.8/qfileinfo.html#suffix instead of endsWith. | |||||
nienhueser: return with an exit code != 0 here?
| |||||
Context not available. | |||||
83 | return 2; | 93 | return 2; | ||
84 | } | 94 | } | ||
85 | 95 | | |||
86 | if ( file.fileName().endsWith( QLatin1String( ".osm" ) ) ) { | 96 | if ( file.suffix() == "osm") { | ||
87 | 97 | | |||
88 | QString error; | 98 | QString error; | ||
89 | Marble::GeoDataDocument* osmMap = OsmParser::parse(inputSrc, error); | 99 | Marble::GeoDataDocument* osmMap = OsmParser::parse(inputSrc, error); | ||
90 | 100 | | |||
91 | if(!error.isEmpty()) { | 101 | if(!error.isEmpty()) { | ||
nienhueser: return with an exit code != 0 here?
| |||||
92 | qDebug() << error; | 102 | qDebug() << error; | ||
103 | return 3; | ||||
93 | } | 104 | } | ||
94 | 105 | | |||
95 | Marble::GeoWriter writer; | 106 | Marble::GeoWriter writer; | ||
Context not available. | |||||
99 | outputfile.open( QIODevice::WriteOnly ); | 110 | outputfile.open( QIODevice::WriteOnly ); | ||
100 | if ( !writer.write( &outputfile, osmMap ) ) { | 111 | if ( !writer.write( &outputfile, osmMap ) ) { | ||
101 | qDebug() << "Could not write the file " << outputSrc; | 112 | qDebug() << "Could not write the file " << outputSrc; | ||
113 | return 4; | ||||
102 | } | 114 | } | ||
103 | 115 | | |||
104 | qDebug() << "Done."; | 116 | qDebug() << "Done."; | ||
105 | } else { | 117 | } else { | ||
106 | qDebug() << "Unsupported file format: " << outputSrc; | 118 | qDebug() << "Unsupported file format: " << outputSrc; | ||
107 | return 3; | 119 | return 5; | ||
108 | } | 120 | } | ||
121 | | ||||
122 | return 0; | ||||
109 | } | 123 | } | ||
110 | 124 | | |||
Context not available. |
osm-addresses => osm-simplify