gisserver.projection module¶
In WFS, a “projection” is placed on top of the queried data.
It translates the incoming data into the subset of properties to display. Practically, this code does inform and adjust the constructed QuerySet to make sure it will provide only the actual fields that are part of the projection.
- class gisserver.projection.FeatureProjection(feature_types: list[FeatureType], property_names: list[wfs20.PropertyName] | None = None, value_reference: fes20.ValueReference | None = None, output_crs: CRS | None = None, output_standalone: bool = False)¶
Tell which fields to access and render for a single feature. This is inspired on ‘fes:AbstractProjectionClause’.
Instead of walking over the full XSD object tree, this object wraps that and makes sure only the actual requested fields are used. When a
PROPERTYNAME(or<wfs:PropertyName>) is used in the request, this will limit which fields to retrieve, which to prefetch, and which to render.- __init__(feature_types: list[FeatureType], property_names: list[wfs20.PropertyName] | None = None, value_reference: fes20.ValueReference | None = None, output_crs: CRS | None = None, output_standalone: bool = False)¶
- Parameters:
feature_types – The feature types used by this query. Typically one, unless there is a JOIN.
property_names – Limited list of fields to render only.
value_reference – Single element to display fo GetPropertyValue
output_crs – Which coordinate reference system to use for geometry data.
output_standalone – Used for the
GetFeatureByIdstored query. This removes thewfs:FeatureCollection><wfs:member>wrapper elements from the output.
- add_field(xsd_element: XsdElement)¶
Restore the retrieval of a field that was not asked for in the original query.
- property all_complex_elements: list[_XsdElement_WithComplexType]¶
Return ALL tree elements with a complex type, including child elements with a complex types.
- property all_elements: list[XsdElement]¶
Return ALL elements of all levels to render.
- property all_flattened_elements: list[XsdElement]¶
Shortcut to get ALL tree elements with a flattened model attribute
- property all_geometry_elements: list[GeometryXsdElement]¶
Tell which GML elements will be hit.
- feature_type: FeatureType¶
Referencing the Feature that is rendered.
- property geometry_elements: list[GeometryXsdElement]¶
Tell which GML elements will be hit at the root-level.
- get_main_geometry_value(instance: models.Model) GEOSGeometry | None¶
Efficiently retrieve the value for the main geometry element.
- property main_geometry_element: GeometryXsdElement | None¶
Return the field used to describe the geometry of the feature. When the projection excludes the geometry,
Noneis returned.
- property only_fields: list[str]¶
Tell which fields to limit the queryset to. This excludes M2M fields because those are not part of the local model data.
- property orm_relations: list[FeatureRelation]¶
Tell which fields will be retrieved from related fields.
This gives an object layout based on the XSD elements, that can be used for prefetching data.
- output_standalone: bool¶
Whether the output should be rendered without wrapper tags (for GetFeatureById).
- remove_fields(predicate: Callable[[XsdElement], bool])¶
Remove elements from the projection based on a given rule. This helps to remove M2M and Array elements for CSV output for example.
Make sure this function is called as early as possible, before other logic already read these attributes.
- property xpath_matches: list[XPathMatch]¶
Resolve which elements the property names point to
- xsd_child_nodes: dict[XsdElement | None, list[XsdElement]]¶
The subset of child nodes to render for a given element.
- xsd_root_elements: list[XsdElement]¶
The list of root element to render for this feature.
- class gisserver.projection.FeatureRelation(orm_path: str, sub_fields: set[XsdElement], related_model: type[models.Model] | None, xsd_elements: list[XsdElement])¶
Tell which related fields are queried by the feature.
- __init__(orm_path: str, sub_fields: set[XsdElement], related_model: type[models.Model] | None, xsd_elements: list[XsdElement]) None¶
- property geometry_elements: list[GeometryXsdElement]¶
Tell which geometry elements this relation will access.
The model that is accessed for this relation (if set)
- sub_fields: set[XsdElement]¶
The fields that will be retrieved for that path (limited by the projection)
- xsd_elements: list[XsdElement]¶
The source elements that access this relation. Could be multiple for flattened relations.