Skip to content

Commit

Permalink
Update -graticule command
Browse files Browse the repository at this point in the history
  • Loading branch information
mbloch committed Feb 12, 2024
1 parent 4e586c4 commit 6c74331
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/cli/mapshaper-options.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
5 changes: 4 additions & 1 deletion src/commands/mapshaper-graticule.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6c74331

Please sign in to comment.