Skip to content

Commit 80c5856

Browse files
committed
shared library
1 parent 18f957f commit 80c5856

File tree

15 files changed

+64
-42
lines changed

15 files changed

+64
-42
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.12)
2-
project(CGT VERSION 2.3)
2+
project(CGT VERSION 2.4)
33

44
set(CMAKE_CXX_STANDARD 17)
55
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
1. 支持投影坐标系以及WGS84之间坐标转换。
44
2. 支持根据矢量范围线导出对应瓦片。
55
3.
6-
百度网盘下载地址: [https://pan.baidu.com/s/1AdLGNJiA2iKKYbFwmGKQ5g?pwd=lxsa](https://pan.baidu.com/s/1AdLGNJiA2iKKYbFwmGKQ5g?pwd=lxsa)
6+
百度网盘下载地址: [https://pan.baidu.com/s/1wfpVE4SuvUKW-ceSdaLDdA?pwd=7np4](https://pan.baidu.com/s/1wfpVE4SuvUKW-ceSdaLDdA?pwd=7np4)
77

88
# 用法说明
99

@@ -25,7 +25,7 @@ Subcommands:
2525
transform coordinate transform
2626
export export osgb data
2727

28-
如果没有设置source-srs,source-origin选项,cgt默认会在输入根目录下寻找metadata.xml
28+
如果没有设置source-srs,source-origin选项,cgt默认会在输入根目录下寻找metadata.xml,支持中文路径
2929
```
3030
### transform
3131
```shell
@@ -42,7 +42,7 @@ cgt [options] export
4242
Options:
4343
--shapefile TEXT:FILE REQUIRED export extent
4444
-c,--copy BOOLEAN copy tile(default: true)
45-
默认会在范围线的Tile拷贝的out路径下通过设置 -c false 取消拷贝只输出符合要求的瓦片名
45+
默认会在范围线的Tile拷贝的out路径下,通过设置 -c false 取消拷贝,只输出符合要求的瓦片名
4646
```
4747
## 示例命令
4848

@@ -58,9 +58,11 @@ cgt.exe -i {DATA} -o ${OUT_DIR} export --shapefile {shp, geojson}
5858
### 倾斜摄影数据
5959

6060
倾斜摄影数据仅支持 smart3d 格式的 osgb 组织方式:
61-
- 每个瓦片目录下,必须有个和目录名同名的 osgb 文件,否则无法识别根节点;
6261

63-
正确的目录结构示意:
62+
- 根目录下可以有多个Data文件夹,比如Data1,Data2等
63+
- 最多有一个metadata.xml文件,且必须放在根目录下
64+
- 每个瓦片目录下,必须有个和目录名同名的 osgb 文件,否则无法识别根节点;
65+
正确的目录结构示意:
6466

6567
```
6668
- Your-data-folder

cgt/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@ configure_file(
22
${PROJECT_SOURCE_DIR}/include/cgt/config.h.in
33
${PROJECT_SOURCE_DIR}/include/cgt/config.h)
44

5-
add_library(cgtcore
5+
add_library(cgtcore SHARED
66
"cgtcore.cpp"
77
"cgtmodel.cpp"
88
"tinyxml2.cpp"
99
"cgtproj.cpp"
1010
"cgtvisitor.cpp"
1111
"cgttransform.cpp"
12-
"cgtexport.cpp" cgtpath.cpp)
13-
14-
add_executable(cgt
15-
"main.cpp" ../include/cgt/cgtpath.h)
16-
12+
"cgtexport.cpp"
13+
"cgtcommon.cpp")
1714
target_link_libraries(cgtcore
1815
${GDAL_LIBRARIES}
1916
${OPENSCENEGRAPH_LIBRARIES})
17+
target_compile_definitions(cgtcore
18+
PRIVATE CGTEXPORT)
2019

20+
add_executable(cgt
21+
"main.cpp")
2122
target_link_libraries(cgt cgtcore)
2223

24+
2325
add_custom_command(TARGET cgt
2426
POST_BUILD
2527
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/resources" "${EXECUTABLE_OUTPUT_PATH}"

cgt/cgtpath.cpp renamed to cgt/cgtcommon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Created by adminstrator on 2022/9/28.
33
//
44

5-
#include <cgt/cgtpath.h>
5+
#include <cgt/cgtcommon.h>
66
#include <filesystem>
77

88
#if defined(_WIN32)

cgt/cgtexport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace scially {
4848
layer->GetSpatialRef()->exportToWkt(&target_wktsrs);
4949
modeldata.set_srs(target_wktsrs);
5050
proj_ = std::make_unique<cgt_proj>(source_metadata_, modeldata);
51-
delete target_wktsrs;
51+
CPLFree(target_wktsrs);
5252
}
5353

5454
bool osg_export::is_intersect(const osg::Node& node){

cgt/cgtproj.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44

55
#include <cgt/cgtproj.h>
6-
#include <cgt/cgtpath.h>
6+
#include <cgt/cgtcommon.h>
77
#include <osg/CoordinateSystemNode>
88
#include <osg/Math>
99

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88

99
#if defined(_WIN32)
1010
#define U8TEXT(s) osgDB::convertStringFromCurrentCodePageToUTF8(s)
11+
12+
#if defined(CGTEXPORT)
13+
#define CGTLIBRARY __declspec(dllexport)
14+
#else
15+
#define CGTLIBRARY __declspec(dllimport)
16+
#endif
1117
#else
1218
#define U8TEXT(s) s
19+
#define CGTLIBRAR
1320
#endif
1421

22+
1523
namespace scially {
1624
std::string get_process_filepath();
1725
}

include/cgt/cgtcore.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <cgt/cgtmodel.h>
88
#include <cgt/cgtproj.h>
9-
#include <cgt/cgtpath.h>
9+
#include <cgt/cgtcommon.h>
1010
#include <spdlog/spdlog.h>
1111

1212
#include <osg/Node>
@@ -20,18 +20,20 @@
2020
namespace scially {
2121
using vec3_transform = std::function<osg::Vec3(osg::Vec3)>;
2222

23-
class node_operator {
23+
class CGTLIBRARY node_operator {
2424
public:
25-
void read(const std::string& path);
26-
void write(const std::string& dir);
27-
void apply(const std::string& base_path, const vec3_transform&);
25+
void read(const std::string &path);
26+
27+
void write(const std::string &dir);
28+
29+
void apply(const std::string &base_path, const vec3_transform &);
2830

2931
private:
3032
osg::ref_ptr<osg::Node> node_;
31-
std::string node_name_;
33+
std::string node_name_;
3234
};
3335

34-
class osg_base {
36+
class CGTLIBRARY osg_base {
3537
public:
3638
static constexpr double DOUBLE_EPS = 1e-5;
3739

include/cgt/cgtexception.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
#pragma once
22

3+
#include <cgt/cgtcommon.h>
4+
35
#include <stdexcept>
46
#include <string>
57

68
namespace scially {
79

8-
class cgt_exception : public std::runtime_error {
10+
class CGTLIBRARY cgt_exception : public std::runtime_error {
911
public:
10-
cgt_exception(const std::string& err)
11-
: err(err),
12-
std::runtime_error(err.data()){
13-
12+
cgt_exception(const std::string &err)
13+
: err(err),
14+
std::runtime_error(err.data()) {
15+
1416
}
15-
virtual const char* what() const noexcept override {
17+
18+
virtual const char *what() const noexcept override {
1619
return err.c_str();
1720
}
21+
1822
private:
1923
std::string err;
2024
};

include/cgt/cgtexport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <vector>
1212

1313
namespace scially {
14-
class osg_export : public osg_base {
14+
class CGTLIBRARY osg_export : public osg_base {
1515
public:
1616
osg_export(const std::string &source_dir, const std::string &target_dir)
1717
: osg_base(source_dir, target_dir) {

0 commit comments

Comments
 (0)