gws.lib.gml.writer

GML geometry writer.

Source code: gws.lib.gml.writer

Module Contents

gws.lib.gml.writer.DEFAULT_VERSION = 3
gws.lib.gml.writer.shape_to_element(shape: gws.Shape, version: int = DEFAULT_VERSION, coordinate_precision: int | None = None, always_xy: bool = False, with_xmlns: bool = True, with_inline_xmlns: bool = False, namespace: gws.XmlNamespace | None = None, crs_format: gws.CrsFormat | None = None) → gws.XmlElement

Convert a Shape to a GML geometry element.

In GML 3, line strings are written as Curve elements and multi line strings and multi polygons as MultiCurve and MultiSurface.

Parameters:
  • shape – A Shape object.

  • version – GML version (2 or 3).

  • coordinate_precision – Number of decimal places. The default depends on the units of the shape CRS.

  • always_xy – If True, coordinates are always written in the XY (lon/lat) order, otherwise in the axis order of the CRS.

  • with_xmlns – If True, put the elements in the GML namespace.

  • with_inline_xmlns – If True, declare the namespace on the geometry element.

  • namespace – Namespace to use (default GML_2 for version 2 and GML, that is GML 3.2, for version 3).

  • crs_format – CRS format for srsName (default url for version 2 and urn for version 3).

Returns:

A GML element.

Raises:

gws.Error – If the version or the geometry type is not supported.