Skip to content

Commit

Permalink
FIX: Switch order of bbox types (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
tnatt authored May 23, 2024
1 parent 8cac8d0 commit f748188
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 51 deletions.
100 changes: 50 additions & 50 deletions schema/definitions/0.8.0/schema/fmu_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -1279,10 +1279,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -1561,10 +1561,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -1843,10 +1843,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -2223,10 +2223,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -2524,10 +2524,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -2926,10 +2926,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -3284,10 +3284,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -3594,10 +3594,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -3888,10 +3888,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -4170,10 +4170,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -4472,10 +4472,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -4754,10 +4754,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -5084,10 +5084,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -5366,10 +5366,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -5703,10 +5703,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -5985,10 +5985,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -6355,10 +6355,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -6751,10 +6751,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -7224,10 +7224,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -7534,10 +7534,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -7816,10 +7816,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -8156,10 +8156,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -8451,10 +8451,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down Expand Up @@ -8733,10 +8733,10 @@
"bbox": {
"anyOf": [
{
"$ref": "#/$defs/BoundingBox2D"
"$ref": "#/$defs/BoundingBox3D"
},
{
"$ref": "#/$defs/BoundingBox3D"
"$ref": "#/$defs/BoundingBox2D"
},
{
"type": "null"
Expand Down
2 changes: 1 addition & 1 deletion src/fmu/dataio/datastructure/meta/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Content(BaseModel):
alias: Optional[List[str]] = Field(default=None)

# Only valid for cooridate based meta.
bbox: Optional[Union[BoundingBox2D, BoundingBox3D]] = Field(default=None)
bbox: Optional[Union[BoundingBox3D, BoundingBox2D]] = Field(default=None)

description: Optional[List[str]] = Field(
default=None,
Expand Down
14 changes: 14 additions & 0 deletions tests/test_units/test_metadata_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ def test_populate_meta_objectdata(regsurf, edataobj2):
assert mymeta["data"]["spec"] == objdata.get_spec()


def test_bbox_zmin_zmax_presence(polygons, edataobj2):
"""
Test to ensure the zmin/zmax fields are present in the metadata for a
data type (polygons) where it is expexted. This is dependent on the order
of the bbox types (2D/3D) inside the pydantic model. If 2D is first zmin/zmax
will be ignored even if present.
"""
mymeta = generate_export_metadata(polygons, edataobj2)

# polygons shall have data.spec
assert "zmin" in mymeta["data"]["bbox"]
assert "zmax" in mymeta["data"]["bbox"]


def test_populate_meta_undef_is_zero(regsurf, globalconfig2):
eobj1 = dio.ExportData(
config=globalconfig2,
Expand Down

0 comments on commit f748188

Please sign in to comment.