diff --git a/README.md b/README.md index 37a2148..3e5c5da 100644 --- a/README.md +++ b/README.md @@ -112,10 +112,10 @@ Layers in GeoJSON files (containing a FeatureCollection) can be represented by a ```bash # mvt -h -OVERVIEW: A utility for inspecting and working with vector tiles and GeoJSON files. +OVERVIEW: A utility for inspecting and working with vector tiles (MVT) and GeoJSON files. -The tile coordinate of vector tiles can be extracted from the path -if it's either in the form '/z/x/y' or 'z_x_y'. +A x/y/z tile coordinate is needed for encoding/decoding vector tiles (MVT). +This tile coordinate can be extracted from the file path/URL if it's either in the form '/z/x/y' or 'z_x_y'. Tile coordinates are not necessary for GeoJSON input files. Examples: diff --git a/Sources/MVTCLI/CLI.swift b/Sources/MVTCLI/CLI.swift index a9f40c4..f75d955 100644 --- a/Sources/MVTCLI/CLI.swift +++ b/Sources/MVTCLI/CLI.swift @@ -10,11 +10,11 @@ struct CLI: AsyncParsableCommand { static let configuration = CommandConfiguration( commandName: "mvt", - abstract: "A utility for inspecting and working with vector tiles and GeoJSON files.", + abstract: "A utility for inspecting and working with vector tiles (MVT) and GeoJSON files.", discussion: """ - The tile coordinate of vector tiles can be extracted from the path - if it's either in the form '/z/x/y' or 'z_x_y'. - Tile coordinates are not necessary for GeoJSON input files. + A x/y/z tile coordinate is needed for encoding/decoding vector tiles (MVT). + This tile coordinate can be extracted from the path/URL if it's either in the form '/z/x/y' or 'z_x_y'. + Tile coordinates are not necessary for GeoJSON files. Examples: - Tests/MVTToolsTests/TestData/14_8716_8015.vector.mvt diff --git a/Sources/MVTCLI/Dump.swift b/Sources/MVTCLI/Dump.swift index ea99fc3..36d1b25 100644 --- a/Sources/MVTCLI/Dump.swift +++ b/Sources/MVTCLI/Dump.swift @@ -14,7 +14,10 @@ extension CLI { @Option(name: [.customShort("P"), .long], help: "Feature property to use for the layer name in input and output GeoJSONs.") var propertyName: String = VectorTile.defaultLayerPropertyName - @Flag(name: [.customShort("D"), .long], help: "Don't add the layer name as a property to Features in the output GeoJSONs.") + @Flag(name: [.customLong("Di", withSingleDash: true), .long], help: "Don't parse the layer name (option 'property-name') from Feature properties in the input GeoJSONs. Might speed up GeoJSON parsing considerably.") + var disableInputLayerProperty: Bool = false + + @Flag(name: [.customLong("Do", withSingleDash: true), .long], help: "Don't add the layer name (option 'property-name') as a Feature property in the output GeoJSONs.") var disableOutputLayerProperty: Bool = false @OptionGroup @@ -34,8 +37,8 @@ extension CLI { var tile = VectorTile( contentsOfGeoJson: url, - layerProperty: propertyName, - layerWhitelist: layerAllowlist, + layerProperty: disableInputLayerProperty ? nil : propertyName, + layerWhitelist: disableInputLayerProperty ? nil : layerAllowlist, logger: options.verbose ? CLI.logger : nil) if tile == nil, diff --git a/Sources/MVTCLI/Export.swift b/Sources/MVTCLI/Export.swift index b86cf43..c925a20 100644 --- a/Sources/MVTCLI/Export.swift +++ b/Sources/MVTCLI/Export.swift @@ -20,7 +20,7 @@ extension CLI { @Option(name: [.customShort("P"), .long], help: "Feature property to use for the layer name in the output GeoJSON.") var propertyName: String = VectorTile.defaultLayerPropertyName - @Flag(name: [.customShort("D"), .long], help: "Don't add the layer name as a property to Features in the output GeoJSON.") + @Flag(name: [.customLong("Do", withSingleDash: true), .long], help: "Don't add the layer name (option 'property-name') as a Feature property in the output GeoJSONs.") var disableOutputLayerProperty: Bool = false @Flag(name: .shortAndLong, help: "Pretty-print the output GeoJSON.") diff --git a/Sources/MVTCLI/Import.swift b/Sources/MVTCLI/Import.swift index 6ecb5e4..27abb89 100644 --- a/Sources/MVTCLI/Import.swift +++ b/Sources/MVTCLI/Import.swift @@ -24,7 +24,7 @@ extension CLI { @Option(name: [.customShort("P"), .long], help: "Feature property to use for the layer name in input GeoJSONs. Fallback to 'layer-name' or a default if the property is not present.") var propertyName: String = VectorTile.defaultLayerPropertyName - @Flag(name: [.customShort("D"), .long], help: "Don't try to find 'propert-name' in input GeoJSONs, just use 'layer-name' or a default. Might speed up things considerably.") + @Flag(name: [.customLong("Di", withSingleDash: true), .long], help: "Don't parse the layer name (option 'property-name') from Feature properties in the input GeoJSONs, just use 'layer-name' or a default. Might speed up GeoJSON parsing considerably.") var disableInputLayerProperty: Bool = false @OptionGroup diff --git a/Sources/MVTCLI/Info.swift b/Sources/MVTCLI/Info.swift index 7892671..fc2be14 100644 --- a/Sources/MVTCLI/Info.swift +++ b/Sources/MVTCLI/Info.swift @@ -11,7 +11,15 @@ extension CLI { case properties } - static let configuration = CommandConfiguration(abstract: "Print information about the input file (MVT or GeoJSON)") + static let configuration = CommandConfiguration( + abstract: "Print information about the input file (MVT or GeoJSON)", + discussion: """ + Available tables: + - features: Feature counts (points, linestrings, polygons) for each layer + in the input file. + - properties: Counts of all Feature properties for each layer in the + input file. + """) @Option(name: .shortAndLong, help: "The tables to print, comma separated list of '\(InfoTables.allCases.map(\.rawValue).joined(separator: ","))'.", diff --git a/Sources/MVTCLI/Merge.swift b/Sources/MVTCLI/Merge.swift index 4355642..3bedef0 100644 --- a/Sources/MVTCLI/Merge.swift +++ b/Sources/MVTCLI/Merge.swift @@ -14,7 +14,7 @@ extension CLI { static let configuration = CommandConfiguration( abstract: "Merge any number of MVTs or GeoJSONs", - discussion: "Vector tiles should all have the same tile coordinate, or you will get strange results.") + discussion: "Note: Vector tiles should all have the same tile coordinate or strange things will happen.") @Option(name: [.short, .customLong("output")], help: "Output file (optional, default is console).") var outputFile: String? @@ -22,19 +22,22 @@ extension CLI { @Option(name: [.customShort("O"), .long], help: "Output file format (optional, one of 'auto', 'geojson', 'mvt').") var outputFormat: OutputFormat = .auto - @Flag(name: .shortAndLong, help: "Force overwrite an existing --output file.") + @Flag(name: .shortAndLong, help: "Force overwrite an existing 'output' file.") var forceOverwrite = false - @Flag(name: .shortAndLong, help: "Append to an existing --output file.") + @Flag(name: .shortAndLong, help: "Append to an existing 'output' file.") var append = false @Option(name: .shortAndLong, help: "Merge only the specified layers (can be repeated).") var layer: [String] = [] - @Option(name: [.customShort("P"), .long], help: "Feature property to use for the layer name in the output GeoJSON.") + @Option(name: [.customShort("P"), .long], help: "Feature property to use for the layer name in input and output GeoJSONs.") var propertyName: String = VectorTile.defaultLayerPropertyName - @Flag(name: [.customShort("D"), .long], help: "Don't add the layer name as a property to Features in the output GeoJSON.") + @Flag(name: [.customLong("Di", withSingleDash: true), .long], help: "Don't parse the layer name (option 'property-name') from Feature properties in the input GeoJSONs. Might speed up GeoJSON parsing considerably.") + var disableInputLayerProperty: Bool = false + + @Flag(name: [.customLong("Do", withSingleDash: true), .long], help: "Don't add the layer name (option 'property-name') as a Feature property in the output GeoJSONs.") var disableOutputLayerProperty: Bool = false @Flag(name: .shortAndLong, help: "Pretty-print the output GeoJSON.") @@ -101,7 +104,7 @@ extension CLI { } else if let geoJsonTile = VectorTile( contentsOfGeoJson: outputUrl, - layerProperty: propertyName, + layerProperty: disableInputLayerProperty ? nil : propertyName, logger: options.verbose ? CLI.logger : nil) { tile = geoJsonTile @@ -180,8 +183,8 @@ extension CLI { } else if let other = VectorTile( contentsOfGeoJson: otherUrl, - layerProperty: propertyName, - layerWhitelist: layerAllowlist, + layerProperty: disableInputLayerProperty ? nil : propertyName, + layerWhitelist: disableInputLayerProperty ? nil : layerAllowlist, logger: options.verbose ? CLI.logger : nil) { otherTile = other diff --git a/Sources/MVTCLI/Query.swift b/Sources/MVTCLI/Query.swift index a837254..139bb32 100644 --- a/Sources/MVTCLI/Query.swift +++ b/Sources/MVTCLI/Query.swift @@ -21,10 +21,13 @@ extension CLI { @Option(name: .shortAndLong, help: "Search only in this layer (can be repeated).") var layer: [String] = [] - @Option(name: [.customShort("P"), .long], help: "Feature property to use for the layer name in the output GeoJSON.") + @Option(name: [.customShort("P"), .long], help: "Feature property to use for the layer name in input and output GeoJSONs.") var propertyName: String = VectorTile.defaultLayerPropertyName - @Flag(name: [.customShort("D"), .long], help: "Don't add the layer name as a property to Features in the output GeoJSON.") + @Flag(name: [.customLong("Di", withSingleDash: true), .long], help: "Don't parse the layer name (option 'property-name') from Feature properties in the input GeoJSONs. Might speed up GeoJSON parsing considerably.") + var disableInputLayerProperty: Bool = false + + @Flag(name: [.customLong("Do", withSingleDash: true), .long], help: "Don't add the layer name (option 'property-name') as a Feature property in the output GeoJSONs.") var disableOutputLayerProperty: Bool = false @Flag(name: .shortAndLong, help: "Pretty-print the output GeoJSON.") @@ -79,8 +82,8 @@ extension CLI { var tile = VectorTile( contentsOfGeoJson: url, - layerProperty: propertyName, - layerWhitelist: layerAllowlist, + layerProperty: disableInputLayerProperty ? nil : propertyName, + layerWhitelist: disableInputLayerProperty ? nil : layerAllowlist, logger: options.verbose ? CLI.logger : nil) if tile == nil,