| 222 | } |
| 223 | |
| 224 | void worldFileTemplateTest() |
| 225 | { |
| 226 | Map map; |
| 227 | MapView view{ &map }; |
| 228 | QVERIFY(map.loadFrom(QStringLiteral("testdata:templates/world-file.xmap"), &view)); |
| 229 | |
| 230 | const auto& georef = map.getGeoreferencing(); |
| 231 | QCOMPARE(georef.getState(), Georeferencing::Geospatial); |
| 232 | |
| 233 | QCOMPARE(map.getNumTemplates(), 1); |
| 234 | auto temp = map.getTemplate(0); |
| 235 | QCOMPARE(temp->getTemplateType(), "TemplateImage"); |
| 236 | QCOMPARE(temp->getTemplateFilename(), QString::fromLatin1("world-file.png")); |
| 237 | QVERIFY(temp->isTemplateGeoreferenced()); |
| 238 | |
| 239 | QVERIFY(temp->getTemplateState() != Template::Invalid); |
| 240 | QCOMPARE(temp->getTemplateRelativePath(), QStringLiteral("world-file.png")); |
| 241 | QCOMPARE(temp->getTemplateRelativePath(nullptr), QStringLiteral("world-file.png")); |
| 242 | auto base_dir = QDir(QStringLiteral("testdata:templates")); |
| 243 | QCOMPARE(temp->getTemplateRelativePath(&base_dir), QStringLiteral("world-file.png")); |
| 244 | base_dir.cdUp(); |
| 245 | QCOMPARE(temp->getTemplateRelativePath(&base_dir), QStringLiteral("templates/world-file.png")); |
| 246 | |
| 247 | map.loadTemplateFiles(view); |
| 248 | QCOMPARE(temp->getTemplateState(), Template::Loaded); |
| 249 | auto rotation_template = 0.01 * qRound(100 * qRadiansToDegrees(temp->getTemplateRotation())); |
| 250 | auto rotation_map = 0.01 * qRound(100 * georef.getGrivation()); |
| 251 | QCOMPARE(rotation_template, rotation_map); |
| 252 | |
| 253 | // Test boundingRect for TemplateImage |
| 254 | QCOMPARE(temp->boundingRect().center(), center(temp)); |
| 255 | } |
| 256 | |
| 257 | |
| 258 | void templatePathTest() |
nothing calls this directly
no test coverage detected