Skip to content

Commit

Permalink
Add a second scalebar style, add cmd help for -scalebar command
Browse files Browse the repository at this point in the history
  • Loading branch information
mbloch committed Feb 20, 2024
1 parent 12d1599 commit 3c7c161
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
34 changes: 27 additions & 7 deletions src/cli/mapshaper-options.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1987,13 +1987,33 @@ export function getOptionParser() {
DEFAULT: true,
describe: 'distance label, e.g. "35 miles"'
})
.option('top', {})
.option('right', {})
.option('bottom', {})
.option('left', {})
.option('font-size', {})
// .option('font-family', {})
.option('label-position', {}); // top or bottom
.option('style', {
describe: 'two options: a or b'
})
.option('font-size', {
type: 'number'
})
.option('tic-length', {
describe: 'length of tic marks (style b)',
type: 'number'
})
.option('bar-width', {
describe: 'line width of bar',
type: 'number'
})
.option('label-offset', {
type: 'number'
})
.option('position', {
describe: 'e.g. bottom-right (default is top-left)'
})
.option('label-position', {
describe: 'top or bottom'
})
.option('margin', {
describe: 'offset in pixels from edge of map',
type: 'number'
});

parser.command('shape')
.describe('create a polyline or polygon from coordinates')
Expand Down
4 changes: 4 additions & 0 deletions src/cli/mapshaper-run-command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export async function runCommand(command, job) {
return done(null);
}

if (name == 'comment') {
return done(null);
}

if (!job) job = new Job();
job.startCommand(command);

Expand Down
4 changes: 2 additions & 2 deletions src/crs/mapshaper-projections.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ export function requireDatasetsHaveCompatibleCRS(arr) {
// x, y: a point location in projected coordinates
// Returns k, the ratio of coordinate distance to distance on the ground
export function getScaleFactorAtXY(x, y, crs) {
var dist = 1;
var dist = 1 / crs.to_meter;
var lp = mproj.pj_inv_deg({x: x, y: y}, crs);
var lp2 = mproj.pj_inv_deg({x: x + dist, y: y}, crs);
var k = dist / geom.greatCircleDistance(lp.lam, lp.phi, lp2.lam, lp2.phi);
var k = 1 / geom.greatCircleDistance(lp.lam, lp.phi, lp2.lam, lp2.phi);
return k;
}

Expand Down

0 comments on commit 3c7c161

Please sign in to comment.