Fix schema mapping if driver includes default fields #918
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
Some drivers create fields by default. Fiona is currently not aware of these fields. Additionally, some drivers modify the field names (e.g. Shapefile has a length restriction for field names). Fiona maintains a schema mapping between field names in the schema provided to Fiona, and the resulting field names. However, as the default fields are not considered, the resulting mapping is wrong (see #916).
This PR fixes the schema mapping if a driver contains default fields. This is kind of a minimal solution, as the existence of default fields also influence the schema validation, which is not touched with this PR. This PR does not modify that only the fields in the schema provided to Fiona are validated.
Currently, schema validation requires that records include all fields of the schema. However, drivers include also "optional" default fields, that do not need to be present. E.g. the default fields for the GPX driver are:
E.g. the
geoidheight
element is defined withminOccurs="0"
in https://www.topografix.com/GPX/1/1/gpx.xsd