# bbox

return type | Array ( GeoJSON bounding box )
syntax | $.geo.bbox( Object shape ( GeoJSON object ) )

usage

    var bbox = $.geo.bbox( {
      type: "LineString", coordinates: [
        [ -71, 40 ], [ -70.5, 41 ]
      ]
    } )

The bbox method calculates the smallest box that will contain all the positions in the passed-in shape. The shape can be any GeoJSON geometry object from Point to GeometryCollection.

The GeoJSON spec allows for each geometry type to have a bbox property. The $.geo.bbox method will honor that property and assume it is accurate. It will return the value of that property before attempting to calculate the bbox itself. If you wish to force $.geo.bbox to calculate the bbox, you will have to manually delete the bbox property from the geometry object.

    var shape = {
      type: "LineString", coordinates: [
        [ -71, 40 ], [ -70.5, 41 ]
      ],
      bbox: [ -71, 40, -70.5, 41 ]
    };
    var bboxFromProperty = $.geo.bbox(shape);
    delete shape.bbox;
    var calculatedBbox = $.geo.bbox(shape);

If the argument is not a basic GeoJSON geometry object, this function returns undefined.

This function is similar to Geometry.getEnvelope in JTS.