diff --git a/.gitignore b/.gitignore index 5841b8a..c29af9a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ out .vs .idea .gitignore -.gitattributes \ No newline at end of file +.gitattributes +cmake-build* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b394e5..13b46bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,10 @@ if(MSVC) add_definitions(-DNOMINMAX) endif() +option(ENABLE_TEST "Enable test" ON) + find_package(GDAL REQUIRED) +find_package(PROJ REQUIRED) find_package(Qt5 REQUIRED COMPONENTS Core Xml Test) @@ -30,5 +33,18 @@ set(CMAKE_AUTORCC ON) add_subdirectory(src) -enable_testing(true) -add_subdirectory(test) +if(ENABLE_TEST) + enable_testing(true) + add_subdirectory(test) + add_custom_target(CopyResources ALL + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/proj_data ${PROJECT_BINARY_DIR}/src/proj_data + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/proj_data ${PROJECT_BINARY_DIR}/test/proj_data + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/gdal_data ${PROJECT_BINARY_DIR}/src/gdal_data + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/gdal_data ${PROJECT_BINARY_DIR}/test/gdal_data + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/data ${PROJECT_BINARY_DIR}/test/data) + +else() + add_custom_target(CopyResources ALL + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/proj_data ${PROJECT_BINARY_DIR}/src/proj_data + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/gdal_data ${PROJECT_BINARY_DIR}/src/gdal_data) +endif() \ No newline at end of file diff --git a/README.md b/README.md index 0071a94..b6937a3 100644 --- a/README.md +++ b/README.md @@ -93,4 +93,4 @@ Converter.exe --format gdal --input --output --field height -- 1. 通过Qt官网安装 2. vcpkg install "qt5[all]" 3. VS2019选择CMakeLists.txt,导入工程,编译 -4. 把OSGPlugins文件夹复制到编译目录下 \ No newline at end of file +4. 将OSGPlugins-${Version}文件夹复制到编译目录下 \ No newline at end of file diff --git a/test/data/Tile_+007_+078.osgb b/data/Tile_+007_+078.osgb similarity index 100% rename from test/data/Tile_+007_+078.osgb rename to data/Tile_+007_+078.osgb diff --git a/test/data/Tile_+007_+078_L15_0.osgb b/data/Tile_+007_+078_L15_0.osgb similarity index 100% rename from test/data/Tile_+007_+078_L15_0.osgb rename to data/Tile_+007_+078_L15_0.osgb diff --git a/test/data/Tile_+007_+078_L16_03.osgb b/data/Tile_+007_+078_L16_03.osgb similarity index 100% rename from test/data/Tile_+007_+078_L16_03.osgb rename to data/Tile_+007_+078_L16_03.osgb diff --git a/test/data/Tile_+007_+078_L17_000.osgb b/data/Tile_+007_+078_L17_000.osgb similarity index 100% rename from test/data/Tile_+007_+078_L17_000.osgb rename to data/Tile_+007_+078_L17_000.osgb diff --git a/test/data/Tile_+007_+078_L17_001.osgb b/data/Tile_+007_+078_L17_001.osgb similarity index 100% rename from test/data/Tile_+007_+078_L17_001.osgb rename to data/Tile_+007_+078_L17_001.osgb diff --git a/test/data/Tile_+007_+078_L17_002.osgb b/data/Tile_+007_+078_L17_002.osgb similarity index 100% rename from test/data/Tile_+007_+078_L17_002.osgb rename to data/Tile_+007_+078_L17_002.osgb diff --git a/test/data/Tile_+007_+078_L17_003.osgb b/data/Tile_+007_+078_L17_003.osgb similarity index 100% rename from test/data/Tile_+007_+078_L17_003.osgb rename to data/Tile_+007_+078_L17_003.osgb diff --git a/test/data/Tile_+007_+078_L17_004.osgb b/data/Tile_+007_+078_L17_004.osgb similarity index 100% rename from test/data/Tile_+007_+078_L17_004.osgb rename to data/Tile_+007_+078_L17_004.osgb diff --git a/include/CoordinateConvert.h b/include/CoordinateConvert.h index b07aefa..ae09c96 100644 --- a/include/CoordinateConvert.h +++ b/include/CoordinateConvert.h @@ -1,7 +1,8 @@ #pragma once + +#include #include #include - namespace scially { class CoordinateConvert : QObject { @@ -18,22 +19,25 @@ namespace scially { WKT, EPSG, Proj4, - Esri, }; Q_ENUM(SrsType); - CoordinateConvert(double x, double y) : sourceX(x), sourceY(y), targetX(0), targetY(0) {} - CoordinateConvert() : CoordinateConvert(0, 0) {} - - void setSourceSrs(const QString& srs, SrsType t) noexcept(false); - void setTargetSrs(const QString& srs, SrsType t) noexcept(false); - void transform() noexcept(false); + CoordinateConvert(double x, double y) : sourceX(x), sourceY(y), targetX(0), targetY(0) { + static internal::GDALDriverWrapper init; + } + CoordinateConvert() : CoordinateConvert(0, 0) { } - + void setSourceSrs(const QString& srs, SrsType t) ; + void setTargetSrs(const QString& srs, SrsType t); + void transform() ; private: void setSrs(OGRSpatialReference& srs, const QString& describe, SrsType t) ; OGRCoordinateTransformationPtr createCoordinateTransformation(); + void init() const { + const char* projResource = "proj_data"; + proj_context_set_search_paths(nullptr, 1, &projResource); + } private: OGRSpatialReference sourceSrs; OGRSpatialReference targetSrs; diff --git a/include/GDALWrapper.h b/include/GDALWrapper.h index 915a606..d11f939 100644 --- a/include/GDALWrapper.h +++ b/include/GDALWrapper.h @@ -4,12 +4,20 @@ #include #include #include +#include namespace scially { namespace internal { class GDALDriverWrapper { public: GDALDriverWrapper() { + init(); + } + private: + void init() const { + CPLSetConfigOption("GDAL_DATA","gdal_data"); + const char* projResource = "proj_data"; + proj_context_set_search_paths(nullptr, 1, &projResource); GDALAllRegister(); } }; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73c3387..92b2ab2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,16 +20,16 @@ add_library(Core STATIC "../include/tiny_gltf.h" "../include/TilesParseException.h" "../include/TilesConvertException.h" - "../include/OSGBConvertJob.h" + "../include/OSGBConvertJob.h" "../include/ShpConvertJob.h" - "../include/ModelMetadata.h" - "../include/QuadTree.h" - "../include/ShpConvert.h" - "../include/GeometryMesh.h" - "../include/GDALWrapper.h" + "../include/ModelMetadata.h" + "../include/QuadTree.h" + "../include/ShpConvert.h" + "../include/GeometryMesh.h" + "../include/GDALWrapper.h" "../include/Batched3DModel.h" "../include/Utils.h" - "../include/earcut.hpp" + "../include/earcut.hpp" "CoordinateConvert.cpp" "OSGBPageLodVisitor.cpp" @@ -47,11 +47,10 @@ add_library(Core STATIC "OSGBuildState.cpp" "OSGBLevel.cpp" "OSGBConvert.cpp" - "OSGBConvertJob.cpp" - "ModelMetadata.cpp" - "QuadTree.cpp" - "GeometryMesh.cpp" - "GDALWrapper.cpp" + "OSGBConvertJob.cpp" + "ModelMetadata.cpp" + "QuadTree.cpp" + "GeometryMesh.cpp" "Batched3DModel.cpp" "ShpConvert.cpp" "ShpConvertJob.cpp") @@ -59,25 +58,12 @@ add_library(Core STATIC target_link_libraries(Core ${GDAL_LIBRARY} + ${PROJ_LIBRARIES} ${OPENSCENEGRAPH_LIBRARIES} Qt5::Core Qt5::Xml) add_executable(Converter "main.cpp") -target_link_libraries(Converter - ${GDAL_LIBRARY} - ${OPENSCENEGRAPH_LIBRARIES} - Qt5::Core - Qt5::Xml - Core) - -add_custom_command( - TARGET Converter PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${PROJECT_SOURCE_DIR}/proj_data/proj.db - ${CMAKE_BINARY_DIR}/src/proj.db - COMMAND ${CMAKE_COMMAND} -E copy - ${PROJECT_SOURCE_DIR}/proj_data/proj.ini - ${CMAKE_BINARY_DIR}/src/proj.ini) +target_link_libraries(Converter Core) diff --git a/src/CoordinateConvert.cpp b/src/CoordinateConvert.cpp index addd5f1..15b4ae1 100644 --- a/src/CoordinateConvert.cpp +++ b/src/CoordinateConvert.cpp @@ -1,15 +1,15 @@ #include namespace scially { - void CoordinateConvert::setSourceSrs(const QString& srs, SrsType t) noexcept(false) { + void CoordinateConvert::setSourceSrs(const QString& srs, SrsType t) { setSrs(sourceSrs, srs, t); } - void CoordinateConvert::setTargetSrs(const QString& srs, SrsType t) noexcept(false) { + void CoordinateConvert::setTargetSrs(const QString& srs, SrsType t) { setSrs(targetSrs, srs, t); } - void CoordinateConvert::transform() noexcept(false) { + void CoordinateConvert::transform() { auto transform = createCoordinateTransformation(); double x = sourceX, y = sourceY; bool succeed = transform->Transform(1, &x, &y); diff --git a/src/GDALWrapper.cpp b/src/GDALWrapper.cpp deleted file mode 100644 index 8386d6f..0000000 --- a/src/GDALWrapper.cpp +++ /dev/null @@ -1 +0,0 @@ -#include \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index f52d8a0..a05f758 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,19 +1,16 @@ #include #include -#include #include #include -#include -#include #include int main(int argc, char** argv){ QCoreApplication app(argc, argv); QCoreApplication::setApplicationName("Cesium3DTilesConverter"); - QCoreApplication::setApplicationVersion("0.1"); + QCoreApplication::setApplicationVersion("0.2"); QTime beginTime = QTime::currentTime(); QCommandLineParser parser; - parser.setApplicationDescription("Convert osgb,shp to Cesium 3dtiles"); + parser.setApplicationDescription("Convert OSGB, GDAL to Cesium 3DTiles"); parser.addHelpOption(); parser.addVersionOption(); const QCommandLineOption inputOption("input", "input path", "input"); @@ -35,7 +32,6 @@ int main(int argc, char** argv){ const QCommandLineOption yUpAxis("yUpAxis", "y up axis", "yUpAxis"); parser.addOption(yUpAxis); - parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); parser.process(app); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 366e9fc..aaf5129 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,3 @@ - # TestGDAL add_executable(TestGDAL "TestGDAL.cpp") target_link_libraries(TestGDAL Qt5::Test Core) @@ -12,31 +11,4 @@ add_test(name Test3DTiles command Test3DTiles) # TestOSGBConvert add_executable(TestOSGBConvert "TestOSGBConvert.cpp") target_link_libraries(TestOSGBConvert Qt5::Test Core) -add_test(name TestOSGBConvert command TestOSGBConvert) - -# TestOSGBLevel -add_executable(TestOSGBLevel "TestOSGBLevel.cpp") -target_link_libraries(TestOSGBLevel Qt5::Test Core) -add_test(name TestOSGBLevel command TestOSGBLevel) - -# TestOSGBLevel -add_executable(TestOSGBConvertJob "TestOSGBConvertJob.cpp") -target_link_libraries(TestOSGBConvertJob Qt5::Test Core) -add_test(name TestOSGBConvertJob command TestOSGBConvertJob) - -#add_custom_command( -# TARGET CopyTestResources PRE_BUILD -# COMMAND ${CMAKE_COMMAND} -E copy_directory -# ${CMAKE_CURRENT_SOURCE_DIR}/data -# ${CMAKE_BINARY_DIR}/test/data) - -add_custom_target(CopyTestResources ALL) -add_custom_command( - TARGET CopyTestResources PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${PROJECT_SOURCE_DIR}/proj_data/proj.db - ${CMAKE_BINARY_DIR}/test/proj.db - COMMAND ${CMAKE_COMMAND} -E copy - ${PROJECT_SOURCE_DIR}/proj_data/proj.ini - ${CMAKE_BINARY_DIR}/test/proj.ini) - +add_test(name TestOSGBConvert command TestOSGBConvert) \ No newline at end of file diff --git a/test/Test3DTiles.cpp b/test/Test3DTiles.cpp index 8cee0d3..e83895d 100644 --- a/test/Test3DTiles.cpp +++ b/test/Test3DTiles.cpp @@ -1,483 +1 @@ -#include -#include -#include - -using namespace scially; - -class Test3DTILES : public QObject { - Q_OBJECT -private slots: - void testBoundingVolume() { - QJsonDocument doc = QJsonDocument::fromJson(R"( { - "region": [ - -1.2419052957251926, - 0.7395016240301894, - -1.2415404171917719, - 0.7396563300150859, - 0, - 20.4 - ] - })"); - BoundingVolume boundingVolume; - boundingVolume.read(doc.object()); - QVERIFY(boundingVolume.write() == doc.object()); - } - - void testAssetProperties() { - QJsonDocument doc = QJsonDocument::fromJson(R"({ - "version": "1.0", - "tilesetVersion": "e575c6f1-a45b-420a-b172-6449fa6e0a59" - })"); - AssetProperties asset; - asset.read(doc.object()); - QVERIFY(asset.assets.contains("version")); - QVERIFY(asset.assets.contains("tilesetVersion")); - QVERIFY(asset.assets["version"] == "1.0"); - QVERIFY(asset.assets["tilesetVersion"] == "e575c6f1-a45b-420a-b172-6449fa6e0a59"); - QVERIFY(asset.write() == doc.object()); - } - - void testTileMatrix() { - QJsonDocument doc = QJsonDocument::fromJson(R"({ "transform": [ - 4.843178171884396, 1.2424271388626869, 0, 0, - -0.7993325488216595, 3.1159251367235608, 3.8278032889280675, 0, - 0.9511533376784163, -3.7077466670407433, 3.2168186118075526, 0, - 1215001.7612985559, -4736269.697480114, 4081650.708604793, 1 - ]})"); - auto tileMatrix = TileMatrix(); - tileMatrix.read(doc.object()["transform"]); - QVERIFY(tileMatrix.write() == doc["transform"]); - } - - void testContentTile() { - QJsonDocument doc = QJsonDocument::fromJson(R"({ - "content": { - "uri": "0/0/0.b3dm", - "boundingVolume": { - "region": [ - -0.0004001690908972599, - 0.8988700116775743, - 0.00010096729722787196, - 0.8989625664878067, - 0, - 241.6 - ] - }}})"); - - auto content = ContentTile(); - content.read(doc["content"]); - QVERIFY(content.write() == doc["content"]); - } - - void testBaseTile() { - QJsonDocument doc = QJsonDocument::fromJson(R"({ - "asset": { - "version" : "1.0" - }, - "geometricError": 494.50961650991815, - "root": { - "boundingVolume": { - "region": [ - -0.0005682966577418737, - 0.8987233516605286, - 0.00011646582098558159, - 0.8990603398325034, - 0, - 241.6 - ] - }, - "content": { - "boundingVolume": { - "region": [ - -0.0004001690908972599, - 0.8988700116775743, - 0.00010096729722787196, - 0.8989625664878067, - 0, - 241.6 - ] - }, - "uri": "0/0/0.b3dm" - }, - "geometricError": 268.37878244706053, - "refine": "ADD", - "children": [ - { - "boundingVolume": { - "region": [ - -0.0004853062518095434, - 0.898741188925484, - -0.0002736676267127107, - 0.8989037314387226, - 0, - 158.4 - ] - }, - "content": { - "boundingVolume": { - "region": [ - -0.0004058588642587614, - 0.898746512179703, - -0.0002736676267127107, - 0.8989037314387226, - 0, - 158.4 - ] - }, - "uri": "1/0/0.b3dm" - }, - "geometricError": 159.43385994848, - "children": [ - { - "boundingVolume": { - "region": [ - -0.0004853062518095434, - 0.898741188925484, - -0.0003930656008416433, - 0.898818995703538, - 0, - 66.7 - ] - }, - "content": { - "uri": "2/0/0.b3dm" - }, - "geometricError": 10.831613588830955 - }, - { - "boundingVolume": { - "region": [ - -0.0003984063083527456, - 0.8987434753068045, - -0.00028070130359824817, - 0.8988027117816164, - 0, - 48.2 - ] - }, - "content": { - "uri": "2/1/0.b3dm" - }, - "geometricError": 11.833855250694043 - }, - { - "boundingVolume": { - "region": [ - -0.00039631191325035245, - 0.8988008442793176, - -0.000280491864088009, - 0.8989002407802179, - 0, - 78.1 - ] - }, - "content": { - "uri": "2/1/1.b3dm" - }, - "geometricError": 24.187299340965403 - }, - { - "boundingVolume": { - "region": [ - -0.00047979101137324135, - 0.8988092742196048, - -0.0003937113726648811, - 0.898901462510695, - 0, - 122.2 - ] - }, - "content": { - "uri": "2/0/1.b3dm" - }, - "geometricError": 48.508446081365975 - } - ] - }, - { - "boundingVolume": { - "region": [ - -0.0002874033679259065, - 0.8987233516605286, - 0.00009827949017980081, - 0.8988939226883266, - 0, - 75.2 - ] - }, - "content": { - "boundingVolume": { - "region": [ - -0.00028230700651008276, - 0.8987309438427749, - -0.00011402236003278958, - 0.8988939226883266, - 0, - 75.2 - ] - }, - "uri": "1/1/0.b3dm" - }, - "geometricError": 132.82048511777703, - "children": [ - { - "boundingVolume": { - "region": [ - -0.0002874033679259065, - 0.8987293381398633, - -0.00018024015185345448, - 0.8987995352823785, - 0, - 38.1 - ] - }, - "content": { - "uri": "2/2/0.b3dm" - }, - "geometricError": 4.206139430532202 - }, - { - "boundingVolume": { - "region": [ - -0.00018407987620784196, - 0.8987233516605286, - -0.0000894132175796695, - 0.8987836876927705, - 0, - 72.9 - ] - }, - "content": { - "uri": "2/3/0.b3dm" - }, - "geometricError": 0 - }, - { - "boundingVolume": { - "region": [ - -0.00018493508754131914, - 0.8987896218122265, - 0.00009827949017980081, - 0.8988920377327339, - 0, - 46.9 - ] - }, - "content": { - "uri": "2/3/1.b3dm" - }, - "geometricError": 0 - }, - { - "boundingVolume": { - "region": [ - -0.00027722809838677943, - 0.8987969696483782, - -0.00017832028967626075, - 0.8988916014004213, - 0, - 55.4 - ] - }, - "content": { - "uri": "2/2/1.b3dm" - }, - "geometricError": 0 - } - ] - }, - { - "boundingVolume": { - "region": [ - -0.0002821848334624433, - 0.8988867144785156, - 0.00011646582098558159, - 0.8990603398325034, - 0, - 158 - ] - }, - "content": { - "boundingVolume": { - "region": [ - -0.0002782229360604159, - 0.8989292306990948, - 0.000006946410422937427, - 0.899046220118855, - 0, - 158 - ] - }, - "uri": "1/1/1.b3dm" - }, - "geometricError": 156.46285780389445, - "children": [ - { - "boundingVolume": { - "region": [ - -0.00027865926837341453, - 0.8988880758353316, - -0.00014501940754820897, - 0.8989746092596459, - 0, - 77.3 - ] - }, - "content": { - "uri": "2/2/2.b3dm" - }, - "geometricError": 0 - }, - { - "boundingVolume": { - "region": [ - -0.00015598007525073333, - 0.8988867144785156, - 0.00011646582098558159, - 0.8989826028676196, - 0, - 106.2 - ] - }, - "content": { - "uri": "2/3/2.b3dm" - }, - "geometricError": 0 - }, - { - "boundingVolume": { - "region": [ - -0.00015252432333178438, - 0.8989769130942584, - 0.00003328342883553189, - 0.8990603398325034, - 0, - 67.9 - ] - }, - "content": { - "uri": "2/3/3.b3dm" - }, - "geometricError": 8.010233984367021 - }, - { - "boundingVolume": { - "region": [ - -0.0002821848334624433, - 0.8989765465751156, - -0.0001477072145962801, - 0.899040914317929, - 0, - 76 - ] - }, - "content": { - "uri": "2/2/3.b3dm" - }, - "geometricError": 40.38435697163592 - } - ] - }, - { - "boundingVolume": { - "region": [ - -0.0005682966577418737, - 0.8989007643789939, - -0.0002669481090925327, - 0.8990582279841088, - 0, - 204 - ] - }, - "content": { - "boundingVolume": { - "region": [ - -0.0005526410543514849, - 0.8989100669839071, - -0.0002669481090925327, - 0.8990037911647392, - 0, - 204 - ] - }, - "uri": "1/0/1.b3dm" - }, - "geometricError": 149.600454457028, - "children": [ - { - "boundingVolume": { - "region": [ - -0.0005474399731805417, - 0.8989017068567899, - -0.00040917498983755046, - 0.8990014698768336, - 0, - 81.2 - ] - }, - "content": { - "uri": "2/0/2.b3dm" - }, - "geometricError": 0 - }, - { - "boundingVolume": { - "region": [ - -0.00041203732981082115, - 0.8989007643789939, - -0.00027176521782803744, - 0.8989922894449685, - 0, - 108.7 - ] - }, - "content": { - "uri": "2/1/2.b3dm" - }, - "geometricError": 0 - }, - { - "boundingVolume": { - "region": [ - -0.0004253716452960582, - 0.8989891478523147, - -0.0002760587277879431, - 0.8990362368355337, - 0, - 30.1 - ] - }, - "content": { - "uri": "2/1/3.b3dm" - }, - "geometricError": 18.837170280352364 - }, - { - "boundingVolume": { - "region": [ - -0.0005682966577418737, - 0.8989984853638134, - -0.000407220221075317, - 0.8990582279841088, - 0, - 53.3 - ] - }, - "content": { - "uri": "2/0/3.b3dm" - }, - "geometricError": 67.4774528507299 - } - ] - } - ] - }})"); - BaseTile tile; - tile.read(doc.object()); - } - -}; - -QTEST_MAIN(Test3DTILES) - -#include "Test3DTiles.moc" +#include #include #include using namespace scially; class Test3DTILES : public QObject { Q_OBJECT private slots: void testBoundingVolume() { QJsonDocument doc = QJsonDocument::fromJson(R"( { "region": [ -1.2419052957251926, 0.7395016240301894, -1.2415404171917719, 0.7396563300150859, 0, 20.4 ] })"); BoundingVolume boundingVolume; boundingVolume.read(doc.object()); QVERIFY(boundingVolume.write() == doc.object()); } void testAssetProperties() { QJsonDocument doc = QJsonDocument::fromJson(R"({ "version": "1.0", "tilesetVersion": "e575c6f1-a45b-420a-b172-6449fa6e0a59" })"); AssetProperties asset; asset.read(doc.object()); QVERIFY(asset.assets.contains("version")); QVERIFY(asset.assets.contains("tilesetVersion")); QVERIFY(asset.assets["version"] == "1.0"); QVERIFY(asset.assets["tilesetVersion"] == "e575c6f1-a45b-420a-b172-6449fa6e0a59"); QVERIFY(asset.write() == doc.object()); } void testTileMatrix() { QJsonDocument doc = QJsonDocument::fromJson(R"({ "transform": [ 4.843178171884396, 1.2424271388626869, 0, 0, -0.7993325488216595, 3.1159251367235608, 3.8278032889280675, 0, 0.9511533376784163, -3.7077466670407433, 3.2168186118075526, 0, 1215001.7612985559, -4736269.697480114, 4081650.708604793, 1 ]})"); auto tileMatrix = TileMatrix(); tileMatrix.read(doc.object()["transform"]); QVERIFY(tileMatrix.write() == doc["transform"]); } void testContentTile() { QJsonDocument doc = QJsonDocument::fromJson(R"({ "content": { "uri": "0/0/0.b3dm", "boundingVolume": { "region": [ -0.0004001690908972599, 0.8988700116775743, 0.00010096729722787196, 0.8989625664878067, 0, 241.6 ] }}})"); auto content = ContentTile(); content.read(doc["content"]); QVERIFY(content.write() == doc["content"]); } void testBaseTile() { QJsonDocument doc = QJsonDocument::fromJson(R"({ "asset": { "version" : "1.0" }, "geometricError": 494.50961650991815, "root": { "boundingVolume": { "region": [ -0.0005682966577418737, 0.8987233516605286, 0.00011646582098558159, 0.8990603398325034, 0, 241.6 ] }, "content": { "boundingVolume": { "region": [ -0.0004001690908972599, 0.8988700116775743, 0.00010096729722787196, 0.8989625664878067, 0, 241.6 ] }, "uri": "0/0/0.b3dm" }, "geometricError": 268.37878244706053, "refine": "ADD", "children": [ { "boundingVolume": { "region": [ -0.0004853062518095434, 0.898741188925484, -0.0002736676267127107, 0.8989037314387226, 0, 158.4 ] }, "content": { "boundingVolume": { "region": [ -0.0004058588642587614, 0.898746512179703, -0.0002736676267127107, 0.8989037314387226, 0, 158.4 ] }, "uri": "1/0/0.b3dm" }, "geometricError": 159.43385994848, "children": [ { "boundingVolume": { "region": [ -0.0004853062518095434, 0.898741188925484, -0.0003930656008416433, 0.898818995703538, 0, 66.7 ] }, "content": { "uri": "2/0/0.b3dm" }, "geometricError": 10.831613588830955 }, { "boundingVolume": { "region": [ -0.0003984063083527456, 0.8987434753068045, -0.00028070130359824817, 0.8988027117816164, 0, 48.2 ] }, "content": { "uri": "2/1/0.b3dm" }, "geometricError": 11.833855250694043 }, { "boundingVolume": { "region": [ -0.00039631191325035245, 0.8988008442793176, -0.000280491864088009, 0.8989002407802179, 0, 78.1 ] }, "content": { "uri": "2/1/1.b3dm" }, "geometricError": 24.187299340965403 }, { "boundingVolume": { "region": [ -0.00047979101137324135, 0.8988092742196048, -0.0003937113726648811, 0.898901462510695, 0, 122.2 ] }, "content": { "uri": "2/0/1.b3dm" }, "geometricError": 48.508446081365975 } ] }, { "boundingVolume": { "region": [ -0.0002874033679259065, 0.8987233516605286, 0.00009827949017980081, 0.8988939226883266, 0, 75.2 ] }, "content": { "boundingVolume": { "region": [ -0.00028230700651008276, 0.8987309438427749, -0.00011402236003278958, 0.8988939226883266, 0, 75.2 ] }, "uri": "1/1/0.b3dm" }, "geometricError": 132.82048511777703, "children": [ { "boundingVolume": { "region": [ -0.0002874033679259065, 0.8987293381398633, -0.00018024015185345448, 0.8987995352823785, 0, 38.1 ] }, "content": { "uri": "2/2/0.b3dm" }, "geometricError": 4.206139430532202 }, { "boundingVolume": { "region": [ -0.00018407987620784196, 0.8987233516605286, -0.0000894132175796695, 0.8987836876927705, 0, 72.9 ] }, "content": { "uri": "2/3/0.b3dm" }, "geometricError": 0 }, { "boundingVolume": { "region": [ -0.00018493508754131914, 0.8987896218122265, 0.00009827949017980081, 0.8988920377327339, 0, 46.9 ] }, "content": { "uri": "2/3/1.b3dm" }, "geometricError": 0 }, { "boundingVolume": { "region": [ -0.00027722809838677943, 0.8987969696483782, -0.00017832028967626075, 0.8988916014004213, 0, 55.4 ] }, "content": { "uri": "2/2/1.b3dm" }, "geometricError": 0 } ] }, { "boundingVolume": { "region": [ -0.0002821848334624433, 0.8988867144785156, 0.00011646582098558159, 0.8990603398325034, 0, 158 ] }, "content": { "boundingVolume": { "region": [ -0.0002782229360604159, 0.8989292306990948, 0.000006946410422937427, 0.899046220118855, 0, 158 ] }, "uri": "1/1/1.b3dm" }, "geometricError": 156.46285780389445, "children": [ { "boundingVolume": { "region": [ -0.00027865926837341453, 0.8988880758353316, -0.00014501940754820897, 0.8989746092596459, 0, 77.3 ] }, "content": { "uri": "2/2/2.b3dm" }, "geometricError": 0 }, { "boundingVolume": { "region": [ -0.00015598007525073333, 0.8988867144785156, 0.00011646582098558159, 0.8989826028676196, 0, 106.2 ] }, "content": { "uri": "2/3/2.b3dm" }, "geometricError": 0 }, { "boundingVolume": { "region": [ -0.00015252432333178438, 0.8989769130942584, 0.00003328342883553189, 0.8990603398325034, 0, 67.9 ] }, "content": { "uri": "2/3/3.b3dm" }, "geometricError": 8.010233984367021 }, { "boundingVolume": { "region": [ -0.0002821848334624433, 0.8989765465751156, -0.0001477072145962801, 0.899040914317929, 0, 76 ] }, "content": { "uri": "2/2/3.b3dm" }, "geometricError": 40.38435697163592 } ] }, { "boundingVolume": { "region": [ -0.0005682966577418737, 0.8989007643789939, -0.0002669481090925327, 0.8990582279841088, 0, 204 ] }, "content": { "boundingVolume": { "region": [ -0.0005526410543514849, 0.8989100669839071, -0.0002669481090925327, 0.8990037911647392, 0, 204 ] }, "uri": "1/0/1.b3dm" }, "geometricError": 149.600454457028, "children": [ { "boundingVolume": { "region": [ -0.0005474399731805417, 0.8989017068567899, -0.00040917498983755046, 0.8990014698768336, 0, 81.2 ] }, "content": { "uri": "2/0/2.b3dm" }, "geometricError": 0 }, { "boundingVolume": { "region": [ -0.00041203732981082115, 0.8989007643789939, -0.00027176521782803744, 0.8989922894449685, 0, 108.7 ] }, "content": { "uri": "2/1/2.b3dm" }, "geometricError": 0 }, { "boundingVolume": { "region": [ -0.0004253716452960582, 0.8989891478523147, -0.0002760587277879431, 0.8990362368355337, 0, 30.1 ] }, "content": { "uri": "2/1/3.b3dm" }, "geometricError": 18.837170280352364 }, { "boundingVolume": { "region": [ -0.0005682966577418737, 0.8989984853638134, -0.000407220221075317, 0.8990582279841088, 0, 53.3 ] }, "content": { "uri": "2/0/3.b3dm" }, "geometricError": 67.4774528507299 } ] } ] }})"); BaseTile tile; tile.read(doc.object()); } }; QTEST_MAIN(Test3DTILES) #include "Test3DTiles.moc" \ No newline at end of file diff --git a/test/TestOSGBConvert.cpp b/test/TestOSGBConvert.cpp index 4b97249..d9a180c 100644 --- a/test/TestOSGBConvert.cpp +++ b/test/TestOSGBConvert.cpp @@ -1,7 +1,6 @@ #include #include - using namespace scially; class TestOSGBConvert : public QObject { diff --git a/test/TestOSGBConvertJob.cpp b/test/TestOSGBConvertJob.cpp deleted file mode 100644 index 16c422a..0000000 --- a/test/TestOSGBConvertJob.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -using namespace scially; - -class TestOSGBConvertJob : public QObject { - Q_OBJECT -private slots: - void testOSGBConvertJob() { - OSGBConvertJob convertJob("./Production_3", "./"); - convertJob.run(); - } -}; - -QTEST_MAIN(TestOSGBConvertJob) - -#include "TestOSGBConvertJob.moc" diff --git a/test/TestOSGBLevel.cpp b/test/TestOSGBLevel.cpp deleted file mode 100644 index fe4bc40..0000000 --- a/test/TestOSGBLevel.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - -using namespace scially; - -class TestOSGBLevel : public QObject { - Q_OBJECT -private slots: - void testOSGBConvert() { - OSGBLevel level("./Production_3/Data/Tile_+000_+000/Tile_+000_+000.osgb"); - BaseTile tile; - level.convertTiles(tile, "./"); - } -}; - -QTEST_MAIN(TestOSGBLevel) - -#include "TestOSGBLevel.moc"