Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geometry validation error on Item spec #1164

Open
g-demarco opened this issue Dec 23, 2021 · 8 comments
Open

Geometry validation error on Item spec #1164

g-demarco opened this issue Dec 23, 2021 · 8 comments
Assignees
Labels
bug minor a relatively small change to the spec
Milestone

Comments

@g-demarco
Copy link

Hi,
I'm getting an error using the item schema (https://github.com/radiantearth/stac-spec/blob/master/item-spec/json-schema/item.json)
I'm trying to create an item with a geometry equal to null, but with a populated bbox.
Looking at the definition it should work, but i'm getting back this error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/jsonschema/validators.py", line 353, in validate
    raise error
ValidationError: {u'assets': {}, u'links': [], u'geometry': None, u'properties': {u'datetime': u'+00:00'}, u'stac_version': u'1.0.0', u'bbox': [1, 1, 1, 1], u'type': u'Feature', u'id': u'q12e'} is not valid under any of the given schemas

Failed validating u'oneOf' in schema[u'allOf'][0][u'allOf'][1]:
{
   "u""oneOf":[
      {
         "u""properties":{
            "u""bbox":{
               "u""items":{
                  "u""type":"u""number"
               },
               "u""oneOf":[
                  {
                     "u""maxItems":4,
                     "u""minItems":4
                  },
                  {
                     "u""maxItems":6,
                     "u""minItems":6
                  }
               ],
               "u""type":"u""array"
            },
            "u""geometry":{
               "u""$ref":"u""https://geojson.org/schema/Geometry.json"
            }
         },
         "u""required":[
            "u""geometry",
            "u""bbox"
         ],
         "u""type":"u""object"
      },
      {
         "u""properties":{
            "u""bbox":{
               "u""not":{
                  
               }
            },
            "u""geometry":{
               "u""type":"u""null"
            }
         },
         "u""required":[
            "u""geometry"
         ],
         "u""type":"u""object"
      }
   ]
}
On instance:
    {
           u'assets': {},
           u'bbox': [1, 1, 1, 1],
           u'geometry': None,
           u'id': u'q12e',
           u'links': [],
           u'properties': {u'datetime': u'+00:00'},
           u'stac_version': u'1.0.0',
           u'type': u'Feature'
}

I'm using a Draft7 compliant validator (https://github.com/Julian/jsonschema)

Any hint for how to address this problem?

@emmanuelmathot
Copy link
Collaborator

Indeed, the spec says

bbox REQUIRED if geometry is not null

but it is missing a constraint that it should not be specified if geometry is null.
IMO, an item with a bbox has necessarily a geometry that is at least the polygon represented by the bbox.

@m-mohr
Copy link
Collaborator

m-mohr commented Jan 3, 2022

Yep, I agree. I believe the intention was that if you have a bbox, you must also provide a geometry with at least the extent of the bounding box. The JSON Schema seems to already follow this, but we'll likely need to clarify this in the written spec. Or do people prefer to fix the JSON Schema? @cholmes

Anyway, to "solve" the issue in 1.0.0, you'd need to provide a geometry that is equivalent to the bbox.

@m-mohr m-mohr added this to the 1.0.1 milestone Jan 3, 2022
@g-demarco
Copy link
Author

Yes @m-mohr, the problem was found "explorating" the schema, it is clear that with a full geometry everything works fine.
The problem should be just the mismatch between the schema and the specification.

Also, the clause:

"bbox": { 
    "not": {}
}

doesn't really seem to be working, but I don't know if it is a problem with the validator or something else.

@m-mohr m-mohr added the minor a relatively small change to the spec label May 2, 2023
@m-mohr m-mohr modified the milestones: 1.0.1, 1.1 May 2, 2023
@m-mohr
Copy link
Collaborator

m-mohr commented Sep 26, 2023

@matthewhanson To do the Markdown PR, @m-mohr to do the JSON Schema.

If there is a bbox you must have a geometry. We couldn't find a use case for having a bbox and not a geometry as you could always provide the bbox also as geometry. If you have use cases, please let us know.

@TomAugspurger
Copy link

The JSON Schema seems to already follow this, but we'll likely need to clarify this in the written spec. Or do people prefer to fix the JSON Schema?

I agree that updating the written spec to state that bbox should be non-null if and only if geometry is non-null (otherwise, just set the geometry to the bbox).

It seems to be like the JSON schema is already enforcing this.

@jsignell
Copy link

It seems like the written spec is correct on the dev branch:
image
https://github.com/radiantearth/stac-spec/blob/dev/item-spec/item-spec.md

@TomAugspurger
Copy link

Good catch, thanks!

@m-mohr
Copy link
Collaborator

m-mohr commented Apr 22, 2024

So we can close this? :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug minor a relatively small change to the spec
Projects
None yet
Development

No branches or pull requests

6 participants