Coverage for gws-app/gws/lib/gml/__init__.py: 100%
2 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""GML geometry support.
3Reads GML geometry elements into ``gws.Shape`` objects and ``gws.Bounds``, and writes
4shapes as GML elements. Both GML 2 and GML 3 are supported. Only 2D coordinates are handled.
6Submodules:
8- ``parser``: parses ``gml:Box``/``gml:Envelope`` into bounds and geometry elements
9 (``Point``, ``LineString``, ``Polygon``, ``Curve``, ``Multi*`` and so on) into shapes
10 or GeoJSON-like geometry dicts.
11- ``writer``: converts a shape to a GML 2 or GML 3 geometry element.
13Both work on ``gws.XmlElement`` objects from ``gws.lib.xmlx``. The parser converts
14GML to a GeoJSON-like dict first and creates the shape with ``gws.lib.shape.from_geojson``.
15The CRS is taken from the ``srsName`` attribute of the element, or from a default CRS
16passed by the caller. The axis order follows the CRS, unless ``always_xy`` is set.
18Reference:
19 - https://www.ogc.org/standards/gml
21Example::
23 el = gws.lib.xmlx.from_string('<Point srsName="EPSG:3857"><pos>1 2</pos></Point>')
24 shape = gws.lib.gml.parse_shape(el)
25 el = gws.lib.gml.shape_to_element(shape, version=2)
26"""
28from .parser import parse_envelope, parse_shape, parse_geometry, is_geometry_element
29from .writer import shape_to_element