12 #include <QApplication>
13 #include <QDataStream>
16 #include <QXmlInputSource>
17 #include <QXmlSimpleReader>
18 #include <QStringList>
21 void parseSvg(
const QString & svgFilename, QDataStream * out,
const QString & path,
int header ) {
24 QFile xmlFile( svgFilename );
25 QXmlInputSource inputSource(&xmlFile);
26 QXmlSimpleReader reader;
28 reader.setContentHandler(&handler);
29 reader.parse( inputSource );
32 int main(
int argc,
char *argv[])
34 QApplication app(argc, argv);
36 qDebug(
" Syntax: pntreplace [-i pnt-sourcefile -o pnt-targetfile -s svg-replacementfile -id pntidNumber -path svgpathid] " );
38 QString inputFilename(
"PDIFFBORDERS.PNT");
39 int inputIndex = app.arguments().indexOf(
"-i");
40 if (inputIndex > 0 && inputIndex + 1 < argc )
41 inputFilename = app.arguments().at( inputIndex + 1 );
43 QString outputFilename(
"NEW.PNT");
44 int outputIndex = app.arguments().indexOf(
"-o");
45 if (outputIndex > 0 && outputIndex + 1 < argc )
46 outputFilename = app.arguments().at( outputIndex + 1 );
48 QString svgFilename(
"output.svg");
49 int svgIndex = app.arguments().indexOf(
"-s");
50 if (svgIndex > 0 && svgIndex + 1 < argc )
51 svgFilename = app.arguments().at( svgIndex + 1 );
53 QString path(
"id_path");
54 int pathIndex = app.arguments().indexOf(
"-path");
55 if (pathIndex > 0 && pathIndex + 1 < argc )
56 path = app.arguments().at( pathIndex + 1 );
59 int idIndex = app.arguments().indexOf(
"-id");
60 if (idIndex > 0 && idIndex + 1 < argc )
61 delIndex = app.arguments().at( idIndex + 1 ).toInt();
64 qDebug() <<
"input filename:" << inputFilename;
65 qDebug() <<
"output filename:" << outputFilename;
66 qDebug() <<
"svg replacement filename:" << svgFilename;
67 qDebug() <<
"replace index:" << delIndex;
68 qDebug() <<
"replacement:" << path;
71 QFile file( inputFilename );
73 if ( file.open( QIODevice::ReadOnly ) ) {
74 QDataStream stream( &file );
75 stream.setByteOrder( QDataStream::LittleEndian );
78 QFile data(outputFilename);
80 if (data.open(QFile::WriteOnly | QFile::Truncate)) {
81 QDataStream out(&data);
82 out.setByteOrder( QDataStream::LittleEndian );
90 while( !stream.atEnd() ){
91 stream >> header >> iLat >> iLon;
92 if ( header == delIndex ) {
93 parseSvg( svgFilename, &out, path, delIndex );
96 else if ( header > 5 )
100 out << header << iLat << iLon;
105 qDebug() <<
"ERROR: Couldn't write output file to disc!";
110 qDebug() <<
"ERROR: Source file not found!";
static GeoTagHandlerRegistrar handler(GeoParser::QualifiedName(dgmlTag_DownloadPolicy, dgmlTag_nameSpace20), new DgmlDownloadPolicyTagHandler)
void parseSvg(const QString &svgFilename, QDataStream *out, const QString &path, int header)
int main(int argc, char *argv[])