Skip to content

LineString

Bases: Spatial

Represents a line.

Follows the GeoJSON specification (RFC 7946).

Parameters:

Name Type Description Default
value List[Tuple[float, float]]

A linestring.

required

Methods:

Name Description
colorspace

Represent the photo in the given colorspace.

gamma

Change the photo's gamma exposure.

Examples:

Create a line.

>>> LineString([(0,0), (0,1), (1,1)])
Source code in valor/schemas/symbolic/types.py
class LineString(Spatial):
    """
    Represents a line.

    Follows the GeoJSON specification (RFC 7946).

    Parameters
    ----------
    value : List[Tuple[float, float]], optional
        A linestring.

    Methods
    -------
    colorspace(c='rgb')
        Represent the photo in the given colorspace.
    gamma(n=1.0)
        Change the photo's gamma exposure.

    Examples
    --------
    Create a line.
    >>> LineString([(0,0), (0,1), (1,1)])
    """

    def __init__(self, value: typing.List[typing.Tuple[float, float]]):
        super().__init__(value=value)

    @classmethod
    def __validate__(cls, value: typing.Any):
        MultiPoint.__validate__(value)
        if len(value) < 2:
            raise ValueError(
                "At least two points are required to make a line."
            )

    @classmethod
    def decode_value(
        cls, value: typing.Optional[typing.List[typing.List[float]]]
    ):
        """Decode object from JSON compatible dictionary."""
        if value is None:
            return None
        return cls([(point[0], point[1]) for point in value])

Functions

valor.schemas.LineString.decode_value(value) classmethod

Decode object from JSON compatible dictionary.

Source code in valor/schemas/symbolic/types.py
@classmethod
def decode_value(
    cls, value: typing.Optional[typing.List[typing.List[float]]]
):
    """Decode object from JSON compatible dictionary."""
    if value is None:
        return None
    return cls([(point[0], point[1]) for point in value])