1 /***************************************************************************
2 * This file is part of Tecorrec. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
5 * Tecorrec 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. *
10 * Tecorrec 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. *
15 * You should have received a copy of the GNU General Public License *
16 * along with Tecorrec. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
27 int cpVoids(const QString filename
, char* voids
)
29 qDebug() << "Reading" << filename
;
31 // Find corresponding file in void directory
32 QFileInfo
fi(filename
);
33 QString name
= fi
.fileName();
36 if (srtm
.open(QIODevice::ReadWrite
))
38 QString pathFname
= QString("%1/%2").arg(voids
).arg(name
);
39 QFile
voidfs(pathFname
);
40 if (voidfs
.open(QIODevice::ReadOnly
))
42 // Check they're the same size
43 int len
= srtm
.size();
44 if (voidfs
.size() == len
)
46 QDataStream
srtmStream(&srtm
);
47 QDataStream
voidStream(&voidfs
);
48 srtmStream
.setByteOrder(QDataStream::BigEndian
);
49 voidStream
.setByteOrder(QDataStream::BigEndian
);
50 for (int i
= 0; i
< len
; i
+= 2)
52 // Read value and voidness
55 srtmStream
>> srtmness
;
56 voidStream
>> voidness
;
59 srtmness
= (srtmness
& 0x7FFF) | (voidness
& 0x8000);
61 srtmStream
<< srtmness
;
66 qDebug() << "Size mismatch with " << filename
<< " and " << pathFname
;
72 qDebug() << "Could not access " << pathFname
;
78 qDebug() << "Could not access " << filename
;
84 int main(int argc
, char** argv
)
86 qDebug() << "Welcome to cpVoids";
88 // Copy void data into HGT files specified
90 for (int i
= 1; i
< argc
; ++i
)
92 if (0 == strcmp(argv
[i
], "--voids"))
94 // next argument is voids directory
98 qDebug() << "Using voids from " << voids
;
105 qDebug() << "Cannot copy voids into " << argv
[i
] << ", no void directory specified, use --voids void/dir before HGT files";
108 error
|= cpVoids(argv
[i
], voids
);