module documentation

SVG builders.

Function shape_to_fragment Convert a shape to a list of XmlElements (a "fragment").
Function soup_to_fragment Convert an svg "soup" to a list of XmlElements (a "fragment").
Constant DEFAULT_FONT_SIZE Undocumented
Constant DEFAULT_MARKER_SIZE Undocumented
Constant DEFAULT_POINT_SIZE Undocumented
Function _add_font_atts Undocumented
Function _add_paint_atts Undocumented
Function _enum_points Undocumented
Function _font_name Undocumented
Function _geom_type Undocumented
Function _geometry Undocumented
Function _icon_size_and_position Undocumented
Function _is_label_visible Undocumented
Function _label Undocumented
Function _label_position Undocumented
Function _label_text Undocumented
Function _marker Undocumented
Function _parse_icon Undocumented
Function _slope Undocumented
Constant _DEFAULT_FONT Undocumented
Constant _TYPE_GEOMETRYCOLLECTION Undocumented
Constant _TYPE_LINEARRING Undocumented
Constant _TYPE_LINESTRING Undocumented
Constant _TYPE_MULTILINESTRING Undocumented
Constant _TYPE_MULTIPOINT Undocumented
Constant _TYPE_MULTIPOLYGON Undocumented
Constant _TYPE_POINT Undocumented
Constant _TYPE_POLYGON Undocumented
def shape_to_fragment(shape: gws.IShape, view: gws.MapView, label: str = None, style: gws.IStyle = None) -> list[gws.IXmlElement]: (source)

Convert a shape to a list of XmlElements (a "fragment").

def soup_to_fragment(view: gws.MapView, points: list[gws.Point], tags: list[t.Any]) -> list[gws.IXmlElement]: (source)

Convert an svg "soup" to a list of XmlElements (a "fragment").

A soup has two components:

  • a list of points, in the map coordinate system
  • a list of tuples suitable for xmlx.tag input (tag-name, {atts}, child1, child2....)

The idea is to represent client-side svg drawings (e.g. dimensions) in a resolution-independent way

First, points are converted to pixels using the view's transform. Then, each tag's attributes are iterated. If any attribute value is an array, it's assumed to be a 'function'. The first element is a function name, the rest are arguments. Attribute 'functions' are

  • ['x', n] - returns points[n][0]
  • ['y', n] - returns points[n][1]
  • ['r', p1, p2, r] - computes a slope between points[p1] points[p2] and returns a string
    rotate(slope, points[r].x, points[r].y)
DEFAULT_FONT_SIZE: int = (source)

Undocumented

Value
10
DEFAULT_MARKER_SIZE: int = (source)

Undocumented

Value
10
DEFAULT_POINT_SIZE: int = (source)

Undocumented

Value
10
def _add_font_atts(atts, sv, prefix=''): (source)

Undocumented

def _add_paint_atts(atts, sv, prefix=''): (source)

Undocumented

def _enum_points(geom): (source)

Undocumented

def _font_name(sv, prefix=''): (source)

Undocumented

def _geom_type(geom): (source)

Undocumented

def _geometry(geom: shapely.geometry.base.BaseGeometry, atts: dict = None) -> gws.IXmlElement: (source)

Undocumented

def _icon_size_and_position(geom, sv, width, height) -> tuple[int, int, int, int]: (source)

Undocumented

def _is_label_visible(view: gws.MapView, sv: gws.StyleValues) -> bool: (source)

Undocumented

def _label(geom, label: str, sv: gws.StyleValues, extra_y_offset=0) -> gws.IXmlElement: (source)

Undocumented

def _label_position(geom, sv: gws.StyleValues, extra_y_offset=0) -> gws.Point: (source)

Undocumented

def _label_text(cx, cy, label, sv: gws.StyleValues) -> gws.IXmlElement: (source)

Undocumented

Undocumented

def _parse_icon(icon, dpi) -> t.Optional[tuple[gws.IXmlElement, float, float]]: (source)

Undocumented

def _slope(a: gws.Point, b: gws.Point) -> float: (source)

Undocumented

_DEFAULT_FONT: str = (source)

Undocumented

Value
'DejaVuSans'
_TYPE_GEOMETRYCOLLECTION: int = (source)

Undocumented

Value
7
_TYPE_LINEARRING: int = (source)

Undocumented

Value
2
_TYPE_LINESTRING: int = (source)

Undocumented

Value
1
_TYPE_MULTILINESTRING: int = (source)

Undocumented

Value
5
_TYPE_MULTIPOINT: int = (source)

Undocumented

Value
4
_TYPE_MULTIPOLYGON: int = (source)

Undocumented

Value
6
_TYPE_POINT: int = (source)

Undocumented

Value
0
_TYPE_POLYGON: int = (source)

Undocumented

Value
3