def in_shape()

in src/mapillary/utils/filter.py [0:0]


def in_shape(data: list, boundary) -> list:
    """
    Whether the given feature list lies within the shape

    :param data: A feature list to be filtered
    :type data: list

    :param boundary: Shapely helper for determining existence of point within a boundary
    :type boundary:

    :return: A feature list
    :rtype: list
    """

    # Generating output format
    output = []

    # Iterating over features
    for feature in data:

        # Extracting point from geometry feature
        point = shape(feature["geometry"])

        # Checking if point falls within the boundary using shapely.geometry.point.point
        if boundary.contains(point):
            # If true, append to output features
            output.append(feature)

    # Return output
    return output