I'm generating some GeoJSON documents and I was unsure how to properly add a bbox to a geometry.
Do I need to necessarily create a Feature object to add the bbox (example 1) or can I do this in the geometry itself (example 2)?
The GeoSON specification (https://www.rfc-editor.org/rfc/rfc7946#appendix-A) presents examples only with the bbox in a GeoJSON object of type Feature, however, validators accept the two modes of inserting the bbox.
Example 1: In this example, the bbox is an element of the GeoJSON object of type Feature.
{
"type": "Feature",
"properties": {"id": 1, "Linha": null},
"bbox": [-48.573569106948469, -27.837770518544438, -48.417446881093412, -27.381161181879751],
"geometry": {
"type": "LineString",
"coordinates": [
[-48.417446881093412, -27.381161181879751],
[-48.573569106948469, -27.837770518544438]
]
}
}
Example 2: In this other example, the bbox was included directly in the GeoJSON object with the geometry (LineString).
{
"type": "LineString",
"bbox": [-48.573569106948469, -27.837770518544438, -48.417446881093412, -27.381161181879751],
"coordinates": [
[-48.417446881093412, -27.381161181879751],
[-48.573569106948469, -27.837770518544438]
]
}