File indexing completed on 2024-12-08 04:17:33

0001 /*
0002     SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include <map/loader/tilecache_p.h>
0008 #include <osm/datatypes.h>
0009 
0010 #include <QTest>
0011 
0012 using namespace KOSMIndoorMap;
0013 
0014 class TileCacheTest: public QObject
0015 {
0016     Q_OBJECT
0017 private Q_SLOTS:
0018     void testTileFromCoordinate_data()
0019     {
0020         QTest::addColumn<int>("z");
0021         QTest::addColumn<double>("lat");
0022         QTest::addColumn<double>("lon");
0023         QTest::addColumn<int>("x");
0024         QTest::addColumn<int>("y");
0025 
0026         QTest::newRow("z17") << 17 << 52.5258 << 13.3684 << 70403 << 42982;
0027     }
0028 
0029     void testTileFromCoordinate()
0030     {
0031         QFETCH(int, z);
0032         QFETCH(double, lat);
0033         QFETCH(double, lon);
0034         QFETCH(int, x);
0035         QFETCH(int, y);
0036 
0037         const auto tile = Tile::fromCoordinate(lat, lon, z);
0038         QCOMPARE(tile.x, x);
0039         QCOMPARE(tile.y, y);
0040         QCOMPARE(tile.z, z);
0041     }
0042 
0043     void testCoordinateForTile()
0044     {
0045         Tile t(0, 0, 1);
0046         QCOMPARE(t.topLeft().latF(), 85.0511287);
0047         QCOMPARE(t.topLeft().lonF(), -180.0);
0048         QCOMPARE(t.boundingBox().min.latF(), 0.0);
0049         QCOMPARE(t.boundingBox().min.lonF(), -180.0);
0050         QCOMPARE(t.boundingBox().max.latF(), 85.0511287);
0051         QCOMPARE(t.boundingBox().max.lonF(), 0.0);
0052     }
0053 };
0054 
0055 QTEST_GUILESS_MAIN(TileCacheTest)
0056 
0057 #include "tilecachetest.moc"