mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Generate the usage message of each tool from its long_options (#409)
* Generate the usage message of each tool from its long_options
The usage messages of tile-join, tippecanoe-overzoom,
tippecanoe-json-tool, tippecanoe-decode, and tippecanoe-enumerate were
hand-written lists of options that had drifted years out of date, since
nothing tied them to the options that are really accepted. Move the
option-list printing that tippecanoe already does into a shared
print_usage(), and use it in all the tools, so that the message is
derived from the same long_options table that getopt_long() gets and
can't fall behind it again.
The tables now carry section headings, as tippecanoe's does, and the
options that were only reachable by their short names (tile-join's -O,
-b, -R, and -r among them) are listed for the first time.
Also state the non-option arguments the way each tool really treats
them: tile-join takes source tilesets unless --read-from names a file to
read them from, tippecanoe-decode takes a tileset either alone or with a
zoom/x/y, tippecanoe-json-tool reads standard input when no files are
named, and tippecanoe-overzoom's two forms are the ones its argument
parsing recognizes. tippecanoe-overzoom now reports the missing -o
instead of passing NULL to fopen(), and tippecanoe-enumerate goes
through getopt_long() so that it will pick up any options added later.
The shared getopt_string() replaces the identical loop that four of the
tools each had for building the short option string, and strip_usage_headings()
the one for dropping the headings before getopt_long() sees them.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016frkRY1xXtiWjxYuCJ8vZY
* Print the usage message when tippecanoe is run with no arguments
Running `tippecanoe` with nothing at all reported the missing output
file, which is true but is not what someone who typed the bare command
needs to know. Check for the empty command line before parsing and print
the general usage message instead, and leave the specific complaint for
the case where an input file was named but an output file wasn't.
To make the message reachable from there, the options table and the
usage printing move out of main() into a usage() function, as in the
other tools.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016frkRY1xXtiWjxYuCJ8vZY
* Address review: alternation, the dead tile-join option, and --version
Four fixes from review of the generated usage messages:
* `--output` and `--output-to-directory` are one-of, not one required and
one optional, in both tippecanoe and tile-join. A `usage_required_option`
can now name an alternation that it belongs to, and the options in one
are listed together as `(--output=... | --output-to-directory=...)`,
which is what the runtime check enforces.
* tile-join's `--use-attribute-for-id` has had no implementation since
533e000 removed it; only the table entry was left behind, so the option
parsed and then exited with "Unrecognized option". Generating the usage
message from the table turned that into a documented option that doesn't
work, so remove the leftover entry too.
* `--version` was grouped under "Progress indicator", in the options table
and in the README both. Give it a heading of its own now that the
headings are something users see.
* print_usage() left `width` holding the length of the last synopsis line,
and only got away with it because every table so far begins with a
heading, which resets it. Start the option list on a line of its own
instead of depending on that.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016frkRY1xXtiWjxYuCJ8vZY
---------
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
1b060b7faf
commit
e6e1ec3263
@@ -57,6 +57,7 @@
|
||||
#include "geometry.hpp"
|
||||
#include "serial.hpp"
|
||||
#include "options.hpp"
|
||||
#include "usage.hpp"
|
||||
#include "mvt.hpp"
|
||||
#include "dirtiles.hpp"
|
||||
#include "evaluator.hpp"
|
||||
@@ -2965,11 +2966,206 @@ void parse_json_source(const char *arg, struct source &src) {
|
||||
json_end(jp);
|
||||
}
|
||||
|
||||
static const struct option long_options_orig[] = {
|
||||
{"Output tileset", 0, 0, 0},
|
||||
{"output", required_argument, 0, 'o'},
|
||||
{"output-to-directory", required_argument, 0, 'e'},
|
||||
{"force", no_argument, 0, 'f'},
|
||||
{"allow-existing", no_argument, 0, 'F'},
|
||||
|
||||
{"Tileset description and attribution", 0, 0, 0},
|
||||
{"name", required_argument, 0, 'n'},
|
||||
{"attribution", required_argument, 0, 'A'},
|
||||
{"description", required_argument, 0, 'N'},
|
||||
|
||||
{"Input files and layer names", 0, 0, 0},
|
||||
{"layer", required_argument, 0, 'l'},
|
||||
{"named-layer", required_argument, 0, 'L'},
|
||||
|
||||
{"Parallel processing of input", 0, 0, 0},
|
||||
{"read-parallel", no_argument, 0, 'P'},
|
||||
|
||||
{"Projection of input", 0, 0, 0},
|
||||
{"projection", required_argument, 0, 's'},
|
||||
|
||||
{"Zoom levels", 0, 0, 0},
|
||||
{"maximum-zoom", required_argument, 0, 'z'},
|
||||
{"minimum-zoom", required_argument, 0, 'Z'},
|
||||
{"smallest-maximum-zoom-guess", required_argument, 0, '~'},
|
||||
{"extend-zooms-if-still-dropping", no_argument, &additional[A_EXTEND_ZOOMS], 1},
|
||||
{"extend-zooms-if-still-dropping-maximum", required_argument, 0, '~'},
|
||||
{"generate-variable-depth-tile-pyramid", no_argument, &additional[A_VARIABLE_DEPTH_PYRAMID], 1},
|
||||
{"one-tile", required_argument, 0, 'R'},
|
||||
|
||||
{"Tile resolution", 0, 0, 0},
|
||||
{"full-detail", required_argument, 0, 'd'},
|
||||
{"low-detail", required_argument, 0, 'D'},
|
||||
{"minimum-detail", required_argument, 0, 'm'},
|
||||
{"extra-detail", required_argument, 0, '~'},
|
||||
|
||||
{"Filtering feature attributes", 0, 0, 0},
|
||||
{"exclude", required_argument, 0, 'x'},
|
||||
{"include", required_argument, 0, 'y'},
|
||||
{"exclude-all", no_argument, 0, 'X'},
|
||||
|
||||
{"Modifying feature attributes", 0, 0, 0},
|
||||
{"attribute-type", required_argument, 0, 'T'},
|
||||
{"attribute-description", required_argument, 0, 'Y'},
|
||||
{"accumulate-attribute", required_argument, 0, 'E'},
|
||||
{"empty-csv-columns-are-null", no_argument, &prevent[P_EMPTY_CSV_COLUMNS], 1},
|
||||
{"convert-stringified-ids-to-numbers", no_argument, &additional[A_CONVERT_NUMERIC_IDS], 1},
|
||||
{"use-attribute-for-id", required_argument, 0, '~'},
|
||||
{"single-precision", no_argument, &prevent[P_SINGLE_PRECISION], 1},
|
||||
{"set-attribute", required_argument, 0, '~'},
|
||||
{"maximum-string-attribute-length", required_argument, 0, '~'},
|
||||
|
||||
{"Filtering features by attributes", 0, 0, 0},
|
||||
{"feature-filter-file", required_argument, 0, 'J'},
|
||||
{"feature-filter", required_argument, 0, 'j'},
|
||||
{"unidecode-data", required_argument, 0, '~'},
|
||||
|
||||
{"Dropping a fixed fraction of features by zoom level", 0, 0, 0},
|
||||
{"drop-rate", required_argument, 0, 'r'},
|
||||
{"retain-points-multiplier", required_argument, 0, '~'},
|
||||
{"base-zoom", required_argument, 0, 'B'},
|
||||
{"drop-denser", required_argument, 0, '~'},
|
||||
{"limit-base-zoom-to-maximum-zoom", no_argument, &prevent[P_BASEZOOM_ABOVE_MAXZOOM], 1},
|
||||
{"drop-lines", no_argument, &additional[A_LINE_DROP], 1},
|
||||
{"drop-polygons", no_argument, &additional[A_POLYGON_DROP], 1},
|
||||
{"cluster-distance", required_argument, 0, 'K'},
|
||||
{"cluster-maxzoom", required_argument, 0, 'k'},
|
||||
{"preserve-point-density-threshold", required_argument, 0, '~'},
|
||||
{"preserve-multiplier-density-threshold", required_argument, 0, '~'},
|
||||
|
||||
{"Dropping or merging a fraction of features to keep under tile size limits", 0, 0, 0},
|
||||
{"drop-densest-as-needed", no_argument, &additional[A_DROP_DENSEST_AS_NEEDED], 1},
|
||||
{"drop-fraction-as-needed", no_argument, &additional[A_DROP_FRACTION_AS_NEEDED], 1},
|
||||
{"drop-smallest-as-needed", no_argument, &additional[A_DROP_SMALLEST_AS_NEEDED], 1},
|
||||
{"drop-by-attribute-as-needed", required_argument, 0, '~'},
|
||||
{"drop-by-attribute-order", required_argument, 0, '~'},
|
||||
{"coalesce-densest-as-needed", no_argument, &additional[A_COALESCE_DENSEST_AS_NEEDED], 1},
|
||||
{"coalesce-fraction-as-needed", no_argument, &additional[A_COALESCE_FRACTION_AS_NEEDED], 1},
|
||||
{"coalesce-smallest-as-needed", no_argument, &additional[A_COALESCE_SMALLEST_AS_NEEDED], 1},
|
||||
{"force-feature-limit", no_argument, &prevent[P_DYNAMIC_DROP], 1},
|
||||
{"cluster-densest-as-needed", no_argument, &additional[A_CLUSTER_DENSEST_AS_NEEDED], 1},
|
||||
{"keep-point-cluster-position", no_argument, &additional[A_KEEP_POINT_CLUSTER_POSITION], 1},
|
||||
|
||||
{"Dropping tightly overlapping features", 0, 0, 0},
|
||||
{"gamma", required_argument, 0, 'g'},
|
||||
{"increase-gamma-as-needed", no_argument, &additional[A_INCREASE_GAMMA_AS_NEEDED], 1},
|
||||
|
||||
{"Line and polygon simplification", 0, 0, 0},
|
||||
{"simplification", required_argument, 0, 'S'},
|
||||
{"no-line-simplification", no_argument, &prevent[P_SIMPLIFY], 1},
|
||||
{"simplify-only-low-zooms", no_argument, &prevent[P_SIMPLIFY_LOW], 1},
|
||||
{"simplification-at-maximum-zoom", required_argument, 0, '~'},
|
||||
{"no-tiny-polygon-reduction", no_argument, &prevent[P_TINY_POLYGON_REDUCTION], 1},
|
||||
{"no-tiny-polygon-reduction-at-maximum-zoom", no_argument, &prevent[P_TINY_POLYGON_REDUCTION_AT_MAXZOOM], 1},
|
||||
{"tiny-polygon-size", required_argument, 0, '~'},
|
||||
{"no-simplification-of-shared-nodes", no_argument, &prevent[P_SIMPLIFY_SHARED_NODES], 1},
|
||||
{"visvalingam", no_argument, &additional[A_VISVALINGAM], 1},
|
||||
|
||||
{"Attempts to improve shared polygon boundaries", 0, 0, 0},
|
||||
{"detect-shared-borders", no_argument, &additional[A_DETECT_SHARED_BORDERS], 1},
|
||||
{"grid-low-zooms", no_argument, &additional[A_GRID_LOW_ZOOMS], 1},
|
||||
|
||||
{"Controlling clipping to tile boundaries", 0, 0, 0},
|
||||
{"buffer", required_argument, 0, 'b'},
|
||||
{"no-clipping", no_argument, &prevent[P_CLIPPING], 1},
|
||||
{"no-duplication", no_argument, &prevent[P_DUPLICATION], 1},
|
||||
|
||||
{"Reordering features within each tile", 0, 0, 0},
|
||||
{"preserve-input-order", no_argument, &prevent[P_INPUT_ORDER], 1},
|
||||
{"reorder", no_argument, &additional[A_REORDER], 1},
|
||||
{"coalesce", no_argument, &additional[A_COALESCE], 1},
|
||||
{"reverse", no_argument, &additional[A_REVERSE], 1},
|
||||
{"hilbert", no_argument, &additional[A_HILBERT], 1},
|
||||
{"order-by", required_argument, 0, '~'},
|
||||
{"order-descending-by", required_argument, 0, '~'},
|
||||
{"order-smallest-first", no_argument, 0, '~'},
|
||||
{"order-largest-first", no_argument, 0, '~'},
|
||||
|
||||
{"Adding calculated attributes", 0, 0, 0},
|
||||
{"calculate-feature-density", no_argument, &additional[A_CALCULATE_FEATURE_DENSITY], 1},
|
||||
{"generate-ids", no_argument, &additional[A_GENERATE_IDS], 1},
|
||||
{"calculate-feature-index", no_argument, &additional[A_CALCULATE_INDEX], 1},
|
||||
|
||||
{"Trying to correct bad source geometry", 0, 0, 0},
|
||||
{"detect-longitude-wraparound", no_argument, &additional[A_DETECT_WRAPAROUND], 1},
|
||||
{"use-source-polygon-winding", no_argument, &prevent[P_USE_SOURCE_POLYGON_WINDING], 1},
|
||||
{"reverse-source-polygon-winding", no_argument, &prevent[P_REVERSE_SOURCE_POLYGON_WINDING], 1},
|
||||
{"clip-bounding-box", required_argument, 0, '~'},
|
||||
{"convert-polygons-to-label-points", no_argument, &additional[A_GENERATE_POLYGON_LABEL_POINTS], 1},
|
||||
|
||||
{"Filtering tile contents", 0, 0, 0},
|
||||
{"prefilter", required_argument, 0, 'C'},
|
||||
{"postfilter", required_argument, 0, 'c'},
|
||||
|
||||
{"Setting or disabling tile size limits", 0, 0, 0},
|
||||
{"maximum-tile-bytes", required_argument, 0, 'M'},
|
||||
{"maximum-tile-features", required_argument, 0, 'O'},
|
||||
{"limit-tile-feature-count", required_argument, 0, '~'},
|
||||
{"limit-tile-feature-count-at-maximum-zoom", required_argument, 0, '~'},
|
||||
{"no-feature-limit", no_argument, &prevent[P_FEATURE_LIMIT], 1},
|
||||
{"no-tile-size-limit", no_argument, &prevent[P_KILOBYTE_LIMIT], 1},
|
||||
{"no-tile-compression", no_argument, &prevent[P_TILE_COMPRESSION], 1},
|
||||
{"no-tile-stats", no_argument, &prevent[P_TILE_STATS], 1},
|
||||
{"tile-stats-attributes-limit", required_argument, 0, '~'},
|
||||
{"tile-stats-sample-values-limit", required_argument, 0, '~'},
|
||||
{"tile-stats-values-limit", required_argument, 0, '~'},
|
||||
|
||||
{"Temporary storage", 0, 0, 0},
|
||||
{"temporary-directory", required_argument, 0, 't'},
|
||||
|
||||
{"Progress indicator", 0, 0, 0},
|
||||
{"quiet", no_argument, 0, 'q'},
|
||||
{"no-progress-indicator", no_argument, 0, 'Q'},
|
||||
{"progress-interval", required_argument, 0, 'U'},
|
||||
{"json-progress", no_argument, 0, 'u'},
|
||||
|
||||
{"Version", 0, 0, 0},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
|
||||
{"", 0, 0, 0},
|
||||
{"prevent", required_argument, 0, 'p'},
|
||||
{"additional", required_argument, 0, 'a'},
|
||||
{"check-polygons", no_argument, &additional[A_DEBUG_POLYGON], 1},
|
||||
{"no-polygon-splitting", no_argument, &prevent[P_POLYGON_SPLIT], 1},
|
||||
{"prefer-radix-sort", no_argument, &additional[A_PREFER_RADIX_SORT], 1},
|
||||
{"help", no_argument, 0, 'H'},
|
||||
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
// the options above, with the usage message headings removed
|
||||
static struct option long_options[sizeof(long_options_orig) / sizeof(long_options_orig[0])];
|
||||
|
||||
void usage(char **argv, int status) {
|
||||
static const char *const forms[] = {
|
||||
"[options] [file.json ...]",
|
||||
NULL,
|
||||
};
|
||||
static const struct usage_required_option required[] = {
|
||||
{"output", "output.mbtiles", 1},
|
||||
{"output-to-directory", "directory", 1},
|
||||
{NULL, NULL, 0},
|
||||
};
|
||||
|
||||
print_usage(stderr, argv[0], forms, long_options_orig, required);
|
||||
exit(status);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#ifdef MTRACE
|
||||
mtrace();
|
||||
#endif
|
||||
|
||||
if (argc == 1) {
|
||||
// with no arguments at all, there is nothing to complain about
|
||||
// specifically, so say in general what the arguments should be
|
||||
usage(argv, EXIT_ARGS);
|
||||
}
|
||||
|
||||
av = argv;
|
||||
init_cpus();
|
||||
|
||||
@@ -3017,197 +3213,9 @@ int main(int argc, char **argv) {
|
||||
additional[i] = 0;
|
||||
}
|
||||
|
||||
static struct option long_options_orig[] = {
|
||||
{"Output tileset", 0, 0, 0},
|
||||
{"output", required_argument, 0, 'o'},
|
||||
{"output-to-directory", required_argument, 0, 'e'},
|
||||
{"force", no_argument, 0, 'f'},
|
||||
{"allow-existing", no_argument, 0, 'F'},
|
||||
|
||||
{"Tileset description and attribution", 0, 0, 0},
|
||||
{"name", required_argument, 0, 'n'},
|
||||
{"attribution", required_argument, 0, 'A'},
|
||||
{"description", required_argument, 0, 'N'},
|
||||
|
||||
{"Input files and layer names", 0, 0, 0},
|
||||
{"layer", required_argument, 0, 'l'},
|
||||
{"named-layer", required_argument, 0, 'L'},
|
||||
|
||||
{"Parallel processing of input", 0, 0, 0},
|
||||
{"read-parallel", no_argument, 0, 'P'},
|
||||
|
||||
{"Projection of input", 0, 0, 0},
|
||||
{"projection", required_argument, 0, 's'},
|
||||
|
||||
{"Zoom levels", 0, 0, 0},
|
||||
{"maximum-zoom", required_argument, 0, 'z'},
|
||||
{"minimum-zoom", required_argument, 0, 'Z'},
|
||||
{"smallest-maximum-zoom-guess", required_argument, 0, '~'},
|
||||
{"extend-zooms-if-still-dropping", no_argument, &additional[A_EXTEND_ZOOMS], 1},
|
||||
{"extend-zooms-if-still-dropping-maximum", required_argument, 0, '~'},
|
||||
{"generate-variable-depth-tile-pyramid", no_argument, &additional[A_VARIABLE_DEPTH_PYRAMID], 1},
|
||||
{"one-tile", required_argument, 0, 'R'},
|
||||
|
||||
{"Tile resolution", 0, 0, 0},
|
||||
{"full-detail", required_argument, 0, 'd'},
|
||||
{"low-detail", required_argument, 0, 'D'},
|
||||
{"minimum-detail", required_argument, 0, 'm'},
|
||||
{"extra-detail", required_argument, 0, '~'},
|
||||
|
||||
{"Filtering feature attributes", 0, 0, 0},
|
||||
{"exclude", required_argument, 0, 'x'},
|
||||
{"include", required_argument, 0, 'y'},
|
||||
{"exclude-all", no_argument, 0, 'X'},
|
||||
|
||||
{"Modifying feature attributes", 0, 0, 0},
|
||||
{"attribute-type", required_argument, 0, 'T'},
|
||||
{"attribute-description", required_argument, 0, 'Y'},
|
||||
{"accumulate-attribute", required_argument, 0, 'E'},
|
||||
{"empty-csv-columns-are-null", no_argument, &prevent[P_EMPTY_CSV_COLUMNS], 1},
|
||||
{"convert-stringified-ids-to-numbers", no_argument, &additional[A_CONVERT_NUMERIC_IDS], 1},
|
||||
{"use-attribute-for-id", required_argument, 0, '~'},
|
||||
{"single-precision", no_argument, &prevent[P_SINGLE_PRECISION], 1},
|
||||
{"set-attribute", required_argument, 0, '~'},
|
||||
{"maximum-string-attribute-length", required_argument, 0, '~'},
|
||||
|
||||
{"Filtering features by attributes", 0, 0, 0},
|
||||
{"feature-filter-file", required_argument, 0, 'J'},
|
||||
{"feature-filter", required_argument, 0, 'j'},
|
||||
{"unidecode-data", required_argument, 0, '~'},
|
||||
|
||||
{"Dropping a fixed fraction of features by zoom level", 0, 0, 0},
|
||||
{"drop-rate", required_argument, 0, 'r'},
|
||||
{"retain-points-multiplier", required_argument, 0, '~'},
|
||||
{"base-zoom", required_argument, 0, 'B'},
|
||||
{"drop-denser", required_argument, 0, '~'},
|
||||
{"limit-base-zoom-to-maximum-zoom", no_argument, &prevent[P_BASEZOOM_ABOVE_MAXZOOM], 1},
|
||||
{"drop-lines", no_argument, &additional[A_LINE_DROP], 1},
|
||||
{"drop-polygons", no_argument, &additional[A_POLYGON_DROP], 1},
|
||||
{"cluster-distance", required_argument, 0, 'K'},
|
||||
{"cluster-maxzoom", required_argument, 0, 'k'},
|
||||
{"preserve-point-density-threshold", required_argument, 0, '~'},
|
||||
{"preserve-multiplier-density-threshold", required_argument, 0, '~'},
|
||||
|
||||
{"Dropping or merging a fraction of features to keep under tile size limits", 0, 0, 0},
|
||||
{"drop-densest-as-needed", no_argument, &additional[A_DROP_DENSEST_AS_NEEDED], 1},
|
||||
{"drop-fraction-as-needed", no_argument, &additional[A_DROP_FRACTION_AS_NEEDED], 1},
|
||||
{"drop-smallest-as-needed", no_argument, &additional[A_DROP_SMALLEST_AS_NEEDED], 1},
|
||||
{"drop-by-attribute-as-needed", required_argument, 0, '~'},
|
||||
{"drop-by-attribute-order", required_argument, 0, '~'},
|
||||
{"coalesce-densest-as-needed", no_argument, &additional[A_COALESCE_DENSEST_AS_NEEDED], 1},
|
||||
{"coalesce-fraction-as-needed", no_argument, &additional[A_COALESCE_FRACTION_AS_NEEDED], 1},
|
||||
{"coalesce-smallest-as-needed", no_argument, &additional[A_COALESCE_SMALLEST_AS_NEEDED], 1},
|
||||
{"force-feature-limit", no_argument, &prevent[P_DYNAMIC_DROP], 1},
|
||||
{"cluster-densest-as-needed", no_argument, &additional[A_CLUSTER_DENSEST_AS_NEEDED], 1},
|
||||
{"keep-point-cluster-position", no_argument, &additional[A_KEEP_POINT_CLUSTER_POSITION], 1},
|
||||
|
||||
{"Dropping tightly overlapping features", 0, 0, 0},
|
||||
{"gamma", required_argument, 0, 'g'},
|
||||
{"increase-gamma-as-needed", no_argument, &additional[A_INCREASE_GAMMA_AS_NEEDED], 1},
|
||||
|
||||
{"Line and polygon simplification", 0, 0, 0},
|
||||
{"simplification", required_argument, 0, 'S'},
|
||||
{"no-line-simplification", no_argument, &prevent[P_SIMPLIFY], 1},
|
||||
{"simplify-only-low-zooms", no_argument, &prevent[P_SIMPLIFY_LOW], 1},
|
||||
{"simplification-at-maximum-zoom", required_argument, 0, '~'},
|
||||
{"no-tiny-polygon-reduction", no_argument, &prevent[P_TINY_POLYGON_REDUCTION], 1},
|
||||
{"no-tiny-polygon-reduction-at-maximum-zoom", no_argument, &prevent[P_TINY_POLYGON_REDUCTION_AT_MAXZOOM], 1},
|
||||
{"tiny-polygon-size", required_argument, 0, '~'},
|
||||
{"no-simplification-of-shared-nodes", no_argument, &prevent[P_SIMPLIFY_SHARED_NODES], 1},
|
||||
{"visvalingam", no_argument, &additional[A_VISVALINGAM], 1},
|
||||
|
||||
{"Attempts to improve shared polygon boundaries", 0, 0, 0},
|
||||
{"detect-shared-borders", no_argument, &additional[A_DETECT_SHARED_BORDERS], 1},
|
||||
{"grid-low-zooms", no_argument, &additional[A_GRID_LOW_ZOOMS], 1},
|
||||
|
||||
{"Controlling clipping to tile boundaries", 0, 0, 0},
|
||||
{"buffer", required_argument, 0, 'b'},
|
||||
{"no-clipping", no_argument, &prevent[P_CLIPPING], 1},
|
||||
{"no-duplication", no_argument, &prevent[P_DUPLICATION], 1},
|
||||
|
||||
{"Reordering features within each tile", 0, 0, 0},
|
||||
{"preserve-input-order", no_argument, &prevent[P_INPUT_ORDER], 1},
|
||||
{"reorder", no_argument, &additional[A_REORDER], 1},
|
||||
{"coalesce", no_argument, &additional[A_COALESCE], 1},
|
||||
{"reverse", no_argument, &additional[A_REVERSE], 1},
|
||||
{"hilbert", no_argument, &additional[A_HILBERT], 1},
|
||||
{"order-by", required_argument, 0, '~'},
|
||||
{"order-descending-by", required_argument, 0, '~'},
|
||||
{"order-smallest-first", no_argument, 0, '~'},
|
||||
{"order-largest-first", no_argument, 0, '~'},
|
||||
|
||||
{"Adding calculated attributes", 0, 0, 0},
|
||||
{"calculate-feature-density", no_argument, &additional[A_CALCULATE_FEATURE_DENSITY], 1},
|
||||
{"generate-ids", no_argument, &additional[A_GENERATE_IDS], 1},
|
||||
{"calculate-feature-index", no_argument, &additional[A_CALCULATE_INDEX], 1},
|
||||
|
||||
{"Trying to correct bad source geometry", 0, 0, 0},
|
||||
{"detect-longitude-wraparound", no_argument, &additional[A_DETECT_WRAPAROUND], 1},
|
||||
{"use-source-polygon-winding", no_argument, &prevent[P_USE_SOURCE_POLYGON_WINDING], 1},
|
||||
{"reverse-source-polygon-winding", no_argument, &prevent[P_REVERSE_SOURCE_POLYGON_WINDING], 1},
|
||||
{"clip-bounding-box", required_argument, 0, '~'},
|
||||
{"convert-polygons-to-label-points", no_argument, &additional[A_GENERATE_POLYGON_LABEL_POINTS], 1},
|
||||
|
||||
{"Filtering tile contents", 0, 0, 0},
|
||||
{"prefilter", required_argument, 0, 'C'},
|
||||
{"postfilter", required_argument, 0, 'c'},
|
||||
|
||||
{"Setting or disabling tile size limits", 0, 0, 0},
|
||||
{"maximum-tile-bytes", required_argument, 0, 'M'},
|
||||
{"maximum-tile-features", required_argument, 0, 'O'},
|
||||
{"limit-tile-feature-count", required_argument, 0, '~'},
|
||||
{"limit-tile-feature-count-at-maximum-zoom", required_argument, 0, '~'},
|
||||
{"no-feature-limit", no_argument, &prevent[P_FEATURE_LIMIT], 1},
|
||||
{"no-tile-size-limit", no_argument, &prevent[P_KILOBYTE_LIMIT], 1},
|
||||
{"no-tile-compression", no_argument, &prevent[P_TILE_COMPRESSION], 1},
|
||||
{"no-tile-stats", no_argument, &prevent[P_TILE_STATS], 1},
|
||||
{"tile-stats-attributes-limit", required_argument, 0, '~'},
|
||||
{"tile-stats-sample-values-limit", required_argument, 0, '~'},
|
||||
{"tile-stats-values-limit", required_argument, 0, '~'},
|
||||
|
||||
{"Temporary storage", 0, 0, 0},
|
||||
{"temporary-directory", required_argument, 0, 't'},
|
||||
|
||||
{"Progress indicator", 0, 0, 0},
|
||||
{"quiet", no_argument, 0, 'q'},
|
||||
{"no-progress-indicator", no_argument, 0, 'Q'},
|
||||
{"progress-interval", required_argument, 0, 'U'},
|
||||
{"json-progress", no_argument, 0, 'u'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
|
||||
{"", 0, 0, 0},
|
||||
{"prevent", required_argument, 0, 'p'},
|
||||
{"additional", required_argument, 0, 'a'},
|
||||
{"check-polygons", no_argument, &additional[A_DEBUG_POLYGON], 1},
|
||||
{"no-polygon-splitting", no_argument, &prevent[P_POLYGON_SPLIT], 1},
|
||||
{"prefer-radix-sort", no_argument, &additional[A_PREFER_RADIX_SORT], 1},
|
||||
{"help", no_argument, 0, 'H'},
|
||||
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
static struct option long_options[sizeof(long_options_orig) / sizeof(long_options_orig[0])];
|
||||
static char getopt_str[sizeof(long_options_orig) / sizeof(long_options_orig[0]) * 2 + 1];
|
||||
strip_usage_headings(long_options_orig, long_options);
|
||||
|
||||
{
|
||||
size_t out = 0;
|
||||
size_t cout = 0;
|
||||
for (size_t lo = 0; long_options_orig[lo].name != NULL; lo++) {
|
||||
if (long_options_orig[lo].val != 0) {
|
||||
long_options[out++] = long_options_orig[lo];
|
||||
|
||||
if (long_options_orig[lo].val > ' ') {
|
||||
getopt_str[cout++] = long_options_orig[lo].val;
|
||||
|
||||
if (long_options_orig[lo].has_arg == required_argument) {
|
||||
getopt_str[cout++] = ':';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long_options[out] = {0, 0, 0, 0};
|
||||
getopt_str[cout] = '\0';
|
||||
|
||||
for (size_t lo = 0; long_options[lo].name != NULL; lo++) {
|
||||
if (long_options[lo].flag != NULL) {
|
||||
if (*long_options[lo].flag != 0) {
|
||||
@@ -3226,9 +3234,10 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
std::string commandline = format_commandline(argc, argv);
|
||||
std::string getopt_str = getopt_string(long_options);
|
||||
|
||||
int option_index = 0;
|
||||
while ((i = getopt_long(argc, argv, getopt_str, long_options, &option_index)) != -1) {
|
||||
while ((i = getopt_long(argc, argv, getopt_str.c_str(), long_options, &option_index)) != -1) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
break;
|
||||
@@ -3652,43 +3661,11 @@ int main(int argc, char **argv) {
|
||||
set_attribute_accum(attribute_accum, optarg, argv);
|
||||
break;
|
||||
|
||||
default: {
|
||||
default:
|
||||
if (i != 'H' && i != '?') {
|
||||
fprintf(stderr, "Unknown option -%c\n", i);
|
||||
}
|
||||
int width = 7 + strlen(argv[0]);
|
||||
fprintf(stderr, "Usage: %s [options] [file.json ...]", argv[0]);
|
||||
for (size_t lo = 0; long_options_orig[lo].name != NULL && strlen(long_options_orig[lo].name) > 0; lo++) {
|
||||
if (long_options_orig[lo].val == 0) {
|
||||
fprintf(stderr, "\n %s\n ", long_options_orig[lo].name);
|
||||
width = 8;
|
||||
continue;
|
||||
}
|
||||
if (width + strlen(long_options_orig[lo].name) + 9 >= 80) {
|
||||
fprintf(stderr, "\n ");
|
||||
width = 8;
|
||||
}
|
||||
width += strlen(long_options_orig[lo].name) + 9;
|
||||
if (strcmp(long_options_orig[lo].name, "output") == 0) {
|
||||
fprintf(stderr, " --%s=output.mbtiles", long_options_orig[lo].name);
|
||||
width += 9;
|
||||
} else if (long_options_orig[lo].has_arg) {
|
||||
fprintf(stderr, " [--%s=...]", long_options_orig[lo].name);
|
||||
} else {
|
||||
fprintf(stderr, " [--%s]", long_options_orig[lo].name);
|
||||
}
|
||||
}
|
||||
if (width + 16 >= 80) {
|
||||
fprintf(stderr, "\n ");
|
||||
width = 8;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
if (i == 'H') {
|
||||
exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
exit(EXIT_ARGS);
|
||||
}
|
||||
}
|
||||
usage(argv, i == 'H' ? EXIT_SUCCESS : EXIT_ARGS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user