Skip to content

Commit a2a6770

Browse files
committed
Support runtime-registered projections and update gis-tools to 3.0.0-beta.1
The generic projection system in gis-tools 3.0.0 replaces the Projection enum with an SRID-identified struct and a registry. Adapt mvt-tools: - Project tile coordinates through the EPSG:4326/Web Mercator pivot for any registered projection instead of special-casing the four built-ins (Projections.swift) - Compute tile/clip bounding boxes in the tile's own projection (MVTEncoder, MLTEncoder, VectorTile inits, ExportOptions) - Remove a redundant .clamped() in the query bounding box path - Update the six gis-tools* dependencies to the 3.0.0-beta.1 releases - Add CustomProjectionTests and ProjectionHandlingTests covering MVT round trips, clipping, queries, overzoom and merge for built-in and runtime-registered projections
1 parent 26a7e9c commit a2a6770

13 files changed

Lines changed: 807 additions & 165 deletions

‎.swiftformat‎

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
--acronyms ID,URL,UUID
2+
--allman false
3+
--allow-partial-wrapping false
4+
--anonymous-for-each convert
5+
--asset-literals visual-width
6+
--async-capturing
7+
--before-marks
8+
--binary-grouping 4,8
9+
--blank-line-after-switch-case multiline-only
10+
--call-site-paren same-line
11+
--category-mark "MARK: %c"
12+
--class-threshold 0
13+
--closing-paren default
14+
--closure-void remove
15+
--complex-attributes preserve
16+
--computed-var-attributes preserve
17+
--conditional-assignment after-property
18+
--conflict-markers reject
19+
--date-format system
20+
--decimal-grouping 3,6
21+
--default-test-suite-attributes
22+
--doc-comments before-declarations
23+
--else-position next-line
24+
--empty-braces no-space
25+
--enum-namespaces always
26+
--enum-threshold 0
27+
--equatable-macro none
28+
--exponent-case lowercase
29+
--exponent-grouping disabled
30+
--extension-acl on-declarations
31+
--extension-mark "MARK: - %t + %c"
32+
--extension-threshold 0
33+
--file-macro "#file"
34+
--fraction-grouping disabled
35+
--fragment false
36+
--func-attributes preserve
37+
--generic-types
38+
--group-blank-lines true
39+
--grouped-extension "MARK: %c"
40+
--guard-else auto
41+
--guard-like-if-statements preserve
42+
--header ignore
43+
--hex-grouping 4,8
44+
--hex-literal-case uppercase
45+
--ifdef no-indent
46+
--import-grouping alpha
47+
--indent 4
48+
--indent-blank-lines false
49+
--indent-case false
50+
--indent-strings false
51+
--inferred-types always
52+
--init-coder-nil false
53+
--lifecycle
54+
--line-after-marks true
55+
--line-between-guards false
56+
--linebreaks lf
57+
--list-wrap-threshold none
58+
--mark-categories true
59+
--mark-class-threshold 0
60+
--mark-enum-threshold 0
61+
--mark-extension-threshold 0
62+
--mark-extensions always
63+
--mark-struct-threshold 0
64+
--mark-types always
65+
--markdown-files ignore
66+
--max-width none
67+
--modifier-order
68+
--never-trailing
69+
--nil-init remove
70+
--no-space-operators
71+
--no-wrap-operators
72+
--non-complex-attributes
73+
--octal-grouping 4,8
74+
--operator-func spaced
75+
--organization-mode visibility
76+
--organize-types actor,class,enum,struct
77+
--pattern-let hoist
78+
--prefer-synthesized-init-for-internal-structs never
79+
--preserve-acronyms
80+
--preserve-decls
81+
--preserved-property-types Package
82+
--property-types infer-locals-only
83+
--ranges spaced
84+
--redundant-async tests-only
85+
--redundant-optional-binding same-name-only
86+
--redundant-throws tests-only
87+
--self init-only
88+
--self-required
89+
--semicolons inline-only
90+
--short-optionals except-properties
91+
--single-line-for-each ignore
92+
--single-line-ternary convert
93+
--smart-tabs enabled
94+
--some-any true
95+
--sort-swiftui-properties none
96+
--sorted-patterns
97+
--stored-var-attributes preserve
98+
--strip-unused-args always
99+
--struct-threshold 0
100+
--suite-name-format preserve
101+
--tab-width unspecified
102+
--test-case-access-control internal
103+
--test-case-name-format raw-identifiers
104+
--throw-capturing
105+
--timezone system
106+
--trailing-closures
107+
--trailing-commas always
108+
--trim-whitespace always
109+
--type-attributes prev-line
110+
--type-blank-lines insert
111+
--type-body-marks preserve
112+
--type-delimiter space-after
113+
--type-mark "MARK: - %t"
114+
--type-marks
115+
--type-order
116+
--url-macro none
117+
--visibility-marks
118+
--visibility-order
119+
--void-type Void
120+
--wrap-arguments before-first
121+
--wrap-collections before-first
122+
--wrap-conditions preserve
123+
--wrap-effects never
124+
--wrap-enum-cases with-values
125+
--wrap-parameters before-first
126+
--wrap-return-type never
127+
--wrap-string-interpolation false
128+
--wrap-ternary before-operators
129+
--wrap-type-aliases before-first
130+
--xcode-indentation enabled
131+
--xctest-symbols
132+
--yoda-swap always
133+
--disable trailingClosures,unusedArguments,preferExplicitFalse
134+
--enable blankLineAfterSwitchCase,blankLinesAfterGuardStatements,blockComments,isEmpty,preferContains,preferCountWhere,preferFirstWhere,preferFlatMap,preferLazyMap,preferMinOverSorted,preferSwiftStringAPI,preferSwiftTesting,singlePropertyPerLine,sortSwitchCases,unusedPrivateDeclarations,wrapEnumCases,wrapMultilineConditionalAssignment,wrapMultilineFunctionChains

‎Package.resolved‎

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Package.swift‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ let package = Package(
3939
description: "Enables Shapefile vector tile import/export."),
4040
],
4141
dependencies: [
42-
.package(url: "https://github.com/Outdooractive/gis-tools", from: "2.3.0"),
43-
.package(url: "https://github.com/Outdooractive/gis-tools-csv", from: "1.2.0"),
44-
.package(url: "https://github.com/Outdooractive/gis-tools-geopackage", from: "1.0.3"),
45-
.package(url: "https://github.com/Outdooractive/gis-tools-gpx", from: "1.0.4"),
46-
.package(url: "https://github.com/Outdooractive/gis-tools-fit", from: "1.0.0"),
47-
.package(url: "https://github.com/Outdooractive/gis-tools-shapefile", from: "1.0.2"),
42+
.package(url: "https://github.com/Outdooractive/gis-tools", exact: "3.0.0-beta.1"),
43+
.package(url: "https://github.com/Outdooractive/gis-tools-csv", exact: "3.0.0-beta.1"),
44+
.package(url: "https://github.com/Outdooractive/gis-tools-geopackage", exact: "3.0.0-beta.1"),
45+
.package(url: "https://github.com/Outdooractive/gis-tools-gpx", exact: "3.0.0-beta.1"),
46+
.package(url: "https://github.com/Outdooractive/gis-tools-fit", exact: "3.0.0-beta.1"),
47+
.package(url: "https://github.com/Outdooractive/gis-tools-shapefile", exact: "3.0.0-beta.1"),
4848
.package(url: "https://github.com/1024jp/GzipSwift.git", from: "7.0.0"),
4949
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.8.2"),
5050
.package(url: "https://github.com/apple/swift-log.git", from: "1.14.0"),

‎Sources/MVTTools/Coders/ExportOptions.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ extension VectorTile {
117117
}
118118

119119
var clipBoundingBox: BoundingBox?
120-
if bufferSize != 0 {
121-
clipBoundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: .epsg4326)
120+
if bufferSize != 0, projection.hasSRID {
121+
clipBoundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: projection)
122122
if let box = clipBoundingBox {
123123
let sqrt2 = 2.0.squareRoot()
124124
let diagonal = Double(VectorTile.ExportOptions.extent) * sqrt2

‎Sources/MVTTools/Coders/MLT/MLTEncoder.swift‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,8 @@ enum MLTEncoder {
3838

3939
// Determine the clipping bounding box.
4040
var clipBoundingBox: BoundingBox?
41-
switch projection {
42-
case .noSRID:
43-
break
44-
case .epsg3857:
45-
clipBoundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: .epsg3857)
46-
case .epsg4326:
47-
clipBoundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: .epsg4326)
48-
case .epsg4978:
49-
clipBoundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: .epsg4978)
41+
if projection.hasSRID {
42+
clipBoundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: projection)
5043
}
5144

5245
// Buffer size

‎Sources/MVTTools/Coders/MLT/VectorTile+MLT.swift‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ extension VectorTile {
4848
self.projection = projection
4949
self.logger = logger
5050

51-
switch projection {
52-
case .noSRID:
51+
if projection.hasSRID {
52+
self.boundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: projection)
53+
}
54+
else {
5355
self.boundingBox = BoundingBox(
5456
southWest: Coordinate3D(x: 0.0, y: 0.0, projection: .noSRID),
5557
northEast: Coordinate3D(x: Double(ExportOptions.extent), y: Double(ExportOptions.extent), projection: .noSRID))
56-
case .epsg3857, .epsg4326, .epsg4978:
57-
self.boundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: projection)
5858
}
5959

6060
let parsedLayers: [String: VectorTile.LayerContainer]

‎Sources/MVTTools/Coders/MVT/MVTEncoder.swift‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,8 @@ enum MVTEncoder {
4141

4242
// Determine the clipping bounding box.
4343
var clipBoundingBox: BoundingBox?
44-
switch projection {
45-
case .noSRID:
46-
break
47-
case .epsg3857:
48-
clipBoundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: .epsg3857)
49-
case .epsg4326:
50-
clipBoundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: .epsg4326)
51-
case .epsg4978:
52-
clipBoundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: .epsg4978)
44+
if projection.hasSRID {
45+
clipBoundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: projection)
5346
}
5447

5548
var bufferSize = 0

‎Sources/MVTTools/Coders/MVT/VectorTile+MVT.swift‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ extension VectorTile {
4747
self.projection = projection
4848
self.logger = logger
4949

50-
switch projection {
51-
case .noSRID:
50+
if projection.hasSRID {
51+
self.boundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: projection)
52+
}
53+
else {
5254
self.boundingBox = BoundingBox(
5355
southWest: Coordinate3D(x: 0.0, y: 0.0, projection: .noSRID),
5456
northEast: Coordinate3D(x: Double(ExportOptions.extent), y: Double(ExportOptions.extent), projection: .noSRID))
55-
case .epsg3857, .epsg4326, .epsg4978:
56-
self.boundingBox = MapTile(x: x, y: y, z: z).boundingBox(projection: projection)
5757
}
5858

5959
guard let parsedLayers = MVTDecoder.decode(

0 commit comments

Comments
 (0)