Toloka documentation

DistanceConditionV1

toloka.client.project.template_builder.conditions.DistanceConditionV1 | Source code

DistanceConditionV1(
    self,
    from_: Optional[Union[BaseComponent, str]] = None,
    to_: Optional[Union[BaseComponent, str]] = None,
    max: Optional[Union[BaseComponent, float]] = None,
    *,
    hint: Optional[Any] = None,
    version: Optional[str] = '1.0.0'
)

This component checks whether the sent coordinates match the ones that you specified

For example, you want the user to take a photo of a specific place. The condition.distance component checks whether the photo was taken at the location that you specified.

Parameters Description

Parameters Type Description
from_ Optional[Union[BaseComponent, str]]

First point.

to_ Optional[Union[BaseComponent, str]]

Second point.

max Optional[Union[BaseComponent, float]]

The distance in meters by which the X and Y coordinates may differ.

hint Optional[Any]

Validation error message that the user will see.

Examples:

How to check that performer is in the right place.

distance_condition = tb.conditions.DistanceConditionV1(
    tb.data.LocationData(),
    tb.data.InputData('coordinates'),
    500,
    hint='You are too far from the destination coordinates.',
),