diff --git a/src/cli/mapshaper-options.mjs b/src/cli/mapshaper-options.mjs index 53d1d234..2cc1d9dd 100644 --- a/src/cli/mapshaper-options.mjs +++ b/src/cli/mapshaper-options.mjs @@ -995,12 +995,12 @@ export function getOptionParser() { describe: 'side length (e.g. 500m, 12km)', type: 'distance' }) - // .option('cols', { - // type: 'integer' - // }) - // .option('rows', { - // type: 'integer' - // }) + .option('cols', { + type: 'integer' + }) + .option('rows', { + type: 'integer' + }) // .option('bbox', { // type: 'bbox', // describe: 'xmin,ymin,xmax,ymax (default is bbox of data)' diff --git a/src/grids/mapshaper-grid-utils.mjs b/src/grids/mapshaper-grid-utils.mjs index c118464a..6ad302ce 100644 --- a/src/grids/mapshaper-grid-utils.mjs +++ b/src/grids/mapshaper-grid-utils.mjs @@ -14,4 +14,6 @@ export function twoCircleIntersection(c1, r1, c2, r2) { } return r1sq * Math.acos(d1/r1) - d1 * Math.sqrt(r1sq - d1 * d1) + r2sq * Math.acos(d2/r2) - d2 * Math.sqrt(r2sq - d2 * d2); -} \ No newline at end of file +} + + diff --git a/src/grids/mapshaper-hex-grid.mjs b/src/grids/mapshaper-hex-grid.mjs index 5fd3b41e..969d24fe 100644 --- a/src/grids/mapshaper-hex-grid.mjs +++ b/src/grids/mapshaper-hex-grid.mjs @@ -8,6 +8,24 @@ import { orient2D } from '../geom/mapshaper-segment-geom'; // Currently the origin cell is always an "outie" (protruding); in the future // "innie" origin cells may be supported +export function getHexGridParams(bbox, interval, opts) { + var params = {}; + params.flatTop = opts.type != 'hex2'; // hex2 is "pointy-top" orientation + // origin cell (bottom left) may be "outie" or "innie" ... could be settable + params.outieOrigin = true; + + // get origin and counts for centered grid + // params.u0 = _getUOrigin(); + // params.v0 = _getVOrigin(); + // params.colCounts = _getColCounts(bbox, interval); + // params.rowCounts = _getRowCounts(bbox, interval); + + if (opts.aligned) { + + } +} + + // interval: side length in projected coordinates // bbox: bounding box of area to be enclosed by grid // @@ -23,6 +41,8 @@ export function getHexGridMaker(bbox, interval, opts) { var _uOrigin = _getUOrigin(); var _vOrigin = _getVOrigin(); + var params = getHexGridParams(bbox, interval, opts); + function cells() { return _rowCounts[0] * _colCounts[0] + _rowCounts[1] * _colCounts[1]; }