function createGrid(interval, mapProjection, gridProjection, extent, projectionExtent, center, squaredTolerance, maxLines, withLabels, xFormatter, yFormatter, xLabelPosition, yLabelPosition, frameSize, labelOptions = {}) {
    if (interval === -1) {
        return {
            xLines: [],
            yLines: [],
            xLabels: [],
            yLabels: [],
            frame: null
        };
    }
    const mapToGrid = proj4(mapProjection, gridProjection).forward;
    const [gridCenterX, gridCenterY] = mapToGrid(center);

    const [minX, minY, maxX, maxY] = reprojectBbox([
        Math.max(extent[0], projectionExtent[0]),
        Math.max(extent[1], projectionExtent[1]),
        Math.min(extent[2], projectionExtent[2]),
        Math.min(extent[3], projectionExtent[3])
    ], mapProjection, gridProjection || 'EPSG:4326');

    const [projMinX, projMinY, projMaxX, projMaxY] = reprojectBbox(
        projectionExtent,
        mapProjection,
        gridProjection || 'EPSG:4326'
    );

    const centerX = clamp(
        Math.floor(gridCenterX / interval) * interval,
        projMinX,
        projMaxX
    );
    const leftPoints = orderBy(linePoints(centerX, -interval, projMinX, centerX));
    const rightPoints = orderBy(linePoints(centerX, interval, centerX, projMaxX));

    const centerY = clamp(
        Math.floor(gridCenterY / interval) * interval,
        projMinY,
        projMaxY
    );
    const downPoints = orderBy(linePoints(centerY, -interval, projMinY, centerY));
    const upPoints = orderBy(linePoints(centerY, interval, centerY, projMaxY));

    const xLines = limitTo([...leftPoints, centerX, ...rightPoints]
        .map(p => getXLine(p, minY, maxY, squaredTolerance, gridProjection || "EPSG:4326", mapProjection))
        .filter(l => intersects(l, extent)), maxLines);
    const yLines = limitTo([...downPoints, centerY, ...upPoints]
        .map(p => getYLine(p, minX, maxX, squaredTolerance, gridProjection || "EPSG:4326", mapProjection))
        .filter(l => intersects(l, extent)), maxLines);

    const frame = frameSize ? getFrame(extent, frameSize) : null;

    return {
        xLines: xLines,
        yLines: yLines,
        xLabels: withLabels ? getXLabels(xLines, extent, xFormatter, xLabelPosition, labelOptions) : [],
        yLabels: withLabels ? getYLabels(yLines, extent, yFormatter, yLabelPosition, labelOptions) : [],
        frame
    };

}
/**
 * Returns an object representing a grid for the given parameters.
 * You can specify different projections for the map and the grid, for example
 * to have a lon-lat grid (EPSG:4326) on a mercator map (EPSG:3857). When projections
 * are different, grid lines may be curved, when reprojected for the map. In this case,
 * those lines need to be densified before being reprojected to the map projection.
 * The squaredTolerance parameter can be used to set the trade-off of the densification process,
 * between speed and precision.
 *
 * @param {number} interval interval (in grid projection units) between the grid lines.
 * @param {string} mapProjection projection used for the map
 * @param {string} gridProjection projection used for the grid
 * @param {number[]} extent map extent as [minX, minY, maxX, maxY]
 * @param {number[]} center projection center point in grid coordinates as [x, y].
 * @param {number} squaredTolerance tolerance used to densify points of curved lines
 * @param {number} maxLines used to limited the max nuber of grid lines generated (defaults to 100).
 * @param {boolean} withLabels if true labels for each grid line is added to the result object.
 * @param {boolean} xFormatter formatter function for labels on the x lines.
 * @param {boolean} yFormatter formatter function for labels on the y lines.
 * @param {number} xLabelPosition x labels offset.
 * @param {number} yLabelPosition y labels offset.
 * @param {number} frameSize if not zero, a frame is drawn around the map, with the given size as a ratio on the map extent.
 * @param {object} labelOptions options that can be used by the label formatter (center, zoom, etc.)
 * @return {object} An object with the XLines, yLines, xLabels, yLabels properties, representing arrays of
 * geometries for the related object.
 */
Returns an object representing a grid for the given parameters.
You can specify different projections for the map and the grid, for example
to have a lon-lat grid (EPSG:4326) on a mercator map (EPSG:3857). When projections
are different, grid lines may be curved, when reprojected for the map. In this case,
those lines need to be densified before being reprojected to the map projection.
The squaredTolerance parameter can be used to set the trade-off of the densification process,
between speed and precision.

@param {number} interval interval (in grid projection units) between the grid lines.
@param {string} mapProjection projection used for the map
@param {string} gridProjection projection used for the grid
@param {number[]} extent map extent as [minX, minY, maxX, maxY]
@param {number[]} center projection center point in grid coordinates as [x, y].
@param {number} squaredTolerance tolerance used to densify points of curved lines
@param {number} maxLines used to limited the max nuber of grid lines generated (defaults to 100).
@param {boolean} withLabels if true labels for each grid line is added to the result object.
@param {boolean} xFormatter formatter function for labels on the x lines.
@param {boolean} yFormatter formatter function for labels on the y lines.
@param {number} xLabelPosition x labels offset.
@param {number} yLabelPosition y labels offset.
@param {number} frameSize if not zero, a frame is drawn around the map, with the given size as a ratio on the map extent.
@param {object} labelOptions options that can be used by the label formatter (center, zoom, etc.)
@return {object} An object with the XLines, yLines, xLabels, yLabels properties, representing arrays of
geometries for the related object.
Returns an object representing a grid for the given parameters . You can specify different projections for the map and the grid for example to have a lon - lat grid ( EPSG : 4326 ) on a mercator map ( EPSG : 3857 ) . When projections are different grid lines may be curved when reprojected for the map . In this case those lines need to be densified before being reprojected to the map projection . The squaredTolerance parameter can be used to set the trade - off of the densification process between speed and precision . @param { number } interval interval ( in grid projection units ) between the grid lines . @param { string } mapProjection projection used for the map @param { string } gridProjection projection used for the grid @param { number [] } extent map extent as [ minX minY maxX maxY ] @param { number [] } center projection center point in grid coordinates as [ x y ] . @param { number } squaredTolerance tolerance used to densify points of curved lines @param { number } maxLines used to limited the max nuber of grid lines generated ( defaults to 100 ) . @param { boolean } withLabels if true labels for each grid line is added to the result object . @param { boolean } xFormatter formatter function for labels on the x lines . @param { boolean } yFormatter formatter function for labels on the y lines . @param { number } xLabelPosition x labels offset . @param { number } yLabelPosition y labels offset . @param { number } frameSize if not zero a frame is drawn around the map with the given size as a ratio on the map extent . @param { object } labelOptions options that can be used by the label formatter ( center zoom etc . ) @return { object } An object with the XLines yLines xLabels yLabels properties representing arrays of geometries for the related object .
function createGrid(interval, mapProjection, gridProjection, extent, projectionExtent, center, squaredTolerance, maxLines, withLabels, xFormatter, yFormatter, xLabelPosition, yLabelPosition, frameSize, labelOptions = {}) {
    if (interval === -1) {
        return {
            xLines: [],
            yLines: [],
            xLabels: [],
            yLabels: [],
            frame: null
        };
    }
    const mapToGrid = proj4(mapProjection, gridProjection).forward;
    const [gridCenterX, gridCenterY] = mapToGrid(center);
    const [minX, minY, maxX, maxY] = reprojectBbox([
        Math.max(extent[0], projectionExtent[0]),
        Math.max(extent[1], projectionExtent[1]),
        Math.min(extent[2], projectionExtent[2]),
        Math.min(extent[3], projectionExtent[3])
    ], mapProjection, gridProjection || 'EPSG:4326');
    const [projMinX, projMinY, projMaxX, projMaxY] = reprojectBbox(
        projectionExtent,
        mapProjection,
        gridProjection || 'EPSG:4326'
    );
    const centerX = clamp(
        Math.floor(gridCenterX / interval) * interval,
        projMinX,
        projMaxX
    );
    const leftPoints = orderBy(linePoints(centerX, -interval, projMinX, centerX));
    const rightPoints = orderBy(linePoints(centerX, interval, centerX, projMaxX));
    const centerY = clamp(
        Math.floor(gridCenterY / interval) * interval,
        projMinY,
        projMaxY
    );
    const downPoints = orderBy(linePoints(centerY, -interval, projMinY, centerY));
    const upPoints = orderBy(linePoints(centerY, interval, centerY, projMaxY));
    const xLines = limitTo([...leftPoints, centerX, ...rightPoints]
        .map(p => getXLine(p, minY, maxY, squaredTolerance, gridProjection || "EPSG:4326", mapProjection))
        .filter(l => intersects(l, extent)), maxLines);
    const yLines = limitTo([...downPoints, centerY, ...upPoints]
        .map(p => getYLine(p, minX, maxX, squaredTolerance, gridProjection || "EPSG:4326", mapProjection))
        .filter(l => intersects(l, extent)), maxLines);
    const frame = frameSize ? getFrame(extent, frameSize) : null;
    return {
        xLines: xLines,
        yLines: yLines,
        xLabels: withLabels ? getXLabels(xLines, extent, xFormatter, xLabelPosition, labelOptions) : [],
        yLabels: withLabels ? getYLabels(yLines, extent, yFormatter, yLabelPosition, labelOptions) : [],
        frame
    };
}
function createGrid ( interval , mapProjection , gridProjection , extent , projectionExtent , center , squaredTolerance , maxLines , withLabels , xFormatter , yFormatter , xLabelPosition , yLabelPosition , frameSize , labelOptions = { } ) { if ( interval === - 1 ) { return { xLines : [ ] , yLines : [ ] , xLabels : [ ] , yLabels : [ ] , frame : null } ; } const mapToGrid = proj4 ( mapProjection , gridProjection ) . forward ; const [ gridCenterX , gridCenterY ] = mapToGrid ( center ) ; const [ minX , minY , maxX , maxY ] = reprojectBbox ( [ Math . max ( extent [ 0 ] , projectionExtent [ 0 ] ) , Math . max ( extent [ 1 ] , projectionExtent [ 1 ] ) , Math . min ( extent [ 2 ] , projectionExtent [ 2 ] ) , Math . min ( extent [ 3 ] , projectionExtent [ 3 ] ) ] , mapProjection , gridProjection || 'EPSG:4326' ) ; const [ projMinX , projMinY , projMaxX , projMaxY ] = reprojectBbox ( projectionExtent , mapProjection , gridProjection || 'EPSG:4326' ) ; const centerX = clamp ( Math . floor ( gridCenterX / interval ) * interval , projMinX , projMaxX ) ; const leftPoints = orderBy ( linePoints ( centerX , - interval , projMinX , centerX ) ) ; const rightPoints = orderBy ( linePoints ( centerX , interval , centerX , projMaxX ) ) ; const centerY = clamp ( Math . floor ( gridCenterY / interval ) * interval , projMinY , projMaxY ) ; const downPoints = orderBy ( linePoints ( centerY , - interval , projMinY , centerY ) ) ; const upPoints = orderBy ( linePoints ( centerY , interval , centerY , projMaxY ) ) ; const xLines = limitTo ( [ ... leftPoints , centerX , ... rightPoints ] . map ( p => getXLine ( p , minY , maxY , squaredTolerance , gridProjection || "EPSG:4326" , mapProjection ) ) . filter ( l => intersects ( l , extent ) ) , maxLines ) ; const yLines = limitTo ( [ ... downPoints , centerY , ... upPoints ] . map ( p => getYLine ( p , minX , maxX , squaredTolerance , gridProjection || "EPSG:4326" , mapProjection ) ) . filter ( l => intersects ( l , extent ) ) , maxLines ) ; const frame = frameSize ? getFrame ( extent , frameSize ) : null ; return { xLines : xLines , yLines : yLines , xLabels : withLabels ? getXLabels ( xLines , extent , xFormatter , xLabelPosition , labelOptions ) : [ ] , yLabels : withLabels ? getYLabels ( yLines , extent , yFormatter , yLabelPosition , labelOptions ) : [ ] , frame } ; }
Returns an object representing a grid for the given parameters.
Returns an object representing a grid for the given parameters .