Skip to content

Commit

Permalink
Try hard to find tile coordinates from input files
Browse files Browse the repository at this point in the history
  • Loading branch information
trasch committed Aug 9, 2024
1 parent dbe79f1 commit 009066d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions Sources/MVTCLI/CLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ struct XYZOptions: ParsableArguments {
var z: Int?

mutating func parseXYZ(
fromPath path: String)
fromPaths paths: [String])
throws -> (Int, Int, Int)
{
if x == nil
|| y == nil
|| z == nil
{
for path in paths {
guard x == nil
|| y == nil
|| z == nil
else { break }

let urlParts = path.extractingGroupsUsingPattern("\\/(\\d+)\\/(\\d+)\\/(\\d+)(?:\\/|\\.)", caseInsensitive: false)
if urlParts.count >= 3 {
if let partX = Int(urlParts[1]),
Expand Down
2 changes: 1 addition & 1 deletion Sources/MVTCLI/Dump.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension CLI {
var path: String

mutating func run() async throws {
let (x, y, z) = try xyzOptions.parseXYZ(fromPath: path)
let (x, y, z) = try xyzOptions.parseXYZ(fromPaths: [path])
let url = try options.parseUrl(fromPath: path)

let layerAllowlist = layer.nonempty
Expand Down
2 changes: 1 addition & 1 deletion Sources/MVTCLI/Export.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension CLI {
var path: String

mutating func run() async throws {
let (x, y, z) = try xyzOptions.parseXYZ(fromPath: path)
let (x, y, z) = try xyzOptions.parseXYZ(fromPaths: [path])
let url = try options.parseUrl(fromPath: path)

let outputUrl = URL(fileURLWithPath: output)
Expand Down
2 changes: 1 addition & 1 deletion Sources/MVTCLI/Import.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension CLI {
var other: [String] = []

mutating func run() async throws {
let (x, y, z) = try xyzOptions.parseXYZ(fromPath: output)
let (x, y, z) = try xyzOptions.parseXYZ(fromPaths: [output] + other)

let outputUrl = URL(fileURLWithPath: output)
if (try? outputUrl.checkResourceIsReachable()) ?? false {
Expand Down
2 changes: 1 addition & 1 deletion Sources/MVTCLI/Merge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension CLI {
var other: [String] = []

mutating func run() async throws {
let (x, y, z) = try xyzOptions.parseXYZ(fromPath: output)
let (x, y, z) = try xyzOptions.parseXYZ(fromPaths: [output] + other)

let outputUrl = URL(fileURLWithPath: output)
if (try? outputUrl.checkResourceIsReachable()) ?? false {
Expand Down
2 changes: 1 addition & 1 deletion Sources/MVTCLI/Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension CLI {
}
}

let (x, y, z) = try xyzOptions.parseXYZ(fromPath: path)
let (x, y, z) = try xyzOptions.parseXYZ(fromPaths: [path])
let url = try options.parseUrl(fromPath: path)

let layerAllowlist = layer.nonempty
Expand Down

0 comments on commit 009066d

Please sign in to comment.