Skip to content

Commit

Permalink
Test case with a big int
Browse files Browse the repository at this point in the history
  • Loading branch information
trasch committed Mar 19, 2024
1 parent 33c00cd commit 29e7a1b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"location" : "https://github.com/Outdooractive/gis-tools",
"state" : {
"branch" : "45_feature_id_overflow",
"revision" : "4e74243416460049a927008a0e515001f3132566"
"revision" : "1cb8776f353dfd0b938251b1eb12ec6ddbb5f44c"
}
},
{
Expand Down
37 changes: 37 additions & 0 deletions Tests/MVTToolsTests/TestData/bigint_id.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"bbox" : [
-120.37960052490236,
34.045263375550654,
-120.37960052490236,
34.045263375550654
],
"geometry" : {
"coordinates" : [
-120.37960052490236,
34.045263375550654
],
"type" : "Point"
},
"id" : 18446744073638380036,
"properties" : {
"class" : "island",
"name" : "San Miguel Island",
"name_de" : "San Miguel Island",
"name_en" : "San Miguel Island",
"name_int" : "San Miguel Island",
"name:ca" : "illa San Miguel",
"name:de" : "San Miguel Island",
"name:en" : "San Miguel Island",
"name:es" : "Isla San Miguel",
"name:et" : "San Migueli saar",
"name:fr" : "île San Miguel",
"name:it" : "Isola di San Miguel",
"name:ja" : "サンミゲル島 (チャンネル諸島)",
"name:latin" : "San Miguel Island",
"name:nl" : "San Miguel Island",
"name:pl" : "San Miguel Island",
"name:zh" : "聖米格爾島",
"rank" : 3
},
"type" : "Feature"
}
15 changes: 15 additions & 0 deletions Tests/MVTToolsTests/VectorTileTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,19 @@ final class VectorTileTests: XCTestCase {
XCTAssertEqual(tile1.features(for: "test2")!.count, 1)
}

func testEncodeDecodeBigInt() throws {
let feature = try XCTUnwrap(Feature(jsonData: TestData.dataFromFile(name: "bigint_id.geojson")))
XCTAssertEqual(feature.id, .uint(18446744073638380036))

var tile = try XCTUnwrap(VectorTile(x: 10, y: 25, z: 6))
tile.setFeatures([feature], for: "test")
let tileData = try XCTUnwrap(tile.data())
XCTAssertFalse(tileData.isEmpty)

let tile2 = try XCTUnwrap(VectorTile(data: tileData, x: 10, y: 25, z: 6))
let feature2: Feature = try XCTUnwrap(tile2.features(for: "test")?.first)

XCTAssertEqual(feature.id, feature2.id)
}

}

0 comments on commit 29e7a1b

Please sign in to comment.