Skip to content

Commit 2ff05d2

Browse files
committed
Swift Package Support for 9.6
1 parent 946df79 commit 2ff05d2

32 files changed

Lines changed: 1181743 additions & 1 deletion

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ build.local.sh
2323
/.vs*
2424
/*build*
2525
/nbproject
26+
/.swiftpm
2627

2728
# Autotools
2829
autom4te.cache

Package.swift

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// swift-tools-version: 5.10
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "proj",
7+
platforms: [
8+
.iOS(.v13), .macOS(.v13)
9+
],
10+
products: [
11+
.library(
12+
name: "proj",
13+
// type: .static,
14+
type: .dynamic,
15+
targets: ["proj"]
16+
),
17+
],
18+
targets: [
19+
.target(
20+
name: "proj",
21+
path: "src",
22+
exclude: [
23+
"apps",
24+
"tests",
25+
"CMakeLists.txt",
26+
"lib_proj.cmake",
27+
"check_md5sum.cmake",
28+
"generate_wkt_parser.cmake",
29+
"general_doc.dox",
30+
"wkt1_grammar.y",
31+
"wkt2_grammar.y",
32+
"file_embed/embedded_resources.c" // Workaround: causes duplicate symbols (copied into src file: embedded_resources.c)
33+
],
34+
resources: [
35+
// .copy("../proj.db") // What is this?
36+
],
37+
publicHeadersPath: ".", // The C header files are mixed with src files, we use a modulemap.module to load "proj.h"
38+
cSettings: [
39+
// .headerSearchPath("../include/proj"),
40+
// .headerSearchPath("../include/proj/internal"),
41+
// .headerSearchPath("../include/proj/internal/vendor/nlohmann"),
42+
],
43+
cxxSettings: [
44+
.headerSearchPath("../include"),
45+
.headerSearchPath("../include/proj"),
46+
.headerSearchPath("../include/proj/internal"),
47+
.headerSearchPath("../include/proj/internal/vendor/nlohmann"),
48+
],
49+
linkerSettings: [
50+
.linkedLibrary("c++"),
51+
.linkedLibrary("sqlite3"),
52+
]
53+
)
54+
],
55+
cxxLanguageStandard: .cxx17
56+
)

src/embedded_resources.c

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,98 @@ const unsigned char *pj_get_embedded_proj_db(unsigned int *pnSize) {
2626

2727
#endif
2828

29-
#include "file_embed/embedded_resources.c"
29+
// Workaround: Duplicate symbols with two files named embedded_resources.c (file_embed/embedded_resources.h)
30+
// Copy the generated contents inline from the CMake build process
31+
32+
//#include "file_embed/embedded_resources.c"
33+
34+
extern const uint8_t proj_ini_data[];
35+
extern const unsigned proj_ini_size;
36+
extern const uint8_t world_data[];
37+
extern const unsigned world_size;
38+
extern const uint8_t other_extra_data[];
39+
extern const unsigned other_extra_size;
40+
extern const uint8_t nad27_data[];
41+
extern const unsigned nad27_size;
42+
extern const uint8_t GL27_data[];
43+
extern const unsigned GL27_size;
44+
extern const uint8_t nad83_data[];
45+
extern const unsigned nad83_size;
46+
extern const uint8_t nad_lst_data[];
47+
extern const unsigned nad_lst_size;
48+
extern const uint8_t CH_data[];
49+
extern const unsigned CH_size;
50+
extern const uint8_t ITRF2000_data[];
51+
extern const unsigned ITRF2000_size;
52+
extern const uint8_t ITRF2008_data[];
53+
extern const unsigned ITRF2008_size;
54+
extern const uint8_t ITRF2014_data[];
55+
extern const unsigned ITRF2014_size;
56+
extern const uint8_t ITRF2020_data[];
57+
extern const unsigned ITRF2020_size;
58+
59+
const unsigned char *pj_get_embedded_resource(const char* filename, unsigned int *pnSize)
60+
{
61+
if (strcmp(filename, "proj.ini") == 0)
62+
{
63+
*pnSize = proj_ini_size;
64+
return proj_ini_data;
65+
}
66+
if (strcmp(filename, "world") == 0)
67+
{
68+
*pnSize = world_size;
69+
return world_data;
70+
}
71+
if (strcmp(filename, "other.extra") == 0)
72+
{
73+
*pnSize = other_extra_size;
74+
return other_extra_data;
75+
}
76+
if (strcmp(filename, "nad27") == 0)
77+
{
78+
*pnSize = nad27_size;
79+
return nad27_data;
80+
}
81+
if (strcmp(filename, "GL27") == 0)
82+
{
83+
*pnSize = GL27_size;
84+
return GL27_data;
85+
}
86+
if (strcmp(filename, "nad83") == 0)
87+
{
88+
*pnSize = nad83_size;
89+
return nad83_data;
90+
}
91+
if (strcmp(filename, "nad.lst") == 0)
92+
{
93+
*pnSize = nad_lst_size;
94+
return nad_lst_data;
95+
}
96+
if (strcmp(filename, "CH") == 0)
97+
{
98+
*pnSize = CH_size;
99+
return CH_data;
100+
}
101+
if (strcmp(filename, "ITRF2000") == 0)
102+
{
103+
*pnSize = ITRF2000_size;
104+
return ITRF2000_data;
105+
}
106+
if (strcmp(filename, "ITRF2008") == 0)
107+
{
108+
*pnSize = ITRF2008_size;
109+
return ITRF2008_data;
110+
}
111+
if (strcmp(filename, "ITRF2014") == 0)
112+
{
113+
*pnSize = ITRF2014_size;
114+
return ITRF2014_data;
115+
}
116+
if (strcmp(filename, "ITRF2020") == 0)
117+
{
118+
*pnSize = ITRF2020_size;
119+
return ITRF2020_data;
120+
}
121+
*pnSize = 0;
122+
return NULL;
123+
}

src/file_embed/CH.c

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
2+
#include "CH.h"
3+
const uint8_t CH_data[] = {
4+
0x23,0x20,0x54,0x68,0x69,0x73,0x20,0x69,
5+
0x6e,0x69,0x74,0x20,0x66,0x69,0x6c,0x65,
6+
0x20,0x70,0x72,0x6f,0x76,0x69,0x64,0x65,
7+
0x73,0x20,0x64,0x65,0x66,0x69,0x6e,0x69,
8+
0x74,0x69,0x6f,0x6e,0x73,0x20,0x66,0x6f,
9+
0x72,0x20,0x43,0x48,0x31,0x39,0x30,0x33,
10+
0x20,0x61,0x6e,0x64,0x20,0x43,0x48,0x31,
11+
0x39,0x30,0x33,0x2f,0x4c,0x56,0x30,0x33,
12+
0x0a,0x23,0x20,0x70,0x72,0x6f,0x6a,0x65,
13+
0x63,0x74,0x69,0x6f,0x6e,0x73,0x20,0x75,
14+
0x73,0x69,0x6e,0x67,0x20,0x74,0x68,0x65,
15+
0x20,0x64,0x69,0x73,0x74,0x6f,0x72,0x74,
16+
0x69,0x6f,0x6e,0x20,0x67,0x72,0x69,0x64,
17+
0x73,0x20,0x64,0x65,0x76,0x65,0x6c,0x6f,
18+
0x70,0x65,0x64,0x20,0x62,0x79,0x20,0x53,
19+
0x77,0x69,0x73,0x73,0x74,0x6f,0x70,0x6f,
20+
0x2e,0x0a,0x23,0x20,0x53,0x65,0x65,0x3a,
21+
0x20,0x68,0x74,0x74,0x70,0x73,0x3a,0x2f,
22+
0x2f,0x73,0x68,0x6f,0x70,0x2e,0x73,0x77,
23+
0x69,0x73,0x73,0x74,0x6f,0x70,0x6f,0x2e,
24+
0x61,0x64,0x6d,0x69,0x6e,0x2e,0x63,0x68,
25+
0x2f,0x65,0x6e,0x2f,0x70,0x72,0x6f,0x64,
26+
0x75,0x63,0x74,0x73,0x2f,0x67,0x65,0x6f,
27+
0x5f,0x73,0x6f,0x66,0x74,0x77,0x61,0x72,
28+
0x65,0x2f,0x47,0x49,0x53,0x5f,0x69,0x6e,
29+
0x66,0x6f,0x0a,0x23,0x0a,0x23,0x20,0x59,
30+
0x6f,0x75,0x27,0x6c,0x6c,0x20,0x6e,0x65,
31+
0x65,0x64,0x20,0x74,0x6f,0x20,0x64,0x6f,
32+
0x77,0x6e,0x6c,0x6f,0x61,0x64,0x20,0x74,
33+
0x68,0x65,0x20,0x67,0x72,0x69,0x64,0x73,
34+
0x20,0x73,0x65,0x70,0x61,0x72,0x61,0x74,
35+
0x65,0x6c,0x79,0x20,0x61,0x6e,0x64,0x20,
36+
0x70,0x75,0x74,0x20,0x69,0x6e,0x20,0x61,
37+
0x20,0x64,0x69,0x72,0x65,0x63,0x74,0x6f,
38+
0x72,0x79,0x0a,0x23,0x20,0x73,0x63,0x61,
39+
0x6e,0x6e,0x65,0x64,0x20,0x62,0x79,0x20,
40+
0x6c,0x69,0x62,0x70,0x72,0x6f,0x6a,0x2e,
41+
0x0a,0x23,0x0a,0x23,0x20,0x4e,0x6f,0x74,
42+
0x65,0x20,0x74,0x68,0x61,0x74,0x20,0x61,
43+
0x6e,0x20,0x69,0x6e,0x64,0x65,0x70,0x65,
44+
0x6e,0x64,0x65,0x6e,0x74,0x20,0x65,0x66,
45+
0x66,0x6f,0x72,0x74,0x20,0x77,0x61,0x73,
46+
0x20,0x6d,0x61,0x64,0x65,0x20,0x74,0x6f,
47+
0x20,0x64,0x65,0x72,0x69,0x76,0x65,0x20,
48+
0x61,0x6e,0x20,0x75,0x73,0x61,0x62,0x6c,
49+
0x65,0x20,0x67,0x72,0x69,0x64,0x0a,0x23,
50+
0x20,0x66,0x72,0x6f,0x6d,0x20,0x74,0x68,
51+
0x65,0x20,0x43,0x48,0x31,0x39,0x30,0x33,
52+
0x2d,0x3e,0x43,0x48,0x31,0x39,0x30,0x33,
53+
0x2b,0x20,0x67,0x72,0x69,0x64,0x20,0x69,
54+
0x6e,0x69,0x74,0x69,0x61,0x6c,0x6c,0x79,
55+
0x20,0x61,0x76,0x61,0x69,0x6c,0x61,0x62,
56+
0x6c,0x65,0x20,0x66,0x72,0x6f,0x6d,0x20,
57+
0x74,0x68,0x65,0x20,0x53,0x77,0x69,0x73,
58+
0x73,0x74,0x6f,0x70,0x6f,0x0a,0x23,0x20,
59+
0x77,0x65,0x62,0x73,0x69,0x74,0x65,0x2e,
60+
0x20,0x59,0x6f,0x75,0x20,0x63,0x61,0x6e,
61+
0x20,0x72,0x65,0x61,0x64,0x20,0x61,0x62,
62+
0x6f,0x75,0x74,0x20,0x74,0x68,0x69,0x73,
63+
0x20,0x6f,0x74,0x68,0x65,0x72,0x20,0x65,
64+
0x66,0x66,0x6f,0x72,0x74,0x20,0x68,0x65,
65+
0x72,0x65,0x3a,0x0a,0x23,0x20,0x68,0x74,
66+
0x74,0x70,0x3a,0x2f,0x2f,0x6c,0x69,0x73,
67+
0x74,0x73,0x2e,0x6d,0x61,0x70,0x74,0x6f,
68+
0x6f,0x6c,0x73,0x2e,0x6f,0x72,0x67,0x2f,
69+
0x70,0x69,0x70,0x65,0x72,0x6d,0x61,0x69,
70+
0x6c,0x2f,0x70,0x72,0x6f,0x6a,0x2f,0x32,
71+
0x30,0x31,0x32,0x2d,0x46,0x65,0x62,0x72,
72+
0x75,0x61,0x72,0x79,0x2f,0x30,0x30,0x36,
73+
0x30,0x39,0x33,0x2e,0x68,0x74,0x6d,0x6c,
74+
0x0a,0x23,0x20,0x49,0x74,0x20,0x6d,0x61,
75+
0x79,0x20,0x62,0x65,0x20,0x6f,0x66,0x20,
76+
0x69,0x6e,0x74,0x65,0x72,0x65,0x73,0x74,
77+
0x20,0x62,0x65,0x63,0x61,0x75,0x73,0x65,
78+
0x20,0x74,0x68,0x65,0x20,0x6c,0x61,0x74,
79+
0x74,0x65,0x72,0x20,0x77,0x61,0x73,0x20,
80+
0x62,0x79,0x20,0x73,0x6f,0x6d,0x65,0x20,
81+
0x72,0x65,0x70,0x6f,0x72,0x74,0x65,0x64,
82+
0x20,0x61,0x73,0x20,0x62,0x65,0x69,0x6e,
83+
0x67,0x0a,0x23,0x20,0x6d,0x6f,0x72,0x65,
84+
0x20,0x61,0x63,0x63,0x75,0x72,0x61,0x74,
85+
0x65,0x20,0x74,0x68,0x61,0x6e,0x20,0x74,
86+
0x68,0x65,0x20,0x66,0x6f,0x72,0x6d,0x65,
87+
0x72,0x3a,0x0a,0x23,0x20,0x68,0x74,0x74,
88+
0x70,0x3a,0x2f,0x2f,0x6c,0x69,0x73,0x74,
89+
0x73,0x2e,0x6d,0x61,0x70,0x74,0x6f,0x6f,
90+
0x6c,0x73,0x2e,0x6f,0x72,0x67,0x2f,0x70,
91+
0x69,0x70,0x65,0x72,0x6d,0x61,0x69,0x6c,
92+
0x2f,0x70,0x72,0x6f,0x6a,0x2f,0x32,0x30,
93+
0x31,0x32,0x2d,0x46,0x65,0x62,0x72,0x75,
94+
0x61,0x72,0x79,0x2f,0x30,0x30,0x36,0x31,
95+
0x31,0x39,0x2e,0x68,0x74,0x6d,0x6c,0x0a,
96+
0x23,0x0a,0x23,0x20,0x54,0x68,0x69,0x73,
97+
0x20,0x69,0x6e,0x69,0x74,0x20,0x66,0x69,
98+
0x6c,0x65,0x20,0x75,0x73,0x65,0x73,0x20,
99+
0x74,0x68,0x65,0x20,0x6f,0x66,0x66,0x69,
100+
0x63,0x69,0x61,0x6c,0x20,0x6f,0x6e,0x65,
101+
0x0a,0x23,0x0a,0x3c,0x6d,0x65,0x74,0x61,
102+
0x64,0x61,0x74,0x61,0x3e,0x20,0x2b,0x6f,
103+
0x72,0x69,0x67,0x69,0x6e,0x3d,0x53,0x77,
104+
0x69,0x73,0x73,0x74,0x6f,0x70,0x6f,0x20,
105+
0x2b,0x6c,0x61,0x73,0x74,0x75,0x70,0x64,
106+
0x61,0x74,0x65,0x3d,0x32,0x30,0x31,0x32,
107+
0x2d,0x30,0x32,0x2d,0x32,0x37,0x0a,0x23,
108+
0x20,0x43,0x48,0x31,0x39,0x30,0x33,0x2f,
109+
0x4c,0x56,0x30,0x33,0x0a,0x3c,0x31,0x39,
110+
0x30,0x33,0x5f,0x4c,0x56,0x30,0x33,0x3e,
111+
0x20,0x20,0x2b,0x70,0x72,0x6f,0x6a,0x3d,
112+
0x73,0x6f,0x6d,0x65,0x72,0x63,0x20,0x2b,
113+
0x6c,0x61,0x74,0x5f,0x30,0x3d,0x34,0x36,
114+
0x2e,0x39,0x35,0x32,0x34,0x30,0x35,0x35,
115+
0x35,0x35,0x35,0x35,0x35,0x35,0x36,0x20,
116+
0x2b,0x6c,0x6f,0x6e,0x5f,0x30,0x3d,0x37,
117+
0x2e,0x34,0x33,0x39,0x35,0x38,0x33,0x33,
118+
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
119+
0x20,0x2b,0x6b,0x5f,0x30,0x3d,0x31,0x20,
120+
0x2b,0x78,0x5f,0x30,0x3d,0x36,0x30,0x30,
121+
0x30,0x30,0x30,0x20,0x2b,0x79,0x5f,0x30,
122+
0x3d,0x32,0x30,0x30,0x30,0x30,0x30,0x20,
123+
0x2b,0x65,0x6c,0x6c,0x70,0x73,0x3d,0x62,
124+
0x65,0x73,0x73,0x65,0x6c,0x20,0x2b,0x75,
125+
0x6e,0x69,0x74,0x73,0x3d,0x6d,0x20,0x2b,
126+
0x6e,0x61,0x64,0x67,0x72,0x69,0x64,0x73,
127+
0x3d,0x43,0x48,0x45,0x4e,0x79,0x78,0x30,
128+
0x36,0x5f,0x45,0x54,0x52,0x53,0x2e,0x67,
129+
0x73,0x62,0x20,0x2b,0x6e,0x6f,0x5f,0x64,
130+
0x65,0x66,0x73,0x0a,0x23,0x20,0x43,0x48,
131+
0x31,0x39,0x30,0x33,0x0a,0x3c,0x31,0x39,
132+
0x30,0x33,0x3e,0x20,0x2b,0x70,0x72,0x6f,
133+
0x6a,0x3d,0x6c,0x6f,0x6e,0x67,0x6c,0x61,
134+
0x74,0x20,0x2b,0x65,0x6c,0x6c,0x70,0x73,
135+
0x3d,0x62,0x65,0x73,0x73,0x65,0x6c,0x20,
136+
0x2b,0x6e,0x61,0x64,0x67,0x72,0x69,0x64,
137+
0x73,0x3d,0x43,0x48,0x45,0x4e,0x79,0x78,
138+
0x30,0x36,0x5f,0x45,0x54,0x52,0x53,0x2e,
139+
0x67,0x73,0x62,0x20,0x2b,0x6e,0x6f,0x5f,
140+
0x64,0x65,0x66,0x73,0x20,0x20,0x3c,0x3e,
141+
0x0a,
142+
};
143+
const unsigned CH_size = sizeof(CH_data);

src/file_embed/CH.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
#ifndef CH_H
3+
#define CH_H
4+
#include <stdint.h>
5+
extern const uint8_t CH_data[];
6+
extern const unsigned CH_size;
7+
#endif // CH_H
8+

0 commit comments

Comments
 (0)