Skip to content

Commit

Permalink
修复坐标不对问题,同步fanvanzh/3dtiles commit
Browse files Browse the repository at this point in the history
  • Loading branch information
scially committed Nov 10, 2022
1 parent a517c7e commit 5847ae3
Show file tree
Hide file tree
Showing 183 changed files with 465 additions and 719 deletions.
94 changes: 25 additions & 69 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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 $<TARGET_FILE:Qt5::Xml> $<TARGET_FILE_DIR:Converter>
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:Converter>
)
add_custom_command(TARGET Converter POST_BUILD
COMMAND ${QT5_WINDEPLOYQT_EXECUTABLE} $<TARGET_FILE_DIR:Converter>)
endif(WIN32)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Converter.exe --format gdal --input <GDB Path> --output <DIR> --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]"
Expand Down
Binary file removed data/Tile_+007_+078.osgb
Binary file not shown.
Binary file removed data/Tile_+007_+078_L15_0.osgb
Binary file not shown.
Binary file removed data/Tile_+007_+078_L16_03.osgb
Binary file not shown.
Binary file removed data/Tile_+007_+078_L17_000.osgb
Binary file not shown.
Binary file removed data/Tile_+007_+078_L17_001.osgb
Binary file not shown.
Binary file removed data/Tile_+007_+078_L17_002.osgb
Binary file not shown.
Binary file removed data/Tile_+007_+078_L17_003.osgb
Binary file not shown.
Binary file removed data/Tile_+007_+078_L17_004.osgb
Binary file not shown.
26 changes: 0 additions & 26 deletions include/AssetProperties.h

This file was deleted.

21 changes: 0 additions & 21 deletions include/BaseObject.h

This file was deleted.

96 changes: 0 additions & 96 deletions include/BoundingVolume.h

This file was deleted.

16 changes: 16 additions & 0 deletions include/Cesium3DTiles/AssetProperties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <QJsonObject>
#include <QVariantMap>

namespace scially {
struct AssetProperties {
static constexpr const char* TypeName = "asset";

QJsonObject write() const;
void read(const QJsonObject& object);

QVariantMap assets;
};
}

28 changes: 5 additions & 23 deletions include/BaseTile.h → include/Cesium3DTiles/BaseTile.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
#pragma once

#include <cmath>
#include <algorithm>
#include <array>
#include <initializer_list>
#include <Cesium3DTiles/AssetProperties.h>
#include <Cesium3DTiles/RootTile.h>

#include <QSharedPointer>
#include <BaseObject.h>
#include <AssetProperties.h>
#include <RootTile.h>
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonArray>
#include <QVector>
#include <QJsonDocument>
#include <TilesParseException.h>

namespace scially {
/// <summary>
Expand All @@ -29,18 +19,10 @@ namespace scially {
/// root |A tile in a 3D Tiles tileset. |ContentTile |Required
/// -----------------------------------------------------------------------------
/// </summary>
class BaseTile : public BaseObject {
public:
using BaseTilePtr = QSharedPointer<BaseTile>;

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#include <QByteArray>

namespace scially {
class Batched3DModel {
public:
struct Batched3DModel {
QByteArray write(bool withHeight = false) const;

// feature table and feature binary
int batchLength = 0;
QByteArray featureBinary;
Expand All @@ -16,7 +17,5 @@ namespace scially {
QVector<double> heights;
// glb buffer
QByteArray glbBuffer;

QByteArray write(bool withHeight = false) const;
};
}
34 changes: 34 additions & 0 deletions include/Cesium3DTiles/BoundingVolume.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include <Cesium3DTiles/BoundingVolumeBox.h>
#include <Cesium3DTiles/BoundingVolumeRegion.h>
#include <Cesium3DTiles/BoundingVolumeSphere.h>

#include <optional>

#include <QJsonValue>
#include <QJsonObject>
#include <QJsonArray>

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<BoundingVolumeBox> box;
std::optional<BoundingVolumeRegion> region;
std::optional<BoundingVolumeSphere> sphere;
};
}

Loading

0 comments on commit 5847ae3

Please sign in to comment.