gws.base.exporter.util¶
Helpers for exporters.
Source code: gws.base.exporter.util
Module Contents¶
- class gws.base.exporter.util.Group(*args, **kwargs)¶
Bases:
gws.DataExport-ready features of one model.
- columns: dict[str, gws.AttributeType]¶
Exported columns and their types.
- geomType: gws.GeometryType | None¶
Geometry type, taken from the first feature with a shape.
- records: list[gws.FeatureRecord]¶
Records with the exported attributes and the shape.
- gws.base.exporter.util.group_features(ea: gws.ExportArgs, er: gws.ExportResult) list[Group]¶
Group features by model and determine the export columns and geometry type.
Columns are the model fields with an attribute type supported by the exporter (or by GDAL, if the exporter does not restrict the types). Features that do not fit their group are skipped and reported in
er.errors, seegws.base.exporter.- Parameters:
ea – Export arguments.
er – Export result, used to report errors.
- Returns:
A list of groups, one per model that has exportable features.
- gws.base.exporter.util.run_gdal_vector_export(driver_name: str, mime_type: str, ea: gws.ExportArgs, er: gws.ExportResult)¶
Export features with a GDAL vector driver.
Writes one file per group, or a single file with one layer per group if the exporter has
withMultiLayer. Several files are zipped. Sets the path, mime type and counts in the export result. Does nothing if there are no features to export.- Parameters:
driver_name – GDAL driver name, e.g.
GeoJSON.mime_type – Mime type of the result file.
ea – Export arguments.
er – Export result, filled by this function.
- Raises:
gws.Error – If the driver is not supported.