def svg_line(shp, scale_factor, stroke):
    """Returns SVG polyline element for the LineString geometry.
    Parameters
    ==========
    scale_factor : float
        Multiplication factor for the SVG stroke-width.  Default is 1.
    stroke_color : str, optional
        Hex string for stroke color. Default is to use "#66cc99" if
        geometry is valid, and "#ff3333" if invalid.
    """
    if shp.is_empty:
        return '<g />'

    stroke = stroke if shp.is_valid else "#ff3333"
    pnt_format = " ".join(["%0.4f,%0.4f" % c for c in shp.coords])
    return ('<polyline fill="none" stroke="{2}" stroke-width="{1}" '
            'points="{0}" opacity="0.8" />') \
        .format(pnt_format, 2. * scale_factor, stroke)