Skip to content

Commit

Permalink
Update mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
arnasbr committed Oct 26, 2023
1 parent 11eef73 commit 441282e
Showing 1 changed file with 154 additions and 152 deletions.
306 changes: 154 additions & 152 deletions traveltimepy/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@


def create_time_filter(
locations: List[Location],
search_ids: Dict[str, List[str]],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
properties: Optional[List[Property]],
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
travel_time: int,
range: Optional[FullRange],
locations: List[Location],
search_ids: Dict[str, List[str]],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
properties: Optional[List[Property]],
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
travel_time: int,
range: Optional[FullRange],
) -> TimeFilterRequest:
if properties is None:
properties = [Property.TRAVEL_TIME]
Expand Down Expand Up @@ -114,12 +114,12 @@ def create_time_filter(


def create_time_filter_fast(
locations: List[Location],
search_ids: Dict[str, List[str]],
transportation: Transportation,
travel_time: int = 3600,
properties: Optional[List[Property]] = None,
one_to_many: bool = False,
locations: List[Location],
search_ids: Dict[str, List[str]],
transportation: Transportation,
travel_time: int = 3600,
properties: Optional[List[Property]] = None,
one_to_many: bool = False,
) -> TimeFilterFastRequest:
if properties is None:
properties = [Property.TRAVEL_TIME]
Expand Down Expand Up @@ -164,21 +164,21 @@ def create_time_filter_fast(


def create_postcodes(
coordinates: List[Coordinates],
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
properties: Optional[List[Property]],
range: Optional[FullRange],
coordinates: List[Coordinates],
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
properties: Optional[List[Property]],
range: Optional[FullRange],
) -> PostcodesRequest:
if properties is None:
properties = [Property.TRAVEL_TIME]
Expand Down Expand Up @@ -223,22 +223,22 @@ def create_postcodes(


def create_districts(
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
reachable_postcodes_threshold,
properties: Optional[List[ZonesProperty]],
range: Optional[FullRange],
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
reachable_postcodes_threshold,
properties: Optional[List[ZonesProperty]],
range: Optional[FullRange],
) -> PostcodesDistrictsRequest:
if properties is None:
properties = [ZonesProperty.TRAVEL_TIME_ALL]
Expand Down Expand Up @@ -285,22 +285,22 @@ def create_districts(


def create_sectors(
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
reachable_postcodes_threshold,
properties: Optional[List[ZonesProperty]],
range: Optional[FullRange],
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
reachable_postcodes_threshold,
properties: Optional[List[ZonesProperty]],
range: Optional[FullRange],
) -> PostcodesSectorsRequest:
if properties is None:
properties = [ZonesProperty.TRAVEL_TIME_ALL]
Expand Down Expand Up @@ -347,21 +347,21 @@ def create_sectors(


def create_time_map(
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
search_range: Optional[Range],
level_of_detail: Optional[LevelOfDetail],
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
search_range: Optional[Range],
level_of_detail: Optional[LevelOfDetail],
) -> TimeMapRequest:
if arrival_time is not None and departure_time is not None:
raise ApiError("arrival_time and departure_time cannot be both specified")
Expand Down Expand Up @@ -407,21 +407,21 @@ def create_time_map(


def create_time_map_geojson(
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
search_range: Optional[Range],
level_of_detail: Optional[LevelOfDetail],
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
search_range: Optional[Range],
level_of_detail: Optional[LevelOfDetail],
) -> TimeMapRequestGeojson:
if arrival_time is not None and departure_time is not None:
raise ApiError("arrival_time and departure_time cannot be both specified")
Expand Down Expand Up @@ -463,21 +463,21 @@ def create_time_map_geojson(


def create_intersection(
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
search_range: Optional[Range],
level_of_detail: Optional[LevelOfDetail],
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
search_range: Optional[Range],
level_of_detail: Optional[LevelOfDetail],
) -> TimeMapRequest:
if arrival_time is not None and departure_time is not None:
raise ApiError("arrival_time and departure_time cannot be both specified")
Expand Down Expand Up @@ -533,21 +533,21 @@ def create_intersection(


def create_union(
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
search_range: Optional[Range],
level_of_detail: Optional[LevelOfDetail],
coordinates: List[Coordinates],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
travel_time: int,
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
search_range: Optional[Range],
level_of_detail: Optional[LevelOfDetail],
) -> TimeMapRequest:
if arrival_time is not None and departure_time is not None:
raise ApiError("arrival_time and departure_time cannot be both specified")
Expand Down Expand Up @@ -603,21 +603,21 @@ def create_union(


def create_routes(
locations: List[Location],
search_ids: Dict[str, List[str]],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
properties: Optional[List[Property]],
range: Optional[FullRange],
locations: List[Location],
search_ids: Dict[str, List[str]],
transportation: Union[
PublicTransport,
Driving,
Ferry,
Walking,
Cycling,
DrivingTrain,
CyclingPublicTransport,
],
departure_time: Optional[datetime],
arrival_time: Optional[datetime],
properties: Optional[List[Property]],
range: Optional[FullRange],
) -> RoutesRequest:
if arrival_time is not None and departure_time is not None:
raise ApiError("arrival_time and departure_time cannot be both specified")
Expand Down Expand Up @@ -665,12 +665,12 @@ def create_routes(


def create_proto_request(
origin: Coordinates,
destinations: List[Coordinates],
transportation: ProtoTransportation,
properties: Optional[List[PropertyProto]],
travel_time: int,
one_to_many: bool = True,
origin: Coordinates,
destinations: List[Coordinates],
transportation: ProtoTransportation,
properties: Optional[List[PropertyProto]],
travel_time: int,
one_to_many: bool = True,
) -> TimeFilterFastRequest_pb2.TimeFilterFastRequest:
request = TimeFilterFastRequest_pb2.TimeFilterFastRequest()

Expand All @@ -683,7 +683,8 @@ def create_proto_request(
request.oneToManyRequest.arrivalTimePeriod = (
TimeFilterFastRequest_pb2.TimePeriod.WEEKDAY_MORNING
)
request.oneToManyRequest.properties.extend(properties)
if properties is not None:
request.oneToManyRequest.properties.extend(properties)

mult = math.pow(10, 5)
for destination in destinations:
Expand All @@ -699,7 +700,8 @@ def create_proto_request(
request.manyToOneRequest.arrivalTimePeriod = (
TimeFilterFastRequest_pb2.TimePeriod.WEEKDAY_MORNING
)
request.manyToOneRequest.properties.extend(properties)
if properties is not None:
request.manyToOneRequest.properties.extend(properties)

mult = math.pow(10, 5)
for destination in destinations:
Expand Down

0 comments on commit 441282e

Please sign in to comment.