diff --git a/CMakeLists.txt b/CMakeLists.txt index ab8419d..f62d574 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.8) -project(Cesium3DTilesConverter) +project(Cesium3DTilesConverter VERSION 3.0.0) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_CXX_STANDARD 17) @@ -40,81 +40,37 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -add_library(Core STATIC - "include/CoordinateConvert.h" - "include/OGRException.h" - "include/OSGBPageLodVisitor.h" - "include/OSGBLevel.h" - "include/BoundingVolume.h" - "include/BoundingVolumeBox.h" - "include/BoundingVolumeRegion.h" - "include/AssetProperties.h" - "include/BoundingVolumeSphere.h" - "include/TileMatrix.h" - "include/Refine.h" - "include/ContentTile.h" - "include/RootTile.h" - "include/BaseTile.h" - "include/OSGBuildState.h" - "include/stb_image.h" - "include/stb_image_write.h" - "include/tiny_gltf.h" - "include/TilesParseException.h" - "include/TilesConvertException.h" - "include/OSGBConvertJob.h" - "include/ShpConvertJob.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" +file(GLOB_RECURSE PROJECT_HEADERS + "include/*.h" + "include/*.hpp" +) - "src/CoordinateConvert.cpp" - "src/OSGBPageLodVisitor.cpp" - "src/BoundingVolume.cpp" - "src/BoundingVolumeBox.cpp" - "src/BoundingVolumeRegion.cpp" - "src/BoundingVolumeSphere.cpp" - "src/AssetProperties.cpp" - "src/TileMatrix.cpp" - "src/Refine.cpp" - "src/ContentTile.cpp" - "src/RootTile.cpp" - "src/BaseTile.cpp" - "src/DxtImage.cpp" - "src/OSGBuildState.cpp" - "src/OSGBLevel.cpp" - "src/OSGBConvert.cpp" - "src/OSGBConvertJob.cpp" - "src/ModelMetadata.cpp" - "src/QuadTree.cpp" - "src/GeometryMesh.cpp" - "src/Batched3DModel.cpp" - "src/ShpConvert.cpp" - "src/ShpConvertJob.cpp") +file(GLOB_RECURSE PROJECT_SRCS + "src/*.cpp" +) -target_link_libraries(Core +add_executable(Converter + ${PROJECT_HEADERS} + ${PROJECT_SRCS} +) + +target_link_libraries(Converter ${GDAL_LIBRARIES} ${PROJ_LIBRARIES} ${OPENSCENEGRAPH_LIBRARIES} Qt5::Xml Qt5::Core) -if(UNIX) - target_link_libraries(Core -lGL) -endif() +add_custom_command(TARGET Converter POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/share/proj_data ${EXECUTABLE_OUTPUT_PATH}/proj_data + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/share/gdal_data ${EXECUTABLE_OUTPUT_PATH}/gdal_data +) -add_executable(Converter src/main.cpp) -target_link_libraries(Converter - Core) +if (WIN32) + get_target_property(QT5_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION) + get_filename_component(QT5_WINDEPLOYQT_EXECUTABLE ${QT5_QMAKE_EXECUTABLE} PATH) + set(QT5_WINDEPLOYQT_EXECUTABLE "${QT5_WINDEPLOYQT_EXECUTABLE}/windeployqt.exe") -add_custom_command(TARGET Converter - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/proj_data ${EXECUTABLE_OUTPUT_PATH}/proj_data - COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/gdal_data ${EXECUTABLE_OUTPUT_PATH}/gdal_data - COMMAND ${CMAKE_COMMAND} -E copy $ $ - COMMAND ${CMAKE_COMMAND} -E copy $ $ -) \ No newline at end of file + add_custom_command(TARGET Converter POST_BUILD + COMMAND ${QT5_WINDEPLOYQT_EXECUTABLE} $) +endif(WIN32) \ No newline at end of file diff --git a/README.md b/README.md index c5df60d..dba141e 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Converter.exe --format gdal --input --output --field height -- 图层中需要有字段来表示高度信息。 # How To Build -1. vcpkg install "osg" "osg[plugins]" +1. vcpkg install "gdal" "osg" "osg[plugins]" 2. 如果没有Qt5.15,可以通过以下两种方式安装: 1. 通过Qt官网安装 2. vcpkg install "qt5[all]" diff --git a/data/Tile_+007_+078.osgb b/data/Tile_+007_+078.osgb deleted file mode 100644 index ac2355f..0000000 Binary files a/data/Tile_+007_+078.osgb and /dev/null differ diff --git a/data/Tile_+007_+078_L15_0.osgb b/data/Tile_+007_+078_L15_0.osgb deleted file mode 100644 index b183c52..0000000 Binary files a/data/Tile_+007_+078_L15_0.osgb and /dev/null differ diff --git a/data/Tile_+007_+078_L16_03.osgb b/data/Tile_+007_+078_L16_03.osgb deleted file mode 100644 index fd7f6de..0000000 Binary files a/data/Tile_+007_+078_L16_03.osgb and /dev/null differ diff --git a/data/Tile_+007_+078_L17_000.osgb b/data/Tile_+007_+078_L17_000.osgb deleted file mode 100644 index 937f0ea..0000000 Binary files a/data/Tile_+007_+078_L17_000.osgb and /dev/null differ diff --git a/data/Tile_+007_+078_L17_001.osgb b/data/Tile_+007_+078_L17_001.osgb deleted file mode 100644 index dd8cb98..0000000 Binary files a/data/Tile_+007_+078_L17_001.osgb and /dev/null differ diff --git a/data/Tile_+007_+078_L17_002.osgb b/data/Tile_+007_+078_L17_002.osgb deleted file mode 100644 index 244df8b..0000000 Binary files a/data/Tile_+007_+078_L17_002.osgb and /dev/null differ diff --git a/data/Tile_+007_+078_L17_003.osgb b/data/Tile_+007_+078_L17_003.osgb deleted file mode 100644 index ae18d99..0000000 Binary files a/data/Tile_+007_+078_L17_003.osgb and /dev/null differ diff --git a/data/Tile_+007_+078_L17_004.osgb b/data/Tile_+007_+078_L17_004.osgb deleted file mode 100644 index 6b42ed2..0000000 Binary files a/data/Tile_+007_+078_L17_004.osgb and /dev/null differ diff --git a/include/AssetProperties.h b/include/AssetProperties.h deleted file mode 100644 index d39a752..0000000 --- a/include/AssetProperties.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -namespace scially { - class AssetProperties : public BaseObject { - public: - using AssetPropertiesPtr = QSharedPointer; - - virtual QJsonValue write() override; - virtual void read(const QJsonValue& object) override; - - virtual QString typeName() override { - return "asset"; - } - virtual ~AssetProperties() {} - QMap assets; - }; -} - diff --git a/include/BaseObject.h b/include/BaseObject.h deleted file mode 100644 index 3086f9f..0000000 --- a/include/BaseObject.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include -#include -#include -namespace scially { - class BaseObject { - public: - using BasePtr = QSharedPointer; - - virtual QJsonValue write() = 0; - virtual void read(const QJsonValue& object) = 0; - virtual QString typeName() = 0; - virtual ~BaseObject() {} - protected: - static bool required(const QJsonValue& object, QJsonValue::Type type) { - return object.type() == type; - } - }; -} \ No newline at end of file diff --git a/include/BoundingVolume.h b/include/BoundingVolume.h deleted file mode 100644 index 9060806..0000000 --- a/include/BoundingVolume.h +++ /dev/null @@ -1,96 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace scially { - - class BoundingVolume : public BaseObject { - public: - BoundingVolume() = default; - explicit BoundingVolume(const BoundingVolumeBox &box): box(box){} - explicit BoundingVolume(const BoundingVolumeRegion ®ion): region(region){} - explicit BoundingVolume(const BoundingVolumeSphere &sphere): sphere(sphere){} - - virtual QString typeName() override { - return "boundingVolume"; - } - - virtual QJsonValue write() override{ - if(box.has_value()){ - return box->write(); - }else if(region.has_value()){ - return region->write(); - }else if(sphere.has_value()){ - return sphere->write(); - }else{ - // TODO: BoundingVolume type must be box,region,sphere - qCritical() << "BoundingVolume not set"; - return QJsonValue(); - } - } - - bool hasValue() const { - return box.has_value() || region.has_value() || sphere.has_value(); - } - - inline BoundingVolume& operator =(const BoundingVolumeBox &box) { - this->box = box; - return *this; - } - inline BoundingVolume& operator =(const BoundingVolumeRegion ®ion){ - this->region = region; - return *this; - } - inline BoundingVolume& operator =(const BoundingVolumeSphere &sphere){ - this->sphere = sphere; - return *this; - } - - virtual void read(const QJsonValue& object) override{ - if (object.type() != QJsonValue::Object) { - qCritical() << "value is not BoundingVolume\n"; - return; - } - - QJsonObject bounding = object.toObject(); - if(bounding.keys().size() != 1){ - qCritical() << "BoundingVolume type must specideifed \n"; - return; - } - QString boundingType = bounding.keys().at(0); - if(boundingType == "box"){ - BoundingVolumeBox boxResult; - boxResult.read(bounding[boundingType]); - box = boxResult; - }else if(boundingType == "region"){ - BoundingVolumeRegion regionResult; - regionResult.read(bounding[boundingType]); - region = regionResult; - }else if(boundingType == "sphere"){ - BoundingVolumeSphere sphereResult; - sphereResult.read(bounding[boundingType]); - sphere = sphereResult; - }else{ - qCritical() << "BoundingVolume type must be box,region,sphere\n"; - } - - } - - virtual ~BoundingVolume() {} - - std::optional box; - std::optional region; - std::optional sphere; - }; -} - diff --git a/include/Cesium3DTiles/AssetProperties.h b/include/Cesium3DTiles/AssetProperties.h new file mode 100644 index 0000000..ae0e587 --- /dev/null +++ b/include/Cesium3DTiles/AssetProperties.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +namespace scially { + struct AssetProperties { + static constexpr const char* TypeName = "asset"; + + QJsonObject write() const; + void read(const QJsonObject& object); + + QVariantMap assets; + }; +} + diff --git a/include/BaseTile.h b/include/Cesium3DTiles/BaseTile.h similarity index 61% rename from include/BaseTile.h rename to include/Cesium3DTiles/BaseTile.h index 921afa0..e45705a 100644 --- a/include/BaseTile.h +++ b/include/Cesium3DTiles/BaseTile.h @@ -1,20 +1,10 @@ #pragma once -#include -#include -#include -#include +#include +#include -#include -#include -#include -#include -#include #include -#include -#include #include -#include namespace scially { /// @@ -29,18 +19,10 @@ namespace scially { /// root |A tile in a 3D Tiles tileset. |ContentTile |Required /// ----------------------------------------------------------------------------- /// - class BaseTile : public BaseObject { - public: - using BaseTilePtr = QSharedPointer; - - BaseTile() {} - virtual QJsonValue write() override; - virtual void read(const QJsonValue& object) override; + struct BaseTile{ + QJsonObject write() const; + void read(const QJsonObject& object); - virtual QString typeName() override { - return ""; - } - virtual ~BaseTile() {} AssetProperties asset; double geometricError; RootTile root; diff --git a/include/Batched3DModel.h b/include/Cesium3DTiles/Batched3DModel.h similarity index 92% rename from include/Batched3DModel.h rename to include/Cesium3DTiles/Batched3DModel.h index 5cd32b3..5f8e8f5 100644 --- a/include/Batched3DModel.h +++ b/include/Cesium3DTiles/Batched3DModel.h @@ -5,8 +5,9 @@ #include namespace scially { - class Batched3DModel { - public: + struct Batched3DModel { + QByteArray write(bool withHeight = false) const; + // feature table and feature binary int batchLength = 0; QByteArray featureBinary; @@ -16,7 +17,5 @@ namespace scially { QVector heights; // glb buffer QByteArray glbBuffer; - - QByteArray write(bool withHeight = false) const; }; } \ No newline at end of file diff --git a/include/Cesium3DTiles/BoundingVolume.h b/include/Cesium3DTiles/BoundingVolume.h new file mode 100644 index 0000000..e63028d --- /dev/null +++ b/include/Cesium3DTiles/BoundingVolume.h @@ -0,0 +1,34 @@ +#pragma once + +#include +#include +#include + +#include + +#include +#include +#include + +namespace scially { + struct BoundingVolume { + public: + static constexpr const char* TypeName = "boundingVolume"; + + BoundingVolume() = default; + BoundingVolume(const BoundingVolumeBox& b) : box(b) {} + BoundingVolume(const BoundingVolumeRegion& r) : region(r) {} + BoundingVolume(const BoundingVolumeSphere& s) : sphere(s) {} + + QJsonObject write() const; + void read(const QJsonObject& object); + bool hasValue() const { + return box.has_value() || region.has_value() || sphere.has_value(); + } + + std::optional box; + std::optional region; + std::optional sphere; + }; +} + diff --git a/include/BoundingVolumeBox.h b/include/Cesium3DTiles/BoundingVolumeBox.h similarity index 69% rename from include/BoundingVolumeBox.h rename to include/Cesium3DTiles/BoundingVolumeBox.h index 6bd0742..72ee8c8 100644 --- a/include/BoundingVolumeBox.h +++ b/include/Cesium3DTiles/BoundingVolumeBox.h @@ -1,10 +1,8 @@ #pragma once -#include -#include +#include + #include -#include -#include namespace scially { /// @@ -16,61 +14,58 @@ namespace scially { /// The next three elements (indices 6, 7, and 8) define the y-axis direction and half-length. /// The last three elements (indices 9, 10, and 11) define the z-axis direction and half-length. /// - class BoundingVolumeBox : public BaseObject { - public: - explicit BoundingVolumeBox(BoundingVolumeRegion r): region(r){} + struct BoundingVolumeBox{ + static constexpr const char* TypeName = "box"; + BoundingVolumeBox() = default; + BoundingVolumeBox(BoundingVolumeRegion r) : region(r) {} - double centerX() { + QJsonArray write() const; + void read(const QJsonArray& object); + double centerX() const{ return (region.east + region.west) / 2; } - double centerY() { + double centerY() const { return (region.north + region.south) / 2; } - double centerZ() { + double centerZ() const { return (region.minHeight + region.maxHeight) / 2; } - double directionX0 () { + double directionX0 () const { return 0; } - double directionX1 () { + double directionX1 () const { return 0; } - double halfXLength () { + double halfXLength () const { return (region.east - region.west) / 2; } - double directionY0() { + double directionY0() const { return 0; } - double directionY1() { + double directionY1() const { return 0; } - double halfYLength () { + double halfYLength () const { return (region.north - region.south) / 2; } - double directionZ0 () { + double directionZ0 () const { return 0; } - double directionZ1() { + double directionZ1() const { return 0; } - double halfZLength () { + double halfZLength () const { return (region.maxHeight - region.minHeight) / 2; } - virtual QJsonValue write() override; - virtual void read(const QJsonValue& object) override; - virtual QString typeName() override { - return "box"; - } - void setMax(const osg::Vec3d& max); void setMin(const osg::Vec3d& min); void setMax(const osg::Vec3f& max); @@ -87,8 +82,6 @@ namespace scially { osg::Vec3d getMax() const; osg::Vec3d getMin() const; - virtual ~BoundingVolumeBox() {} - private: BoundingVolumeRegion region; }; } diff --git a/include/BoundingVolumeRegion.h b/include/Cesium3DTiles/BoundingVolumeRegion.h similarity index 85% rename from include/BoundingVolumeRegion.h rename to include/Cesium3DTiles/BoundingVolumeRegion.h index 275b5dc..5727152 100644 --- a/include/BoundingVolumeRegion.h +++ b/include/Cesium3DTiles/BoundingVolumeRegion.h @@ -1,17 +1,16 @@ #pragma once +#include + #include +#include #include #include #include #include -#include -#include -#include namespace scially { - /// /// The boundingVolume.region property is an array of six numbers that define the bounding geographic region /// with latitude, longitude, and height coordinates with the order @@ -19,21 +18,10 @@ namespace scially { /// Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians. /// Heights are in meters above (or below) the WGS 84 ellipsoid. /// - class BoundingVolumeRegion : public BaseObject { - public: - using BoundingVolumeRegionPtr = QSharedPointer; - double west = std::numeric_limits::max(); - double south = std::numeric_limits::max(); - double east = std::numeric_limits::min(); - double north = std::numeric_limits::min(); - double minHeight = std::numeric_limits::max(); - double maxHeight = std::numeric_limits::min(); - - virtual QJsonValue write() override; - virtual void read(const QJsonValue& object) override; - virtual QString typeName() override { - return "region"; - }; + struct BoundingVolumeRegion { + static constexpr const char* TypeName = "region"; + QJsonArray write() const; + void read(const QJsonArray& object); osg::Vec3d getMax() const; osg::Vec3d getMin() const; @@ -67,6 +55,12 @@ namespace scially { BoundingVolumeRegion toRadin(double lon, double lat) const; static BoundingVolumeRegion fromCenterXY(double centerX, double centerY, double xLength, double yLength, double minHeight, double maxHeight); - virtual ~BoundingVolumeRegion() {} + + double west = std::numeric_limits::max(); + double south = std::numeric_limits::max(); + double east = std::numeric_limits::min(); + double north = std::numeric_limits::min(); + double minHeight = std::numeric_limits::max(); + double maxHeight = std::numeric_limits::min(); }; } diff --git a/include/BoundingVolumeSphere.h b/include/Cesium3DTiles/BoundingVolumeSphere.h similarity index 64% rename from include/BoundingVolumeSphere.h rename to include/Cesium3DTiles/BoundingVolumeSphere.h index ed3e704..ce63a14 100644 --- a/include/BoundingVolumeSphere.h +++ b/include/Cesium3DTiles/BoundingVolumeSphere.h @@ -2,12 +2,10 @@ #include -#include #include #include #include - namespace scially { /// /// The boundingVolume.sphere property is an array of four numbers that define a bounding sphere. @@ -15,18 +13,15 @@ namespace scially { /// for the center of the sphere in a right-handed 3-axis (x, y, z) Cartesian coordinate system where the z-axis is up. /// The last element (with index 3) defines the radius in meters. /// - class BoundingVolumeSphere : public BaseObject { - public: + struct BoundingVolumeSphere { + static constexpr const char* TypeName = "sphere"; + + QJsonArray write() const; + void read(const QJsonArray& object); + double centerX = std::numeric_limits::min(); double centerY = std::numeric_limits::min(); double centerZ = std::numeric_limits::min(); - double radius = std::numeric_limits::min(); - - virtual QJsonValue write() override; - virtual void read(const QJsonValue& object) override; - virtual QString typeName() override { - return "sphere"; - } - virtual ~BoundingVolumeSphere() {} + double radius = std::numeric_limits::min(); }; } diff --git a/include/ContentTile.h b/include/Cesium3DTiles/Content.h similarity index 66% rename from include/ContentTile.h rename to include/Cesium3DTiles/Content.h index f5fd0bd..7981c4f 100644 --- a/include/ContentTile.h +++ b/include/Cesium3DTiles/Content.h @@ -1,11 +1,10 @@ #pragma once -#include -#include +#include + #include #include -#include -#include + namespace scially { /// /// Metadata about the tile's content and a link to the content. @@ -17,18 +16,13 @@ namespace scially { /// uri |A uri that points to the tile's content. |string |Required /// ------------------------------------------------------------------------------------------------- /// - class ContentTile : public BaseObject { - public: - using ContentTilePtr = QSharedPointer; + struct Content { + static constexpr const char* TypeName = "content"; - ContentTile() {} - virtual QJsonValue write() override; - virtual void read(const QJsonValue& object) override; - virtual QString typeName() override { - return "content"; - } + QJsonObject write() const; + void read(const QJsonObject& object); - std::optional boundingVolume; + BoundingVolume boundingVolume; QString uri; }; diff --git a/include/Cesium3DTiles/Refine.h b/include/Cesium3DTiles/Refine.h new file mode 100644 index 0000000..e4affaf --- /dev/null +++ b/include/Cesium3DTiles/Refine.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +namespace scially { + /// + /// Refinement determines the process by which a lower resolution parent tile renders + /// when its higher resolution children are selected to be rendered. + /// Permitted refinement types are replacement ("REPLACE") and additive ("ADD") + /// + struct Refine { + static constexpr const char* TypeName = "refine"; + + void read(const QString& object) { type = object; } + QString write() const { return type; } + + QString type = "REPLACE"; + }; + +} diff --git a/include/RootTile.h b/include/Cesium3DTiles/RootTile.h similarity index 73% rename from include/RootTile.h rename to include/Cesium3DTiles/RootTile.h index 1c5d73d..1f7d24e 100644 --- a/include/RootTile.h +++ b/include/Cesium3DTiles/RootTile.h @@ -1,13 +1,9 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include namespace scially { @@ -29,25 +25,18 @@ namespace scially { /// children |An array of objects that define child tiles |RootTile[] | /// -------------------------------------------------------------------------------------------------------- /// - class RootTile : public BaseObject { - public: - using RootTilePtr = QSharedPointer; + struct RootTile{ + static constexpr const char* TypeName = "root"; - virtual QJsonValue write() override; - virtual void read(const QJsonValue& object) override; - virtual QString typeName() override { - return "root"; - } - - RootTile(); - virtual ~RootTile() {} + QJsonObject write() const; + void read(const QJsonObject& object); BoundingVolume boundingVolume; - TileMatrix transform; + Transform transform; double geometricError = 0; Refine refine; - std::optional content; - QVector children; + std::optional content; + QVector children; }; } diff --git a/include/TileMatrix.h b/include/Cesium3DTiles/Transform.h similarity index 61% rename from include/TileMatrix.h rename to include/Cesium3DTiles/Transform.h index f32466a..77bc699 100644 --- a/include/TileMatrix.h +++ b/include/Cesium3DTiles/Transform.h @@ -1,12 +1,10 @@ #pragma once -#include -#include +#include + #include #include #include -#include -#include namespace scially { /// @@ -14,16 +12,14 @@ namespace scially { /// transforms from the tile's local coordinate system to the parent tile's coordinate system or /// the tileset's coordinate system in the case of the root tile. /// - class TileMatrix : public BaseObject, public osg::Matrixd { - public: - using TileMatrixPtr = QSharedPointer; - - TileMatrix(): Matrixd(1, 0, 0, 0, + struct Transform : public osg::Matrixd { + static constexpr const char* TypeName = "transform"; + Transform(): Matrixd(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) {} - TileMatrix(double m11, double m12, double m13, double m14, + Transform(double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44) @@ -33,16 +29,9 @@ namespace scially { m31, m32, m33, m34, m41, m42, m43, m44){} - virtual QJsonValue write() override; - - virtual void read(const QJsonValue& object) override; - - virtual QString typeName() override { - return "transform"; - } - - static TileMatrix fromXYZ(double lon, double lat, double height); - + QJsonArray write() const; + void read(const QJsonArray& object); + static Transform fromXYZ(double lon, double lat, double height); }; diff --git a/include/GDALWrapper.h b/include/GDALWrapper.h index 3f2db61..a5c917c 100644 --- a/include/GDALWrapper.h +++ b/include/GDALWrapper.h @@ -2,12 +2,12 @@ #include +#include + #include #include #include -#include - namespace scially { class GDALDriverWrapper { public: diff --git a/include/GeometryMesh.h b/include/GeometryMesh.h index 3233511..09156c1 100644 --- a/include/GeometryMesh.h +++ b/include/GeometryMesh.h @@ -5,13 +5,12 @@ #include #include #include -#include + #include #include #include #include - namespace scially { class GeometryMesh { public: diff --git a/include/ModelMetadata.h b/include/ModelMetadata.h index 6b00fb8..f9a7aef 100644 --- a/include/ModelMetadata.h +++ b/include/ModelMetadata.h @@ -2,7 +2,6 @@ #include - namespace scially { class ModelMetadata { public: diff --git a/include/OSGBConvert.h b/include/OSGBConvert.h index 3a86bec..a5abb82 100644 --- a/include/OSGBConvert.h +++ b/include/OSGBConvert.h @@ -1,13 +1,15 @@ #pragma once +#include +#include + #include #include #include #include #include #include -#include -#include + namespace scially { class OSGBConvert { diff --git a/include/OSGBConvertJob.h b/include/OSGBConvertJob.h index f74129d..70f74e2 100644 --- a/include/OSGBConvertJob.h +++ b/include/OSGBConvertJob.h @@ -1,10 +1,10 @@ #pragma once #include + #include #include #include -#include #include #include #include diff --git a/include/OSGBLevel.h b/include/OSGBLevel.h index 9343c12..8ac3a6f 100644 --- a/include/OSGBLevel.h +++ b/include/OSGBLevel.h @@ -1,9 +1,10 @@ #pragma once +#include +#include #include #include -#include -#include + #include #include #include @@ -39,8 +40,7 @@ namespace scially { QString absoluteLocation() const; /// - /// 提取 Tile_+154_+018_L22_0000320.osgb _L后面的数字 - /// 提取失败,返回 0 + /// get Tile_+154_+018_L22_0000320.osgb _L level /// int getLevelNumber() const; QString getTileName() const; diff --git a/include/OSGBPageLodVisitor.h b/include/OSGBPageLodVisitor.h index cab6ae0..e331bae 100644 --- a/include/OSGBPageLodVisitor.h +++ b/include/OSGBPageLodVisitor.h @@ -1,5 +1,9 @@ #pragma once +#include +#include +#include + #include #include #include @@ -10,10 +14,6 @@ #include #include -#include -#include -#include - namespace scially { class OSGBPageLodVisitor : public osg::NodeVisitor diff --git a/include/OSGBuildState.h b/include/OSGBuildState.h index 3620f0f..c3f9a44 100644 --- a/include/OSGBuildState.h +++ b/include/OSGBuildState.h @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #include #include diff --git a/include/QuadTree.h b/include/QuadTree.h index 2303db0..dbd9e0f 100644 --- a/include/QuadTree.h +++ b/include/QuadTree.h @@ -1,7 +1,9 @@ #pragma once #include + #include + #include #include diff --git a/include/Refine.h b/include/Refine.h deleted file mode 100644 index ab3e61d..0000000 --- a/include/Refine.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -namespace scially { - /// - /// Refinement determines the process by which a lower resolution parent tile renders - /// when its higher resolution children are selected to be rendered. - /// Permitted refinement types are replacement ("REPLACE") and additive ("ADD") - /// - class Refine : public BaseObject { - public: - virtual void read(const QJsonValue& object) override; - virtual QJsonValue write() override; - virtual QString typeName() override { - return "refine"; - } - Refine& operator =(const QString &type) { - this->type = type; - return *this; - } - - Refine() = default; - QString type = "REPLACE"; - }; - -} diff --git a/include/ShpConvert.h b/include/ShpConvert.h index f631c56..f33a978 100644 --- a/include/ShpConvert.h +++ b/include/ShpConvert.h @@ -1,13 +1,14 @@ #pragma once -#include -#include -#include #include #include #include #include +#include +#include +#include + namespace scially { class ShpConvert { public: diff --git a/include/ShpConvertJob.h b/include/ShpConvertJob.h index a78236a..a7b8ef0 100644 --- a/include/ShpConvertJob.h +++ b/include/ShpConvertJob.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace scially { diff --git a/include/TilesParseException.h b/include/TilesParseException.h deleted file mode 100644 index 100597a..0000000 --- a/include/TilesParseException.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace scially { - class TilesParseException : public QException { - public: - TilesParseException(const char* err) : err(err) {} - virtual const char* what() const noexcept override { - return err; - } - private: - const char* err; - }; -} diff --git a/include/Utils.h b/include/Utils.h index 91c589e..0d5553e 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -5,6 +5,7 @@ #include #include #include + #include namespace scially { @@ -54,10 +55,4 @@ namespace scially { } return arr; } - - inline QByteArray jsonDump(QJsonObject json, QJsonDocument::JsonFormat format = QJsonDocument::Compact) { - QJsonDocument doc(json); - return doc.toJson(format); - } - } \ No newline at end of file diff --git a/include/earcut.hpp b/include/earcut/earcut.hpp similarity index 100% rename from include/earcut.hpp rename to include/earcut/earcut.hpp diff --git a/include/json.hpp b/include/tiny_gltf/json.hpp similarity index 100% rename from include/json.hpp rename to include/tiny_gltf/json.hpp diff --git a/include/stb_image.h b/include/tiny_gltf/stb_image.h similarity index 100% rename from include/stb_image.h rename to include/tiny_gltf/stb_image.h diff --git a/include/stb_image_write.h b/include/tiny_gltf/stb_image_write.h similarity index 100% rename from include/stb_image_write.h rename to include/tiny_gltf/stb_image_write.h diff --git a/include/tiny_gltf.h b/include/tiny_gltf/tiny_gltf.h similarity index 99% rename from include/tiny_gltf.h rename to include/tiny_gltf/tiny_gltf.h index 5cb7e89..b3bd74d 100644 --- a/include/tiny_gltf.h +++ b/include/tiny_gltf/tiny_gltf.h @@ -2617,6 +2617,7 @@ namespace tinygltf { json v; #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && not defined(TINYGLTF_NOEXCEPTION) + try { v = json::parse(str, str + length); diff --git a/gdal_data/GDALLogoBW.svg b/share/gdal_data/GDALLogoBW.svg similarity index 100% rename from gdal_data/GDALLogoBW.svg rename to share/gdal_data/GDALLogoBW.svg diff --git a/gdal_data/GDALLogoColor.svg b/share/gdal_data/GDALLogoColor.svg similarity index 100% rename from gdal_data/GDALLogoColor.svg rename to share/gdal_data/GDALLogoColor.svg diff --git a/gdal_data/GDALLogoGS.svg b/share/gdal_data/GDALLogoGS.svg similarity index 100% rename from gdal_data/GDALLogoGS.svg rename to share/gdal_data/GDALLogoGS.svg diff --git a/gdal_data/LICENSE.TXT b/share/gdal_data/LICENSE.TXT similarity index 100% rename from gdal_data/LICENSE.TXT rename to share/gdal_data/LICENSE.TXT diff --git a/gdal_data/bag_template.xml b/share/gdal_data/bag_template.xml similarity index 100% rename from gdal_data/bag_template.xml rename to share/gdal_data/bag_template.xml diff --git a/gdal_data/copyright b/share/gdal_data/copyright similarity index 100% rename from gdal_data/copyright rename to share/gdal_data/copyright diff --git a/gdal_data/cubewerx_extra.wkt b/share/gdal_data/cubewerx_extra.wkt similarity index 100% rename from gdal_data/cubewerx_extra.wkt rename to share/gdal_data/cubewerx_extra.wkt diff --git a/gdal_data/default.rsc b/share/gdal_data/default.rsc similarity index 100% rename from gdal_data/default.rsc rename to share/gdal_data/default.rsc diff --git a/gdal_data/ecw_cs.wkt b/share/gdal_data/ecw_cs.wkt similarity index 100% rename from gdal_data/ecw_cs.wkt rename to share/gdal_data/ecw_cs.wkt diff --git a/gdal_data/eedaconf.json b/share/gdal_data/eedaconf.json similarity index 100% rename from gdal_data/eedaconf.json rename to share/gdal_data/eedaconf.json diff --git a/gdal_data/epsg.wkt b/share/gdal_data/epsg.wkt similarity index 100% rename from gdal_data/epsg.wkt rename to share/gdal_data/epsg.wkt diff --git a/gdal_data/esri_StatePlane_extra.wkt b/share/gdal_data/esri_StatePlane_extra.wkt similarity index 100% rename from gdal_data/esri_StatePlane_extra.wkt rename to share/gdal_data/esri_StatePlane_extra.wkt diff --git a/gdal_data/gdalicon.png b/share/gdal_data/gdalicon.png similarity index 100% rename from gdal_data/gdalicon.png rename to share/gdal_data/gdalicon.png diff --git a/gdal_data/gdalmdiminfo_output.schema.json b/share/gdal_data/gdalmdiminfo_output.schema.json similarity index 100% rename from gdal_data/gdalmdiminfo_output.schema.json rename to share/gdal_data/gdalmdiminfo_output.schema.json diff --git a/gdal_data/gdalvrt.xsd b/share/gdal_data/gdalvrt.xsd similarity index 100% rename from gdal_data/gdalvrt.xsd rename to share/gdal_data/gdalvrt.xsd diff --git a/gdal_data/gml_registry.xml b/share/gdal_data/gml_registry.xml similarity index 100% rename from gdal_data/gml_registry.xml rename to share/gdal_data/gml_registry.xml diff --git a/gdal_data/gmlasconf.xml b/share/gdal_data/gmlasconf.xml similarity index 100% rename from gdal_data/gmlasconf.xml rename to share/gdal_data/gmlasconf.xml diff --git a/gdal_data/gmlasconf.xsd b/share/gdal_data/gmlasconf.xsd similarity index 100% rename from gdal_data/gmlasconf.xsd rename to share/gdal_data/gmlasconf.xsd diff --git a/gdal_data/gt_datum.csv b/share/gdal_data/gt_datum.csv similarity index 100% rename from gdal_data/gt_datum.csv rename to share/gdal_data/gt_datum.csv diff --git a/gdal_data/gt_ellips.csv b/share/gdal_data/gt_ellips.csv similarity index 100% rename from gdal_data/gt_ellips.csv rename to share/gdal_data/gt_ellips.csv diff --git a/gdal_data/header.dxf b/share/gdal_data/header.dxf similarity index 100% rename from gdal_data/header.dxf rename to share/gdal_data/header.dxf diff --git a/gdal_data/inspire_cp_BasicPropertyUnit.gfs b/share/gdal_data/inspire_cp_BasicPropertyUnit.gfs similarity index 100% rename from gdal_data/inspire_cp_BasicPropertyUnit.gfs rename to share/gdal_data/inspire_cp_BasicPropertyUnit.gfs diff --git a/gdal_data/inspire_cp_CadastralBoundary.gfs b/share/gdal_data/inspire_cp_CadastralBoundary.gfs similarity index 100% rename from gdal_data/inspire_cp_CadastralBoundary.gfs rename to share/gdal_data/inspire_cp_CadastralBoundary.gfs diff --git a/gdal_data/inspire_cp_CadastralParcel.gfs b/share/gdal_data/inspire_cp_CadastralParcel.gfs similarity index 100% rename from gdal_data/inspire_cp_CadastralParcel.gfs rename to share/gdal_data/inspire_cp_CadastralParcel.gfs diff --git a/gdal_data/inspire_cp_CadastralZoning.gfs b/share/gdal_data/inspire_cp_CadastralZoning.gfs similarity index 100% rename from gdal_data/inspire_cp_CadastralZoning.gfs rename to share/gdal_data/inspire_cp_CadastralZoning.gfs diff --git a/gdal_data/jpfgdgml_AdmArea.gfs b/share/gdal_data/jpfgdgml_AdmArea.gfs similarity index 100% rename from gdal_data/jpfgdgml_AdmArea.gfs rename to share/gdal_data/jpfgdgml_AdmArea.gfs diff --git a/gdal_data/jpfgdgml_AdmBdry.gfs b/share/gdal_data/jpfgdgml_AdmBdry.gfs similarity index 100% rename from gdal_data/jpfgdgml_AdmBdry.gfs rename to share/gdal_data/jpfgdgml_AdmBdry.gfs diff --git a/gdal_data/jpfgdgml_AdmPt.gfs b/share/gdal_data/jpfgdgml_AdmPt.gfs similarity index 100% rename from gdal_data/jpfgdgml_AdmPt.gfs rename to share/gdal_data/jpfgdgml_AdmPt.gfs diff --git a/gdal_data/jpfgdgml_BldA.gfs b/share/gdal_data/jpfgdgml_BldA.gfs similarity index 100% rename from gdal_data/jpfgdgml_BldA.gfs rename to share/gdal_data/jpfgdgml_BldA.gfs diff --git a/gdal_data/jpfgdgml_BldL.gfs b/share/gdal_data/jpfgdgml_BldL.gfs similarity index 100% rename from gdal_data/jpfgdgml_BldL.gfs rename to share/gdal_data/jpfgdgml_BldL.gfs diff --git a/gdal_data/jpfgdgml_Cntr.gfs b/share/gdal_data/jpfgdgml_Cntr.gfs similarity index 100% rename from gdal_data/jpfgdgml_Cntr.gfs rename to share/gdal_data/jpfgdgml_Cntr.gfs diff --git a/gdal_data/jpfgdgml_CommBdry.gfs b/share/gdal_data/jpfgdgml_CommBdry.gfs similarity index 100% rename from gdal_data/jpfgdgml_CommBdry.gfs rename to share/gdal_data/jpfgdgml_CommBdry.gfs diff --git a/gdal_data/jpfgdgml_CommPt.gfs b/share/gdal_data/jpfgdgml_CommPt.gfs similarity index 100% rename from gdal_data/jpfgdgml_CommPt.gfs rename to share/gdal_data/jpfgdgml_CommPt.gfs diff --git a/gdal_data/jpfgdgml_Cstline.gfs b/share/gdal_data/jpfgdgml_Cstline.gfs similarity index 100% rename from gdal_data/jpfgdgml_Cstline.gfs rename to share/gdal_data/jpfgdgml_Cstline.gfs diff --git a/gdal_data/jpfgdgml_ElevPt.gfs b/share/gdal_data/jpfgdgml_ElevPt.gfs similarity index 100% rename from gdal_data/jpfgdgml_ElevPt.gfs rename to share/gdal_data/jpfgdgml_ElevPt.gfs diff --git a/gdal_data/jpfgdgml_GCP.gfs b/share/gdal_data/jpfgdgml_GCP.gfs similarity index 100% rename from gdal_data/jpfgdgml_GCP.gfs rename to share/gdal_data/jpfgdgml_GCP.gfs diff --git a/gdal_data/jpfgdgml_LeveeEdge.gfs b/share/gdal_data/jpfgdgml_LeveeEdge.gfs similarity index 100% rename from gdal_data/jpfgdgml_LeveeEdge.gfs rename to share/gdal_data/jpfgdgml_LeveeEdge.gfs diff --git a/gdal_data/jpfgdgml_RailCL.gfs b/share/gdal_data/jpfgdgml_RailCL.gfs similarity index 100% rename from gdal_data/jpfgdgml_RailCL.gfs rename to share/gdal_data/jpfgdgml_RailCL.gfs diff --git a/gdal_data/jpfgdgml_RdASL.gfs b/share/gdal_data/jpfgdgml_RdASL.gfs similarity index 100% rename from gdal_data/jpfgdgml_RdASL.gfs rename to share/gdal_data/jpfgdgml_RdASL.gfs diff --git a/gdal_data/jpfgdgml_RdArea.gfs b/share/gdal_data/jpfgdgml_RdArea.gfs similarity index 100% rename from gdal_data/jpfgdgml_RdArea.gfs rename to share/gdal_data/jpfgdgml_RdArea.gfs diff --git a/gdal_data/jpfgdgml_RdCompt.gfs b/share/gdal_data/jpfgdgml_RdCompt.gfs similarity index 100% rename from gdal_data/jpfgdgml_RdCompt.gfs rename to share/gdal_data/jpfgdgml_RdCompt.gfs diff --git a/gdal_data/jpfgdgml_RdEdg.gfs b/share/gdal_data/jpfgdgml_RdEdg.gfs similarity index 100% rename from gdal_data/jpfgdgml_RdEdg.gfs rename to share/gdal_data/jpfgdgml_RdEdg.gfs diff --git a/gdal_data/jpfgdgml_RdMgtBdry.gfs b/share/gdal_data/jpfgdgml_RdMgtBdry.gfs similarity index 100% rename from gdal_data/jpfgdgml_RdMgtBdry.gfs rename to share/gdal_data/jpfgdgml_RdMgtBdry.gfs diff --git a/gdal_data/jpfgdgml_RdSgmtA.gfs b/share/gdal_data/jpfgdgml_RdSgmtA.gfs similarity index 100% rename from gdal_data/jpfgdgml_RdSgmtA.gfs rename to share/gdal_data/jpfgdgml_RdSgmtA.gfs diff --git a/gdal_data/jpfgdgml_RvrMgtBdry.gfs b/share/gdal_data/jpfgdgml_RvrMgtBdry.gfs similarity index 100% rename from gdal_data/jpfgdgml_RvrMgtBdry.gfs rename to share/gdal_data/jpfgdgml_RvrMgtBdry.gfs diff --git a/gdal_data/jpfgdgml_SBAPt.gfs b/share/gdal_data/jpfgdgml_SBAPt.gfs similarity index 100% rename from gdal_data/jpfgdgml_SBAPt.gfs rename to share/gdal_data/jpfgdgml_SBAPt.gfs diff --git a/gdal_data/jpfgdgml_SBArea.gfs b/share/gdal_data/jpfgdgml_SBArea.gfs similarity index 100% rename from gdal_data/jpfgdgml_SBArea.gfs rename to share/gdal_data/jpfgdgml_SBArea.gfs diff --git a/gdal_data/jpfgdgml_SBBdry.gfs b/share/gdal_data/jpfgdgml_SBBdry.gfs similarity index 100% rename from gdal_data/jpfgdgml_SBBdry.gfs rename to share/gdal_data/jpfgdgml_SBBdry.gfs diff --git a/gdal_data/jpfgdgml_WA.gfs b/share/gdal_data/jpfgdgml_WA.gfs similarity index 100% rename from gdal_data/jpfgdgml_WA.gfs rename to share/gdal_data/jpfgdgml_WA.gfs diff --git a/gdal_data/jpfgdgml_WL.gfs b/share/gdal_data/jpfgdgml_WL.gfs similarity index 100% rename from gdal_data/jpfgdgml_WL.gfs rename to share/gdal_data/jpfgdgml_WL.gfs diff --git a/gdal_data/jpfgdgml_WStrA.gfs b/share/gdal_data/jpfgdgml_WStrA.gfs similarity index 100% rename from gdal_data/jpfgdgml_WStrA.gfs rename to share/gdal_data/jpfgdgml_WStrA.gfs diff --git a/gdal_data/jpfgdgml_WStrL.gfs b/share/gdal_data/jpfgdgml_WStrL.gfs similarity index 100% rename from gdal_data/jpfgdgml_WStrL.gfs rename to share/gdal_data/jpfgdgml_WStrL.gfs diff --git a/gdal_data/netcdf_config.xsd b/share/gdal_data/netcdf_config.xsd similarity index 100% rename from gdal_data/netcdf_config.xsd rename to share/gdal_data/netcdf_config.xsd diff --git a/gdal_data/nitf_spec.xml b/share/gdal_data/nitf_spec.xml similarity index 100% rename from gdal_data/nitf_spec.xml rename to share/gdal_data/nitf_spec.xml diff --git a/gdal_data/nitf_spec.xsd b/share/gdal_data/nitf_spec.xsd similarity index 100% rename from gdal_data/nitf_spec.xsd rename to share/gdal_data/nitf_spec.xsd diff --git a/gdal_data/ogrvrt.xsd b/share/gdal_data/ogrvrt.xsd similarity index 100% rename from gdal_data/ogrvrt.xsd rename to share/gdal_data/ogrvrt.xsd diff --git a/gdal_data/osmconf.ini b/share/gdal_data/osmconf.ini similarity index 100% rename from gdal_data/osmconf.ini rename to share/gdal_data/osmconf.ini diff --git a/gdal_data/ozi_datum.csv b/share/gdal_data/ozi_datum.csv similarity index 100% rename from gdal_data/ozi_datum.csv rename to share/gdal_data/ozi_datum.csv diff --git a/gdal_data/ozi_ellips.csv b/share/gdal_data/ozi_ellips.csv similarity index 100% rename from gdal_data/ozi_ellips.csv rename to share/gdal_data/ozi_ellips.csv diff --git a/gdal_data/pci_datum.txt b/share/gdal_data/pci_datum.txt similarity index 100% rename from gdal_data/pci_datum.txt rename to share/gdal_data/pci_datum.txt diff --git a/gdal_data/pci_ellips.txt b/share/gdal_data/pci_ellips.txt similarity index 100% rename from gdal_data/pci_ellips.txt rename to share/gdal_data/pci_ellips.txt diff --git a/gdal_data/pdfcomposition.xsd b/share/gdal_data/pdfcomposition.xsd similarity index 100% rename from gdal_data/pdfcomposition.xsd rename to share/gdal_data/pdfcomposition.xsd diff --git a/gdal_data/pds4_template.xml b/share/gdal_data/pds4_template.xml similarity index 100% rename from gdal_data/pds4_template.xml rename to share/gdal_data/pds4_template.xml diff --git a/gdal_data/plscenesconf.json b/share/gdal_data/plscenesconf.json similarity index 100% rename from gdal_data/plscenesconf.json rename to share/gdal_data/plscenesconf.json diff --git a/gdal_data/ruian_vf_ob_v1.gfs b/share/gdal_data/ruian_vf_ob_v1.gfs similarity index 100% rename from gdal_data/ruian_vf_ob_v1.gfs rename to share/gdal_data/ruian_vf_ob_v1.gfs diff --git a/gdal_data/ruian_vf_st_uvoh_v1.gfs b/share/gdal_data/ruian_vf_st_uvoh_v1.gfs similarity index 100% rename from gdal_data/ruian_vf_st_uvoh_v1.gfs rename to share/gdal_data/ruian_vf_st_uvoh_v1.gfs diff --git a/gdal_data/ruian_vf_st_v1.gfs b/share/gdal_data/ruian_vf_st_v1.gfs similarity index 100% rename from gdal_data/ruian_vf_st_v1.gfs rename to share/gdal_data/ruian_vf_st_v1.gfs diff --git a/gdal_data/ruian_vf_v1.gfs b/share/gdal_data/ruian_vf_v1.gfs similarity index 100% rename from gdal_data/ruian_vf_v1.gfs rename to share/gdal_data/ruian_vf_v1.gfs diff --git a/gdal_data/s57agencies.csv b/share/gdal_data/s57agencies.csv similarity index 100% rename from gdal_data/s57agencies.csv rename to share/gdal_data/s57agencies.csv diff --git a/gdal_data/s57attributes.csv b/share/gdal_data/s57attributes.csv similarity index 100% rename from gdal_data/s57attributes.csv rename to share/gdal_data/s57attributes.csv diff --git a/gdal_data/s57expectedinput.csv b/share/gdal_data/s57expectedinput.csv similarity index 100% rename from gdal_data/s57expectedinput.csv rename to share/gdal_data/s57expectedinput.csv diff --git a/gdal_data/s57objectclasses.csv b/share/gdal_data/s57objectclasses.csv similarity index 100% rename from gdal_data/s57objectclasses.csv rename to share/gdal_data/s57objectclasses.csv diff --git a/gdal_data/seed_2d.dgn b/share/gdal_data/seed_2d.dgn similarity index 100% rename from gdal_data/seed_2d.dgn rename to share/gdal_data/seed_2d.dgn diff --git a/gdal_data/seed_3d.dgn b/share/gdal_data/seed_3d.dgn similarity index 100% rename from gdal_data/seed_3d.dgn rename to share/gdal_data/seed_3d.dgn diff --git a/gdal_data/stateplane.csv b/share/gdal_data/stateplane.csv similarity index 100% rename from gdal_data/stateplane.csv rename to share/gdal_data/stateplane.csv diff --git a/gdal_data/template_tiles.mapml b/share/gdal_data/template_tiles.mapml similarity index 100% rename from gdal_data/template_tiles.mapml rename to share/gdal_data/template_tiles.mapml diff --git a/gdal_data/tms_LINZAntarticaMapTileGrid.json b/share/gdal_data/tms_LINZAntarticaMapTileGrid.json similarity index 100% rename from gdal_data/tms_LINZAntarticaMapTileGrid.json rename to share/gdal_data/tms_LINZAntarticaMapTileGrid.json diff --git a/gdal_data/tms_MapML_APSTILE.json b/share/gdal_data/tms_MapML_APSTILE.json similarity index 100% rename from gdal_data/tms_MapML_APSTILE.json rename to share/gdal_data/tms_MapML_APSTILE.json diff --git a/gdal_data/tms_MapML_CBMTILE.json b/share/gdal_data/tms_MapML_CBMTILE.json similarity index 100% rename from gdal_data/tms_MapML_CBMTILE.json rename to share/gdal_data/tms_MapML_CBMTILE.json diff --git a/gdal_data/tms_NZTM2000.json b/share/gdal_data/tms_NZTM2000.json similarity index 100% rename from gdal_data/tms_NZTM2000.json rename to share/gdal_data/tms_NZTM2000.json diff --git a/gdal_data/trailer.dxf b/share/gdal_data/trailer.dxf similarity index 100% rename from gdal_data/trailer.dxf rename to share/gdal_data/trailer.dxf diff --git a/gdal_data/usage b/share/gdal_data/usage similarity index 100% rename from gdal_data/usage rename to share/gdal_data/usage diff --git a/gdal_data/vcpkg-cmake-wrapper.cmake b/share/gdal_data/vcpkg-cmake-wrapper.cmake similarity index 100% rename from gdal_data/vcpkg-cmake-wrapper.cmake rename to share/gdal_data/vcpkg-cmake-wrapper.cmake diff --git a/gdal_data/vcpkg_abi_info.txt b/share/gdal_data/vcpkg_abi_info.txt similarity index 100% rename from gdal_data/vcpkg_abi_info.txt rename to share/gdal_data/vcpkg_abi_info.txt diff --git a/gdal_data/vdv452.xml b/share/gdal_data/vdv452.xml similarity index 100% rename from gdal_data/vdv452.xml rename to share/gdal_data/vdv452.xml diff --git a/gdal_data/vdv452.xsd b/share/gdal_data/vdv452.xsd similarity index 100% rename from gdal_data/vdv452.xsd rename to share/gdal_data/vdv452.xsd diff --git a/gdal_data/vicar.json b/share/gdal_data/vicar.json similarity index 100% rename from gdal_data/vicar.json rename to share/gdal_data/vicar.json diff --git a/proj_data/CH b/share/proj_data/CH similarity index 100% rename from proj_data/CH rename to share/proj_data/CH diff --git a/proj_data/GL27 b/share/proj_data/GL27 similarity index 100% rename from proj_data/GL27 rename to share/proj_data/GL27 diff --git a/proj_data/ITRF2000 b/share/proj_data/ITRF2000 similarity index 100% rename from proj_data/ITRF2000 rename to share/proj_data/ITRF2000 diff --git a/proj_data/ITRF2008 b/share/proj_data/ITRF2008 similarity index 100% rename from proj_data/ITRF2008 rename to share/proj_data/ITRF2008 diff --git a/proj_data/ITRF2014 b/share/proj_data/ITRF2014 similarity index 100% rename from proj_data/ITRF2014 rename to share/proj_data/ITRF2014 diff --git a/proj_data/copyright b/share/proj_data/copyright similarity index 100% rename from proj_data/copyright rename to share/proj_data/copyright diff --git a/proj_data/deformation_model.schema.json b/share/proj_data/deformation_model.schema.json similarity index 100% rename from proj_data/deformation_model.schema.json rename to share/proj_data/deformation_model.schema.json diff --git a/proj_data/nad.lst b/share/proj_data/nad.lst similarity index 100% rename from proj_data/nad.lst rename to share/proj_data/nad.lst diff --git a/proj_data/nad27 b/share/proj_data/nad27 similarity index 100% rename from proj_data/nad27 rename to share/proj_data/nad27 diff --git a/proj_data/nad83 b/share/proj_data/nad83 similarity index 100% rename from proj_data/nad83 rename to share/proj_data/nad83 diff --git a/proj_data/other.extra b/share/proj_data/other.extra similarity index 100% rename from proj_data/other.extra rename to share/proj_data/other.extra diff --git a/proj_data/proj-targets-debug.cmake b/share/proj_data/proj-targets-debug.cmake similarity index 100% rename from proj_data/proj-targets-debug.cmake rename to share/proj_data/proj-targets-debug.cmake diff --git a/proj_data/proj-targets-release.cmake b/share/proj_data/proj-targets-release.cmake similarity index 100% rename from proj_data/proj-targets-release.cmake rename to share/proj_data/proj-targets-release.cmake diff --git a/proj_data/proj-targets.cmake b/share/proj_data/proj-targets.cmake similarity index 100% rename from proj_data/proj-targets.cmake rename to share/proj_data/proj-targets.cmake diff --git a/proj_data/proj.db b/share/proj_data/proj.db similarity index 100% rename from proj_data/proj.db rename to share/proj_data/proj.db diff --git a/proj_data/proj.ini b/share/proj_data/proj.ini similarity index 100% rename from proj_data/proj.ini rename to share/proj_data/proj.ini diff --git a/proj_data/proj4-config-version.cmake b/share/proj_data/proj4-config-version.cmake similarity index 100% rename from proj_data/proj4-config-version.cmake rename to share/proj_data/proj4-config-version.cmake diff --git a/proj_data/proj4-config.cmake b/share/proj_data/proj4-config.cmake similarity index 100% rename from proj_data/proj4-config.cmake rename to share/proj_data/proj4-config.cmake diff --git a/proj_data/proj4-targets-debug.cmake b/share/proj_data/proj4-targets-debug.cmake similarity index 100% rename from proj_data/proj4-targets-debug.cmake rename to share/proj_data/proj4-targets-debug.cmake diff --git a/proj_data/proj4-targets-release.cmake b/share/proj_data/proj4-targets-release.cmake similarity index 100% rename from proj_data/proj4-targets-release.cmake rename to share/proj_data/proj4-targets-release.cmake diff --git a/proj_data/proj4-targets.cmake b/share/proj_data/proj4-targets.cmake similarity index 100% rename from proj_data/proj4-targets.cmake rename to share/proj_data/proj4-targets.cmake diff --git a/proj_data/projjson.schema.json b/share/proj_data/projjson.schema.json similarity index 100% rename from proj_data/projjson.schema.json rename to share/proj_data/projjson.schema.json diff --git a/proj_data/triangulation.schema.json b/share/proj_data/triangulation.schema.json similarity index 100% rename from proj_data/triangulation.schema.json rename to share/proj_data/triangulation.schema.json diff --git a/proj_data/usage b/share/proj_data/usage similarity index 100% rename from proj_data/usage rename to share/proj_data/usage diff --git a/proj_data/vcpkg_abi_info.txt b/share/proj_data/vcpkg_abi_info.txt similarity index 100% rename from proj_data/vcpkg_abi_info.txt rename to share/proj_data/vcpkg_abi_info.txt diff --git a/proj_data/world b/share/proj_data/world similarity index 100% rename from proj_data/world rename to share/proj_data/world diff --git a/src/AssetProperties.cpp b/src/AssetProperties.cpp deleted file mode 100644 index b95aec7..0000000 --- a/src/AssetProperties.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include - -namespace scially { - QJsonValue AssetProperties::write() { - QJsonObject object; - for (auto iter = assets.constKeyValueBegin(); iter != assets.constKeyValueEnd(); iter++) { - object[iter->first] = iter->second; - } - return object; - } - - void AssetProperties::read(const QJsonValue& object) { - assets.clear(); - if (!object.isObject()) - throw TilesParseException("asset is required"); - - for (const auto& key : object.toObject().keys()) { - assets[key] = object[key].toString(); - } - } - -} diff --git a/src/BaseTile.cpp b/src/BaseTile.cpp deleted file mode 100644 index 18ace66..0000000 --- a/src/BaseTile.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -namespace scially { - - QJsonValue BaseTile::write() { - QJsonObject object; - - object[asset.typeName()] = asset.write(); - object["geometricError"] = geometricError; - object[root.typeName()] = root.write(); - return object; - } - - void BaseTile::read(const QJsonValue& object) { - if (!object.isObject()) - return; - - asset.read(object["asset"]); - geometricError = object["geometricError"].toDouble(); - root.read(object["root"]); - - } - -} diff --git a/src/Batched3DModel.cpp b/src/Batched3DModel.cpp deleted file mode 100644 index 31821a0..0000000 --- a/src/Batched3DModel.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -namespace scially { - QByteArray Batched3DModel::write(bool withHeight) const { - QByteArray buffer; - QDataStream dataStream(&buffer, QIODevice::WriteOnly); - dataStream.setByteOrder(QDataStream::LittleEndian); - - // feature json and feature binary - QString featureJsonStr = QString(R"({"BATCH_LENGTH":%1})").arg(batchLength); - - while (featureJsonStr.size() % 4 != 0) { - featureJsonStr.append(' '); - } - - // batch json and batch binary - QJsonObject batchJson; - batchJson["batchId"] = arrayToQJsonArray(batchID.begin(), batchID.end()); - batchJson["name"] = arrayToQJsonArray(names.begin(), names.end()); - - if (withHeight) { - batchJson["height"] = arrayToQJsonArray(heights.begin(), heights.end()); - } - - QString batchJsonStr = jsonDump(batchJson); - while (batchJsonStr.size() % 4 != 0) { - batchJsonStr.append(' '); - } - - - // feature binary and batch binary not implement - int totalSize = 28 /*header size*/ + featureJsonStr.size() + batchJsonStr.size() + glbBuffer.size(); - - dataStream.writeRawData("b3dm", 4); - dataStream << 1; - dataStream << totalSize; - dataStream << featureJsonStr.size(); - dataStream << 0; // feature binary - dataStream << batchJsonStr.size(); - dataStream << 0; // batch binary - - dataStream.writeRawData(featureJsonStr.toStdString().data(), featureJsonStr.size()); - dataStream.writeRawData(batchJsonStr.toStdString().data(), batchJsonStr.size()); - dataStream.writeRawData(glbBuffer.data(), glbBuffer.size()); - - return buffer; - } -} \ No newline at end of file diff --git a/src/BoundingVolume.cpp b/src/BoundingVolume.cpp deleted file mode 100644 index 16b7813..0000000 --- a/src/BoundingVolume.cpp +++ /dev/null @@ -1 +0,0 @@ -#include \ No newline at end of file diff --git a/src/BoundingVolumeSphere.cpp b/src/BoundingVolumeSphere.cpp deleted file mode 100644 index da0e2fb..0000000 --- a/src/BoundingVolumeSphere.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - -namespace scially { - - QJsonValue BoundingVolumeSphere::write() { - QJsonObject object; - - QJsonArray array; - array.append(centerX); - array.append(centerY); - array.append(centerZ); - array.append(radius); - - object["sphere"] = array; - return object; - } - - void BoundingVolumeSphere::read(const QJsonValue& object) { - if(!object.isArray()){ - qCritical() << "parse BoundingVolumeSphere: " << object << "failed\n"; - return; - } - - centerX = object[0].toDouble(); - centerY = object[1].toDouble(); - centerZ = object[2].toDouble(); - radius = object[3].toDouble(); - } - -} diff --git a/src/Cesium3DTiles/AssetProperties.cpp b/src/Cesium3DTiles/AssetProperties.cpp new file mode 100644 index 0000000..8c998ba --- /dev/null +++ b/src/Cesium3DTiles/AssetProperties.cpp @@ -0,0 +1,16 @@ +#include + +namespace scially { + QJsonObject AssetProperties::write() const { + QJsonObject object = QJsonObject::fromVariantMap(assets); + return object; + } + + void AssetProperties::read(const QJsonObject& object) { + assets.clear(); + + for (const auto& key : object.keys()) { + assets[key] = object[key].toString(); + } + } +} diff --git a/src/Cesium3DTiles/BaseTile.cpp b/src/Cesium3DTiles/BaseTile.cpp new file mode 100644 index 0000000..0646ec0 --- /dev/null +++ b/src/Cesium3DTiles/BaseTile.cpp @@ -0,0 +1,18 @@ +#include + +namespace scially { + QJsonObject BaseTile::write() const { + QJsonObject object; + object[asset.TypeName] = asset.write(); + object["geometricError"] = geometricError; + object[root.TypeName] = root.write(); + return object; + } + + void BaseTile::read(const QJsonObject& object) { + asset.read(object[asset.TypeName].toObject()); + geometricError = object["geometricError"].toDouble(); + root.read(object["root"].toObject()); + } + +} diff --git a/src/Cesium3DTiles/Batched3DModel.cpp b/src/Cesium3DTiles/Batched3DModel.cpp new file mode 100644 index 0000000..4aaa66a --- /dev/null +++ b/src/Cesium3DTiles/Batched3DModel.cpp @@ -0,0 +1,58 @@ +#include +#include + +#include +#include +#include +#include + +namespace scially { + QByteArray Batched3DModel::write(bool withHeight) const { + QByteArray buffer; + QDataStream dataStream(&buffer, QIODevice::WriteOnly); + dataStream.setByteOrder(QDataStream::LittleEndian); + QString feature, batch; + + // feature json and feature binary + feature = QString(R"({"BATCH_LENGTH":%1})").arg(batchLength); + + while ((feature.size() + 28) % 8 != 0) { + feature.append(' '); + } + + // batch json and batch binary + { + QJsonObject batchJson; + batchJson["batchId"] = arrayToQJsonArray(batchID.begin(), batchID.end()); + batchJson["name"] = arrayToQJsonArray(names.begin(), names.end()); + + if (withHeight) { + batchJson["height"] = arrayToQJsonArray(heights.begin(), heights.end()); + } + + batch = QJsonDocument(batchJson).toJson(QJsonDocument::Compact); + while (batch.size() % 8 != 0) { + batch.append(' '); + } + } + + + // feature binary and batch binary not implement + int totalSize = 28 /*header size*/ + + feature.size() + batch.size() + glbBuffer.size(); + + dataStream.writeRawData("b3dm", 4); + dataStream << 1; + dataStream << totalSize; + dataStream << feature.size(); + dataStream << 0; // feature binary + dataStream << batch.size(); + dataStream << 0; // batch binary + + dataStream.writeRawData(feature.toLatin1(), feature.size()); + dataStream.writeRawData(batch.toLatin1(), batch.size()); + dataStream.writeRawData(glbBuffer.data(), glbBuffer.size()); + + return buffer; + } +} \ No newline at end of file diff --git a/src/Cesium3DTiles/BoundingVolume.cpp b/src/Cesium3DTiles/BoundingVolume.cpp new file mode 100644 index 0000000..26c5a7c --- /dev/null +++ b/src/Cesium3DTiles/BoundingVolume.cpp @@ -0,0 +1,55 @@ +#include +#include + +namespace scially { + QJsonObject BoundingVolume::write() const { + QString key; + QJsonArray value; + + if (box.has_value()) { + key = box->TypeName; + value = box->write(); + } + else if (region.has_value()) { + key = region->TypeName; + value = region->write(); + } + else if (sphere.has_value()) { + key = sphere->TypeName; + value = sphere->write(); + } + else { + throw TilesConvertException("BoundingVolume type must be box,region,sphere"); + } + QJsonObject obj; + obj.insert(key, value); + return obj; + } + + void BoundingVolume::read(const QJsonObject& object) { + + QString key = object.keys().at(0); + QJsonArray value = object.value(key).toArray(); + + if (key == "box") { + BoundingVolumeBox boxResult; + boxResult.read(value); + box = boxResult; + } + else if (key == "region") { + BoundingVolumeRegion regionResult; + regionResult.read(value); + region = regionResult; + } + else if (key == "sphere") { + BoundingVolumeSphere sphereResult; + sphereResult.read(value); + sphere = sphereResult; + } + else { + throw TilesConvertException("BoundingVolume type must be box,region,sphere"); + } + + } + +} \ No newline at end of file diff --git a/src/BoundingVolumeBox.cpp b/src/Cesium3DTiles/BoundingVolumeBox.cpp similarity index 87% rename from src/BoundingVolumeBox.cpp rename to src/Cesium3DTiles/BoundingVolumeBox.cpp index 40f1ca4..e300a54 100644 --- a/src/BoundingVolumeBox.cpp +++ b/src/Cesium3DTiles/BoundingVolumeBox.cpp @@ -1,27 +1,16 @@ -#include - +#include namespace scially { - - QJsonValue BoundingVolumeBox::write() { - QJsonObject object; - + QJsonArray BoundingVolumeBox::write() const{ QJsonArray array; array.append(centerX()); array.append(centerY()); array.append(centerZ()); array.append(halfXLength()); array.append(directionX0()); array.append(directionX1()); array.append(directionY0()); array.append(halfYLength()); array.append(directionY1()); array.append(directionZ0()); array.append(directionZ1()); array.append(halfZLength()); - - object["box"] = array; - return object; + return array; } - void BoundingVolumeBox::read(const QJsonValue& object) { - if(!object.isArray()){ - qCritical() << "parse BoundingVolumeBox: " << object << "failed\n"; - return; - } - + void BoundingVolumeBox::read(const QJsonArray& object) { double centerX = object[0].toDouble(), centerY = object[1].toDouble(), centerZ = object[2].toDouble(); double directionX0 = object[4].toDouble(), directionX1 = object[5].toDouble(), halfXLength = object[3].toDouble(); double directionY0 = object[6].toDouble(), directionY1 = object[8].toDouble(), halfYLength = object[7].toDouble(); diff --git a/src/BoundingVolumeRegion.cpp b/src/Cesium3DTiles/BoundingVolumeRegion.cpp similarity index 89% rename from src/BoundingVolumeRegion.cpp rename to src/Cesium3DTiles/BoundingVolumeRegion.cpp index acfce91..b710a66 100644 --- a/src/BoundingVolumeRegion.cpp +++ b/src/Cesium3DTiles/BoundingVolumeRegion.cpp @@ -1,12 +1,9 @@ -#include +#include #include -#include namespace scially { - QJsonValue BoundingVolumeRegion::write() { - QJsonObject object; - + QJsonArray BoundingVolumeRegion::write() const { QJsonArray array; array.append(west); array.append(south); @@ -14,16 +11,10 @@ namespace scially { array.append(north); array.append(minHeight); array.append(maxHeight); - - object["region"] = array; - return object; + return array; } - void BoundingVolumeRegion::read(const QJsonValue& object) { - if(!object.isArray()){ - qCritical() << "parse BoundingVolumeRegion: " << object << " failed\n"; - } - + void BoundingVolumeRegion::read(const QJsonArray& object) { west = object[0].toDouble(); south = object[1].toDouble(); east = object[2].toDouble(); diff --git a/src/Cesium3DTiles/BoundingVolumeSphere.cpp b/src/Cesium3DTiles/BoundingVolumeSphere.cpp new file mode 100644 index 0000000..ba1fa7a --- /dev/null +++ b/src/Cesium3DTiles/BoundingVolumeSphere.cpp @@ -0,0 +1,22 @@ +#include + +#include + +namespace scially { + QJsonArray BoundingVolumeSphere::write() const { + QJsonArray array; + array.append(centerX); + array.append(centerY); + array.append(centerZ); + array.append(radius); + return array; + } + + void BoundingVolumeSphere::read(const QJsonArray& object) { + centerX = object[0].toDouble(); + centerY = object[1].toDouble(); + centerZ = object[2].toDouble(); + radius = object[3].toDouble(); + } + +} diff --git a/src/Cesium3DTiles/Content.cpp b/src/Cesium3DTiles/Content.cpp new file mode 100644 index 0000000..fc2fdd0 --- /dev/null +++ b/src/Cesium3DTiles/Content.cpp @@ -0,0 +1,17 @@ +#include + +namespace scially { + QJsonObject Content::write() const { + QJsonObject object; + if (boundingVolume.hasValue()) + object[boundingVolume.TypeName] = boundingVolume.write(); + object["uri"] = uri; + return object; + } + + void Content::read(const QJsonObject& object) { + uri = object["uri"].toString(); + QJsonValue value = object[BoundingVolume::TypeName]; + boundingVolume.read(value.toObject()); + } +} diff --git a/src/RootTile.cpp b/src/Cesium3DTiles/RootTile.cpp similarity index 52% rename from src/RootTile.cpp rename to src/Cesium3DTiles/RootTile.cpp index 1d7a1d0..32122bc 100644 --- a/src/RootTile.cpp +++ b/src/Cesium3DTiles/RootTile.cpp @@ -1,17 +1,12 @@ -#include +#include namespace scially { - - RootTile::RootTile() { - children.clear(); - } - - QJsonValue RootTile::write() { + QJsonObject RootTile::write() const{ QJsonObject object; - object["boundingVolume"] = boundingVolume.write(); + object[boundingVolume.TypeName] = boundingVolume.write(); object["geometricError"] = geometricError; - object["refine"] = refine.write(); - object[transform.typeName()] = transform.write(); + object[refine.TypeName] = refine.write(); + object[transform.TypeName] = transform.write(); if (content.has_value()) { object["content"] = content->write(); @@ -25,25 +20,19 @@ namespace scially { return object; } - void RootTile::read(const QJsonValue& object) { - if (object.isNull()) - return; - - boundingVolume.read(object["boundingVolume"]); + void RootTile::read(const QJsonObject& object) { + boundingVolume.read(object[boundingVolume.TypeName].toObject()); geometricError = object["geometricError"].toDouble(); - transform.read(object["transform"]); - + transform.read(object[transform.TypeName].toArray()); content.emplace(); - content->read(object["content"]); - - refine.read(object["refine"]); + content->read(object[content->TypeName].toObject()); + refine.read(object[refine.TypeName].toString()); QJsonArray values = object["children"].toArray(); for (const auto& value : values) { RootTile r; - r.read(value); + r.read(value.toObject()); children.append(r); } - } } diff --git a/src/TileMatrix.cpp b/src/Cesium3DTiles/Transform.cpp similarity index 89% rename from src/TileMatrix.cpp rename to src/Cesium3DTiles/Transform.cpp index 240ab5b..dc88b11 100644 --- a/src/TileMatrix.cpp +++ b/src/Cesium3DTiles/Transform.cpp @@ -1,12 +1,12 @@ -#include -#include +#include #include #include #include + namespace scially { - QJsonValue TileMatrix::write() { + QJsonArray Transform::write() const{ QJsonArray array; array.append(_mat[0][0]); array.append(_mat[1][0]); array.append(_mat[2][0]); array.append(_mat[3][0]); array.append(_mat[0][1]); array.append(_mat[1][1]); array.append(_mat[2][1]); array.append(_mat[3][1]); @@ -16,17 +16,14 @@ namespace scially { return array; } - void TileMatrix::read(const QJsonValue& object) { - if(!object.isArray()) - return; - + void Transform::read(const QJsonArray& object) { _mat[0][0] = object[0].toDouble(); _mat[1][0] = object[1].toDouble(); _mat[2][0] = object[2].toDouble(); _mat[3][0]= object[3].toDouble(); _mat[0][1] = object[4].toDouble(); _mat[1][1] = object[5].toDouble(); _mat[2][1] = object[6].toDouble(); _mat[3][1]= object[7].toDouble(); _mat[0][2] = object[8].toDouble(); _mat[1][2] = object[9].toDouble(); _mat[2][2] = object[10].toDouble(); _mat[3][2] = object[11].toDouble(); _mat[0][3] = object[12].toDouble(); _mat[1][3] = object[13].toDouble(); _mat[2][3] = object[14].toDouble(); _mat[3][3] = object[15].toDouble(); } - TileMatrix TileMatrix::fromXYZ(double lon, double lat, double minHeight) { + Transform Transform::fromXYZ(double lon, double lat, double minHeight) { double lonr = osg::DegreesToRadians(lon); double latr = osg::DegreesToRadians(lat); @@ -59,7 +56,7 @@ namespace scially { osg::Vec3d eastUnit = eastVec / eastVec.length(); osg::Vec3d northUnit = northVec / northVec.length(); - return TileMatrix( + return Transform( eastUnit[0], northUnit[0], xn, px + dx, eastUnit[1], northUnit[1], yn, py + dy, eastUnit[2], northUnit[2], zn, pz + dz, diff --git a/src/ContentTile.cpp b/src/ContentTile.cpp deleted file mode 100644 index 7d70030..0000000 --- a/src/ContentTile.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -namespace scially { - - QJsonValue ContentTile::write() { - QJsonObject object; - if (boundingVolume.has_value() && boundingVolume->hasValue()) - object["boundingVolume"] = boundingVolume->write(); - object["uri"] = uri; - return object; - } - - void ContentTile::read(const QJsonValue& object) { - if(!object.isObject()) - return; - uri = object["uri"].toString(); - - QJsonValue boundingVolumeJson = object["boundingVolume"]; - if(boundingVolumeJson.isObject()){ - BoundingVolume boundingResult; - boundingResult.read(boundingVolumeJson); - boundingVolume = boundingResult; - } - - } -} diff --git a/src/main.cpp b/src/Conveter.cpp similarity index 98% rename from src/main.cpp rename to src/Conveter.cpp index 00fa5a2..eb5f9b2 100644 --- a/src/main.cpp +++ b/src/Conveter.cpp @@ -9,9 +9,11 @@ int main(int argc, char** argv){ QCoreApplication app(argc, argv); scially::GDALDriverWrapper init; + QCoreApplication::setApplicationName("Cesium3DTilesConverter"); - QCoreApplication::setApplicationVersion("1.2"); + QCoreApplication::setApplicationVersion("2.0"); QTime beginTime = QTime::currentTime(); + QCommandLineParser parser; parser.setApplicationDescription("Convert OSGB, GDAL to Cesium 3DTiles"); parser.addHelpOption(); diff --git a/src/GeometryMesh.cpp b/src/GeometryMesh.cpp index dc9e14f..b4ca2a1 100644 --- a/src/GeometryMesh.cpp +++ b/src/GeometryMesh.cpp @@ -1,14 +1,17 @@ +#include +#include +#include +#include #include #include -#include -#include + +#include #include #include #include #include -#include -#include + #include namespace scially { diff --git a/src/ModelMetadata.cpp b/src/ModelMetadata.cpp index 80f1303..fcbd398 100644 --- a/src/ModelMetadata.cpp +++ b/src/ModelMetadata.cpp @@ -1,10 +1,10 @@ #include -#include +#include +#include + #include #include #include -#include -#include namespace scially { void ModelMetadata::parse(const QString &input){ @@ -59,8 +59,8 @@ namespace scially { convert.setSourceSrs(epsg, CoordinateConvert::EPSG); convert.setTargetSrs("4326", CoordinateConvert::EPSG); convert.transform(); - lon = convert.targetX; - lat = convert.targetY; + lat = convert.targetX; + lon = convert.targetY; } else{// maybe wkt if(srsOrigin.isEmpty()){ @@ -76,8 +76,8 @@ namespace scially { convert.setSourceSrs(srs, CoordinateConvert::WKT); convert.setTargetSrs("4326", CoordinateConvert::EPSG); convert.transform(); - lon = convert.targetX; - lat = convert.targetY; + lat = convert.targetX; + lon = convert.targetY; } } } diff --git a/src/OSGBConvert.cpp b/src/OSGBConvert.cpp index 623b829..130cd95 100644 --- a/src/OSGBConvert.cpp +++ b/src/OSGBConvert.cpp @@ -1,6 +1,12 @@ #include -#include +#include #include +#define STB_IMAGE_IMPLEMENTATION +#define STB_IMAGE_WRITE_IMPLEMENTATION +#define TINYGLTF_IMPLEMENTATION +#include +#include + #include #include #include @@ -12,12 +18,6 @@ #include #include -#define STB_IMAGE_IMPLEMENTATION -#define STB_IMAGE_WRITE_IMPLEMENTATION -#define TINYGLTF_IMPLEMENTATION -#include -#include - namespace scially { @@ -257,7 +257,7 @@ namespace scially { } } model.asset.version = "2.0"; - model.asset.generator = "hwang"; + model.asset.generator = "Cesium3DTilesConveter"; glbBuffer = QByteArray::fromStdString(gltf.Serialize(&model)); return glbBuffer; diff --git a/src/OSGBConvertJob.cpp b/src/OSGBConvertJob.cpp index 456b03f..0f90a3a 100644 --- a/src/OSGBConvertJob.cpp +++ b/src/OSGBConvertJob.cpp @@ -1,6 +1,7 @@ #include #include #include + #include #include #include @@ -11,13 +12,8 @@ namespace scially { // 解析XML中的坐标 ModelMetadata metadata; double lon, lat; - try{ - metadata.parse(input + "/metadata.xml"); - metadata.getCoordinate(lon, lat); - }catch (const TilesConvertException& e){ - qCritical() << e.what(); - return; - } + metadata.parse(input + "/metadata.xml"); + metadata.getCoordinate(lon, lat); // 遍历Data QDir dataDir(input + "/Data"); @@ -45,7 +41,7 @@ namespace scially { baseTile.asset.assets["gltfUpAxis"] = "Z"; baseTile.asset.assets["version"] = "1.0"; - baseTile.root.transform = TileMatrix::fromXYZ(lon, lat, height); + baseTile.root.transform = Transform::fromXYZ(lon, lat, height); baseTile.root.geometricError = 1000; BoundingVolumeBox mergeBox; for(auto iter = tasks.constBegin(); iter != tasks.constEnd(); ++iter){ @@ -54,21 +50,21 @@ namespace scially { // for this child RootTile childTile = task->tile.root; mergeBox = mergeBox.merge(task->tile.root.boundingVolume.box.value()); - ContentTile content; + Content content; content.uri = "./" + task->osgbLevel.getTileName() + "/tileset.json"; childTile.content = content; childTile.children.clear(); baseTile.root.children.append(childTile); } } - baseTile.root.boundingVolume = mergeBox; - QJsonDocument doc(baseTile.write().toObject()); + baseTile.root.boundingVolume.box = mergeBox; + QFile tilesetjsonFile(output + "/tileset.json"); if(!tilesetjsonFile.open(QIODevice::WriteOnly)){ qWarning() << "Can't not write tileset.json in " << output; return; } - int writeBytes = tilesetjsonFile.write(doc.toJson(QJsonDocument::Indented)); + int writeBytes = tilesetjsonFile.write(QJsonDocument(baseTile.write()).toJson(QJsonDocument::Indented)); if(writeBytes <= 0){ qWarning() << "Can't not write tileset.json in " << output; return; diff --git a/src/OSGBLevel.cpp b/src/OSGBLevel.cpp index 0d36be4..8f029d6 100644 --- a/src/OSGBLevel.cpp +++ b/src/OSGBLevel.cpp @@ -1,13 +1,14 @@ +#include #include +#include +#include + #include #include #include #include #include -#include -#include -#include -#include +#include namespace scially { @@ -97,10 +98,9 @@ namespace scially { tile.asset.assets["version"] = "1.0"; tile.root.children.append(childTile); - tile.root.boundingVolume = this->region; + tile.root.boundingVolume.box = this->region; tile.root.geometricError = 1000; - QJsonDocument jsonDoc(tile.write().toObject()); - QByteArray json = jsonDoc.toJson(QJsonDocument::Indented); + QFile tilesetFile(output + "/" + getTileName() + "/tileset.json"); if (!tilesetFile.open(QIODevice::WriteOnly)) { @@ -108,7 +108,7 @@ namespace scially { return false; } - tilesetFile.write(json); + tilesetFile.write(QJsonDocument(tile.write()).toJson(QJsonDocument::Indented)); return true; } @@ -125,19 +125,19 @@ namespace scially { if (writeBytes <= 0) return false; - ContentTile content; + Content content; content.uri = "./" + nodeName + B3DMEXTENSION; - content.boundingVolume = BoundingVolumeBox(convert.region); + content.boundingVolume.box = BoundingVolumeBox(convert.region); - root.refine = "REPLACE"; + root.refine.type = "REPLACE"; root.content = content; - root.boundingVolume = BoundingVolumeBox(convert.region); + root.boundingVolume.box = BoundingVolumeBox(convert.region); for(int i = 0; i < subNodes.size(); i++){ RootTile child; subNodes[i].convertTiles(child, output); root.children.append(child); - root.boundingVolume = root.boundingVolume.box->merge(child.boundingVolume.box.value()); + root.boundingVolume.box = root.boundingVolume.box->merge(child.boundingVolume.box.value()); } return true; diff --git a/src/OSGBPageLodVisitor.cpp b/src/OSGBPageLodVisitor.cpp index 1a1e4cb..32bae0b 100644 --- a/src/OSGBPageLodVisitor.cpp +++ b/src/OSGBPageLodVisitor.cpp @@ -1,4 +1,3 @@ -#include #include namespace scially { diff --git a/src/OSGBuildState.cpp b/src/OSGBuildState.cpp index 144f1d2..4cd7a15 100644 --- a/src/OSGBuildState.cpp +++ b/src/OSGBuildState.cpp @@ -1,5 +1,6 @@ #include -#include + +#include namespace scially { diff --git a/src/Refine.cpp b/src/Refine.cpp deleted file mode 100644 index f70483f..0000000 --- a/src/Refine.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -namespace scially { - void Refine::read(const QJsonValue& object) { - if(object.isString()){ - type = object.toString(); - } - } - - QJsonValue Refine::write() { - return type; - } -} diff --git a/src/ShpConvert.cpp b/src/ShpConvert.cpp index ff7e37d..e791cea 100644 --- a/src/ShpConvert.cpp +++ b/src/ShpConvert.cpp @@ -1,7 +1,7 @@ +#include #include -#include -#include +#include #include #include @@ -115,7 +115,7 @@ namespace scially { centerX, centerY, nodeBox.MaxX - nodeBox.MinX, nodeBox.MaxY - nodeBox.MinY, 0, maxHeight); - child.transform = TileMatrix::fromXYZ(centerX, centerY, 0); + child.transform = Transform::fromXYZ(centerX, centerY, 0); child.content.emplace(); child.content->uri = QString("./tile/%1/%2/%3.b3dm") .arg(root->getLevel()) @@ -136,7 +136,7 @@ namespace scially { rootBounding.minHeight = 0; rootBounding.maxHeight = layerMaxHeight; tile.root.boundingVolume = rootBounding; - QByteArray tileBuffer = jsonDump(tile.write().toObject()); + QByteArray tileBuffer = QJsonDocument(tile.write()).toJson(); QFile tileFile(output + "/tileset.json"); if (!tileFile.open(QIODevice::WriteOnly)){ qWarning() << "Can't write file: " << tileFile.fileName(); diff --git a/src/ShpConvertJob.cpp b/src/ShpConvertJob.cpp index 82a10c6..2180efc 100644 --- a/src/ShpConvertJob.cpp +++ b/src/ShpConvertJob.cpp @@ -1,7 +1,8 @@ #include #include -#include +#include + namespace scially { void ShpConvertJob::run() { try{