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

[Proposal] Support format per respective type: File #52

Open
fmigneault opened this issue Aug 22, 2024 · 1 comment
Open

[Proposal] Support format per respective type: File #52

fmigneault opened this issue Aug 22, 2024 · 1 comment

Comments

@fmigneault
Copy link
Contributor

At the moment, it is possible to do the following:

inputs:
  features:
    type:
      - "File"
      - type: array
        items: "File"
    format:
      - "ogc:FeatureCollection"
      - "iana:application/geo+json"
$namespaces:
  iana: "https://www.iana.org/assignments/media-types/"
  ogc: "http://www.opengis.net/def/glossary/term/"

However, it is NOT possible to do something like the following:

inputs:
  features:
    type:
      - type: "File"
        format: "ogc:FeatureCollection"
      - type: array
        items:
          type: "File"
          format: "iana:application/geo+json"
$namespaces:
  iana: "https://www.iana.org/assignments/media-types/"
  ogc: "http://www.opengis.net/def/glossary/term/"

The reasoning of the above is that the application receiving this features input can either receive a single document embedding of a "FeatureCollection" (a specific type of GeoJSON: https://geojson.org/schema/FeatureCollection.json), or an array of "single feature" GeoJSON (eg: https://geojson.org/schema/Feature.json).

The current limitation of format permitted only directly under the input makes it such that some combinations of formats are inconsistent with the desired use. In the first example, a single "Feature" GeoJSON could be submitted, or an array of "FeatureCollection" (resulting in a 2D array of features) could be submitted, both of which are invalid for the application that expect a "list of features".

Allowing to nest format under the specific type would allow to adequately narrow the structure to the valid combinations.

@fmigneault
Copy link
Contributor Author

The following seems to be an appropriate workaround, but is much harder to interpret than format fields placed at the respective locations. This is also become more error-prone when the number of combinations increases. Finally, there might be situations where the Array.isArray used below might not be sufficient to distinguish between the cases, making the code harder to maintain.

inputs:
  features:
    type:
      - "File"
      - type: array
        items: "File"
    format: |
      ${ 
        if (Array.isArray(inputs.features)) {
          return "iana:application/geo+json";
        }
        return "ogc:FeatureCollection";
      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant