Skip to content

Commit

Permalink
#17: Handle integer overflows in ids
Browse files Browse the repository at this point in the history
  • Loading branch information
trasch committed Mar 19, 2024
1 parent 9ddfaa0 commit 33c00cd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
12 changes: 6 additions & 6 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Outdooractive/gis-tools",
"state" : {
"revision" : "271ffa105096a3c5889b211227c9a31dc59030db",
"version" : "1.2.0"
"branch" : "45_feature_id_overflow",
"revision" : "4e74243416460049a927008a0e515001f3132566"
}
},
{
Expand All @@ -23,17 +23,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
"revision" : "46989693916f56d1186bd59ac15124caef896560",
"version" : "1.3.1"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version" : "1.5.3"
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ let package = Package(
targets: ["MVTTools"]),
],
dependencies: [
.package(url: "https://github.com/Outdooractive/gis-tools", from: "1.2.0"),
.package(url: "https://github.com/Outdooractive/gis-tools", branch: "45_feature_id_overflow"),
.package(url: "https://github.com/1024jp/GzipSwift.git", from: "5.2.0"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.3"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.1"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
.package(url: "https://github.com/apple/swift-protobuf", from: "1.25.2"),
],
targets: [
Expand Down
10 changes: 7 additions & 3 deletions Sources/MVTTools/VectorTileDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,13 @@ extension VectorTile {
properties[key] = value
}
layerFeature.properties = properties
layerFeature.id = feature.hasID
? .int(Int(feature.id))
: .string(UUID().uuidString)

if feature.hasID {
layerFeature.id = Feature.Identifier(value: feature.id)
}
else {
layerFeature.id = .string(UUID().uuidString)
}

layerFeatures.append(layerFeature)
}
Expand Down
6 changes: 2 additions & 4 deletions Sources/MVTTools/VectorTileEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,8 @@ extension VectorTile {
vectorTileFeature.type = geometryType
vectorTileFeature.geometry = geometryIntegers

if case let .int(int) = feature.id,
let converted = UInt64(exactly: int)
{
vectorTileFeature.id = converted
if let featureId = feature.id?.uint64Value {
vectorTileFeature.id = featureId
}

return vectorTileFeature
Expand Down

0 comments on commit 33c00cd

Please sign in to comment.