gws.lib.gml.parser¶
GML geometry parsers.
Source code: gws.lib.gml.parser
Module Contents¶
- gws.lib.gml.parser.is_geometry_element(el: gws.XmlElement) bool¶
Check if an element is a supported GML geometry element.
- Parameters:
el – An XML element.
- Returns:
Trueif the element name is one of the supported geometry tags.
- gws.lib.gml.parser.parse_envelope(el: gws.XmlElement, default_crs: gws.Crs = None, always_xy: bool = False) gws.Bounds¶
Parse a
gml:Boxorgml:Envelopeelement into bounds.- Parameters:
el – A
BoxorEnvelopeelement.default_crs – CRS to use when the element has no
srsNameattribute.always_xy – If
True, coordinates are assumed to be in the XY (lon/lat) order.
- Returns:
A Bounds object.
- Raises:
Error – If no CRS is given or the element cannot be parsed.
- gws.lib.gml.parser.parse_geometry(el: gws.XmlElement) dict¶
Convert a GML geometry element to a GeoJSON-like geometry dict.
A
Curveis converted to aLineStringfrom its first segment only.MultiCurveandMultiSurfacebecomeMultiLineStringandMultiPolygon.- Parameters:
el – A GML geometry element.
- Returns:
A dict with
typeandcoordinates.- Raises:
Error – If the element cannot be parsed.
- gws.lib.gml.parser.parse_shape(el: gws.XmlElement, default_crs: gws.Crs = None, always_xy: bool = False) gws.Shape¶
Convert a GML geometry element to a Shape.
- Parameters:
el – A GML geometry element.
default_crs – CRS to use when the element has no
srsNameattribute.always_xy – If
True, coordinates are assumed to be in the XY (lon/lat) order.
- Returns:
A Shape object.
- Raises:
Error – If no CRS is given or the element cannot be parsed.