• JMap.Geometry.getNormalizedBbox

    Returns a normalized bbox that can be used in query string. The input bbox must be expressed in degrees and must also respect the convention of sw longitude being numerically smaller than ne longitude

    A bbox that spans more than 360 degrees will be normalized as [-180, , 180, ]

    A bbox which easting coordinates are not in the range -360<-->+360 will be translated to respect valid coordinates

    The OGC define rules for bboxes that cross the antimeridian, stating that for such a bbox, the westmost coordinate must be expressed as a positive number.

    For instance, this bbox: [-190, 42, -70, 50] would be expressed as [170, 42, -70, 50] in OGC-compliant syntax. Some services require that bboxes respect that syntax, but JS cartographic APIs and frameworks often use the non OGC-compliant format

    The ogcCompliant parameter ensures that the returned bbox will be expressed in the good form.

    Parameters

    • bbox: JBoundaryBox

      the boundary box to normalize (expressed in degrees)

    • Optional ogcCompliant: boolean

      wheter we want an OGC-compliant bbox, or not (default false)

    Returns JBoundaryBox

    Example

    let bbox = { sw: { x: -190, y: 10 }, ne: { x: -170, y: 12 } }
    // Normalize using OGC syntax
    let normalizedBbox = JMap.Geometry.getNormalizedBbox(bbox, true)
    // { sw: { x: 170, y: 10 }, ne: { x: -170, y: 12 } }

    Throws

    if the passed bbox is malformed, or invalid.