From 6c7433129298b92bb4368be96865b0eaeaf7c30e Mon Sep 17 00:00:00 2001 From: Matthew Bloch Date: Sun, 11 Feb 2024 20:43:22 -0500 Subject: [PATCH] Update -graticule command --- REFERENCE.md | 4 ++-- src/cli/mapshaper-options.mjs | 2 +- src/commands/mapshaper-graticule.mjs | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 40f5c749..30b2ef81 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -1,6 +1,6 @@ # COMMAND REFERENCE -This documentation applies to version 0.6.61 of mapshaper's command line program. Run `mapshaper -v` to check your version. For an introduction to the command line tool, read [this page](https://github.com/mbloch/mapshaper/wiki/Introduction-to-the-Command-Line-Tool) first. +This documentation applies to version 0.6.62 of mapshaper's command line program. Run `mapshaper -v` to check your version. For an introduction to the command line tool, read [this page](https://github.com/mbloch/mapshaper/wiki/Introduction-to-the-Command-Line-Tool) first. ## Command line syntax @@ -735,7 +735,7 @@ Create a graticule layer appropriate for a world map centered on longitude 0. `polygon` Create an polygon enclosing the entire area of the graticule. Useful for creating background or outline shapes for clipped projections, like Robinson or Stereographic. -`interval=` Specify the spacing of graticule lines (in degrees). Options include: 5, 10, 15, 30, 45. Default is 10. +`interval=` Specify the spacing of graticule lines (in degrees). Common options are: 5, 10, 15, 30, 45. Default is 10. ### -grid diff --git a/src/cli/mapshaper-options.mjs b/src/cli/mapshaper-options.mjs index 56310c54..7fb59efb 100644 --- a/src/cli/mapshaper-options.mjs +++ b/src/cli/mapshaper-options.mjs @@ -983,7 +983,7 @@ export function getOptionParser() { parser.command('graticule') .describe('create a graticule layer') .option('interval', { - describe: 'size of grid cells in degrees (options: 5 10 15 30 45, default is 10)', + describe: 'size of grid cells in degrees (default is 10)', type: 'number' }) .option('polygon', { diff --git a/src/commands/mapshaper-graticule.mjs b/src/commands/mapshaper-graticule.mjs index 3cf14537..4aa7c618 100644 --- a/src/commands/mapshaper-graticule.mjs +++ b/src/commands/mapshaper-graticule.mjs @@ -82,7 +82,9 @@ function addOutlineToGraticule(graticule, outline) { // function createGraticule(P, outlined, opts) { var interval = opts.interval || 10; - if (![5,10,15,20,30,45].includes(interval)) stop('Invalid interval:', interval); + if (Math.round(interval) != interval || interval > 0 === false) { + stop('Invalid interval:', interval); + } var lon0 = P.lam0 * 180 / Math.PI; var precision = interval > 10 ? 1 : 0.5; // degrees between each vertex var xstep = interval; @@ -123,6 +125,7 @@ function createGraticule(P, outlined, opts) { return Math.abs(a - b) < interval / 5; } + // extended: meridian extends to pole function createMeridian(x, extended) { var y0 = ystep <= 15 ? ystep : 0; createMeridianPart(x, -90 + y0, 90 - y0);