diff --git a/examples/random_persons.py b/examples/random_persons.py index 5f4782a..a5abc63 100644 --- a/examples/random_persons.py +++ b/examples/random_persons.py @@ -1,7 +1,7 @@ -from mosstool.trip.generator import (V1_DEFAULT_PERSON, V2_DEFAULT_PERSON, - PositionMode, RandomGenerator) +from mosstool.trip.generator import (DEFAULT_PERSON, PositionMode, + RandomGenerator) from mosstool.trip.route import RoutingClient, pre_route -from mosstool.type import Map, TripMode, Person, Persons +from mosstool.type import Map, Person, Persons, TripMode from mosstool.util.format_converter import pb2json @@ -11,7 +11,7 @@ async def main(): m.ParseFromString(f.read()) template = Person() - template.CopyFrom(V1_DEFAULT_PERSON) + template.CopyFrom(DEFAULT_PERSON) template.vehicle_attribute.model = "normal" template.pedestrian_attribute.model = "normal" rg = RandomGenerator( @@ -43,7 +43,6 @@ async def main(): with open("data/temp/persons.json", "w") as f: f.write(pb2json(pb)) - if __name__ == "__main__": import asyncio diff --git a/mosstool/trip/generator/__init__.py b/mosstool/trip/generator/__init__.py index fcddf81..1c52338 100644 --- a/mosstool/trip/generator/__init__.py +++ b/mosstool/trip/generator/__init__.py @@ -2,11 +2,10 @@ from .generate_from_od import TripGenerator from .gravity import GravityGenerator from .random import PositionMode, RandomGenerator -from .template import V1_DEFAULT_PERSON,V2_DEFAULT_PERSON +from .template import DEFAULT_PERSON __all__ = [ - "V1_DEFAULT_PERSON", - "V2_DEFAULT_PERSON", + "DEFAULT_PERSON", "RandomGenerator", "PositionMode", "GravityGenerator", diff --git a/mosstool/trip/generator/_util/utils.py b/mosstool/trip/generator/_util/utils.py index f72bd86..cfdb46d 100644 --- a/mosstool/trip/generator/_util/utils.py +++ b/mosstool/trip/generator/_util/utils.py @@ -2,16 +2,15 @@ from typing import Dict, List, Literal, Optional, Set, Tuple, Union, cast import numpy as np -from pycityproto.city.person.v2.person_pb2 import (BusAttribute, BusType,Person as v2Person, - PersonAttribute) -from pycityproto.city.person.v1.person_pb2 import (BusAttribute as v1BusAttribute, BusType as v1BusType, - PersonAttribute as v1PersonAttribute, Person as v1Person) +from pycityproto.city.person.v2.person_pb2 import (BusAttribute, BusType, + Person, PersonAttribute) from pycityproto.city.routing.v2.routing_pb2 import (DrivingJourneyBody, Journey, JourneyType) from pycityproto.city.trip.v2.trip_pb2 import TripStop from ....map._map_util.const import * -from ....type import (AoiPosition, LanePosition, Position, Schedule, Trip, TripMode) +from ....type import (AoiPosition, LanePosition, Position, Schedule, Trip, + TripMode) from ....util.format_converter import dict2pb, pb2dict from .const import * @@ -243,13 +242,12 @@ def extract_HWEO_from_od_matrix( def gen_bus_drivers( person_id: int, - person_template: v2Person, + person_template: Person, depart_times: List[float], stop_duration_time: float, road_aoi_id2d_pos: Dict[Tuple[int, int], geov2.LanePosition], subline, - person_version:str, -) -> Tuple[int, List[v2Person]]: +) -> Tuple[int, List[Person]]: def _transfer_conn_road_ids( station_connection_road_ids: List[List[int]], ) -> List[int]: @@ -270,204 +268,104 @@ def _aoi_road_ids(station_connection_road_ids) -> List[int]: # road that connect to the end station cur_road_ids.append(station_connection_road_ids[-1][-1]) return cur_road_ids - if person_version=="v1": - sl_id = subline.id - # basic attributes - sl_type = subline.type - bus_type = v1BusType.BUS_TYPE_UNSPECIFIED - if sl_type == mapv2.SUBLINE_TYPE_BUS: - sl_capacity = STATION_CAPACITY["BUS"] - sl_attributes = PT_DRIVER_ATTRIBUTES["BUS"] - bus_type = v1BusType.BUS_TYPE_BUS - elif sl_type == mapv2.SUBLINE_TYPE_SUBWAY: - sl_capacity = STATION_CAPACITY["SUBWAY"] - sl_attributes = PT_DRIVER_ATTRIBUTES["SUBWAY"] - bus_type = v1BusType.BUS_TYPE_SUBWAY - elif sl_type == mapv2.SUBLINE_TYPE_UNSPECIFIED: - sl_capacity = STATION_CAPACITY["UNSPECIFIED"] - sl_attributes = PT_DRIVER_ATTRIBUTES["UNSPECIFIED"] - bus_type = v1BusType.BUS_TYPE_UNSPECIFIED - else: - raise ValueError(f"Bad Subline Type {sl_type}") - # road ids - station_connection_road_ids = [ - [rid for rid in rids.road_ids] for rids in subline.station_connection_road_ids - ] - route_road_ids = _transfer_conn_road_ids(station_connection_road_ids) - trip_stop_road_ids = _aoi_road_ids( - station_connection_road_ids - ) # stop road ids during the trip - # trip stops - aoi_ids = list(subline.aoi_ids) - home_aoi_id, end_aoi_id = aoi_ids[0], aoi_ids[-1] - trip_stop_aoi_ids = aoi_ids # stop aoi ids during the trip - trip_stop_lane_id_s = [] - for cur_road_id, cur_aoi_id in zip(trip_stop_road_ids, trip_stop_aoi_ids): - road_aoi_key = (cur_road_id, cur_aoi_id) - if road_aoi_key not in road_aoi_id2d_pos: - raise ValueError(f"bad road and AOI pair {road_aoi_key}") - d_pos = road_aoi_id2d_pos[road_aoi_key] - d_lane_id, d_s = d_pos.lane_id, d_pos.s - trip_stop_lane_id_s.append((d_lane_id, d_s)) - assert len(trip_stop_lane_id_s) == len( - trip_stop_aoi_ids - ), f"Bad PublicTransport Route at {aoi_ids}" - p_trip_stops = [] - # bus attribute - p_bus_attr = v1BusAttribute( - subline_id=sl_id, capacity=sl_capacity, type=bus_type, model="" - ) - for (d_lane_id, d_s), aoi_id in zip(trip_stop_lane_id_s, trip_stop_aoi_ids): - trip_stop = TripStop() - trip_stop.lane_position.CopyFrom(LanePosition(lane_id=d_lane_id, s=d_s)) - trip_stop.aoi_position.CopyFrom(AoiPosition(aoi_id=aoi_id)) - trip_stop.duration = stop_duration_time - p_trip_stops.append(trip_stop) - # eta for bus journey - bus_eta = sum(subline.schedules.offset_times) - sl_drivers = [] - if bus_type == BusType.BUS_TYPE_BUS: - for tm in depart_times: - p = v1Person() - p.CopyFrom(person_template) - p.id = person_id - if sl_attributes: - p.attribute.CopyFrom(dict2pb(sl_attributes, v1PersonAttribute())) - p.bus_attribute.CopyFrom(p_bus_attr) - p.home.CopyFrom(Position(aoi_position=AoiPosition(aoi_id=home_aoi_id))) - schedule = cast(Schedule, p.schedules.add()) - schedule.departure_time = tm - schedule.loop_count = 1 - trip = Trip( - mode=cast( - TripMode, - CAR, - ), - end=Position(aoi_position=AoiPosition(aoi_id=end_aoi_id)), - activity="", - model="", - trip_stops=p_trip_stops, - routes=[ - Journey( - driving=DrivingJourneyBody( - road_ids=route_road_ids, eta=bus_eta - ), - type=JourneyType.JOURNEY_TYPE_DRIVING, - ) - ], - ) - schedule.trips.append(trip) - person_id += 1 - sl_drivers.append(p) - elif bus_type == BusType.BUS_TYPE_SUBWAY: - # empty schedule - p = v1Person() - p.CopyFrom(person_template) - p.id = person_id - if sl_attributes: - p.attribute.CopyFrom(dict2pb(sl_attributes, v1PersonAttribute())) - p.bus_attribute.CopyFrom(p_bus_attr) - p.home.CopyFrom(Position(aoi_position=AoiPosition(aoi_id=home_aoi_id))) - person_id += 1 - sl_drivers.append(p) - else: - sl_id = subline.id - # basic attributes - sl_type = subline.type + + sl_id = subline.id + # basic attributes + sl_type = subline.type + bus_type = BusType.BUS_TYPE_UNSPECIFIED + if sl_type == mapv2.SUBLINE_TYPE_BUS: + sl_capacity = STATION_CAPACITY["BUS"] + sl_attributes = PT_DRIVER_ATTRIBUTES["BUS"] + bus_type = BusType.BUS_TYPE_BUS + elif sl_type == mapv2.SUBLINE_TYPE_SUBWAY: + sl_capacity = STATION_CAPACITY["SUBWAY"] + sl_attributes = PT_DRIVER_ATTRIBUTES["SUBWAY"] + bus_type = BusType.BUS_TYPE_SUBWAY + elif sl_type == mapv2.SUBLINE_TYPE_UNSPECIFIED: + sl_capacity = STATION_CAPACITY["UNSPECIFIED"] + sl_attributes = PT_DRIVER_ATTRIBUTES["UNSPECIFIED"] bus_type = BusType.BUS_TYPE_UNSPECIFIED - if sl_type == mapv2.SUBLINE_TYPE_BUS: - sl_capacity = STATION_CAPACITY["BUS"] - sl_attributes = PT_DRIVER_ATTRIBUTES["BUS"] - bus_type = BusType.BUS_TYPE_BUS - elif sl_type == mapv2.SUBLINE_TYPE_SUBWAY: - sl_capacity = STATION_CAPACITY["SUBWAY"] - sl_attributes = PT_DRIVER_ATTRIBUTES["SUBWAY"] - bus_type = BusType.BUS_TYPE_SUBWAY - elif sl_type == mapv2.SUBLINE_TYPE_UNSPECIFIED: - sl_capacity = STATION_CAPACITY["UNSPECIFIED"] - sl_attributes = PT_DRIVER_ATTRIBUTES["UNSPECIFIED"] - bus_type = BusType.BUS_TYPE_UNSPECIFIED - else: - raise ValueError(f"Bad Subline Type {sl_type}") - # road ids - station_connection_road_ids = [ - [rid for rid in rids.road_ids] for rids in subline.station_connection_road_ids - ] - route_road_ids = _transfer_conn_road_ids(station_connection_road_ids) - trip_stop_road_ids = _aoi_road_ids( - station_connection_road_ids - ) # stop road ids during the trip - # trip stops - aoi_ids = list(subline.aoi_ids) - home_aoi_id, end_aoi_id = aoi_ids[0], aoi_ids[-1] - trip_stop_aoi_ids = aoi_ids # stop aoi ids during the trip - trip_stop_lane_id_s = [] - for cur_road_id, cur_aoi_id in zip(trip_stop_road_ids, trip_stop_aoi_ids): - road_aoi_key = (cur_road_id, cur_aoi_id) - if road_aoi_key not in road_aoi_id2d_pos: - raise ValueError(f"bad road and AOI pair {road_aoi_key}") - d_pos = road_aoi_id2d_pos[road_aoi_key] - d_lane_id, d_s = d_pos.lane_id, d_pos.s - trip_stop_lane_id_s.append((d_lane_id, d_s)) - assert len(trip_stop_lane_id_s) == len( - trip_stop_aoi_ids - ), f"Bad PublicTransport Route at {aoi_ids}" - p_trip_stops = [] - # bus attribute - p_bus_attr = BusAttribute( - subline_id=sl_id, capacity=sl_capacity, type=bus_type, model="" - ) - for (d_lane_id, d_s), aoi_id in zip(trip_stop_lane_id_s, trip_stop_aoi_ids): - trip_stop = TripStop() - trip_stop.lane_position.CopyFrom(LanePosition(lane_id=d_lane_id, s=d_s)) - trip_stop.aoi_position.CopyFrom(AoiPosition(aoi_id=aoi_id)) - trip_stop.duration = stop_duration_time - p_trip_stops.append(trip_stop) - # eta for bus journey - bus_eta = sum(subline.schedules.offset_times) - sl_drivers = [] - if bus_type == BusType.BUS_TYPE_BUS: - for tm in depart_times: - p = v2Person() - p.CopyFrom(person_template) - p.id = person_id - if sl_attributes: - p.attribute.CopyFrom(dict2pb(sl_attributes, PersonAttribute())) - p.bus_attribute.CopyFrom(p_bus_attr) - p.home.CopyFrom(Position(aoi_position=AoiPosition(aoi_id=home_aoi_id))) - schedule = cast(Schedule, p.schedules.add()) - schedule.departure_time = tm - schedule.loop_count = 1 - trip = Trip( - mode=cast( - TripMode, - CAR, - ), - end=Position(aoi_position=AoiPosition(aoi_id=end_aoi_id)), - activity="", - model="", - trip_stops=p_trip_stops, - routes=[ - Journey( - driving=DrivingJourneyBody( - road_ids=route_road_ids, eta=bus_eta - ), - type=JourneyType.JOURNEY_TYPE_DRIVING, - ) - ], - ) - schedule.trips.append(trip) - person_id += 1 - sl_drivers.append(p) - elif bus_type == BusType.BUS_TYPE_SUBWAY: - # empty schedule - p = v2Person() + else: + raise ValueError(f"Bad Subline Type {sl_type}") + # road ids + station_connection_road_ids = [ + [rid for rid in rids.road_ids] for rids in subline.station_connection_road_ids + ] + route_road_ids = _transfer_conn_road_ids(station_connection_road_ids) + trip_stop_road_ids = _aoi_road_ids( + station_connection_road_ids + ) # stop road ids during the trip + # trip stops + aoi_ids = list(subline.aoi_ids) + home_aoi_id, end_aoi_id = aoi_ids[0], aoi_ids[-1] + trip_stop_aoi_ids = aoi_ids # stop aoi ids during the trip + trip_stop_lane_id_s = [] + for cur_road_id, cur_aoi_id in zip(trip_stop_road_ids, trip_stop_aoi_ids): + road_aoi_key = (cur_road_id, cur_aoi_id) + if road_aoi_key not in road_aoi_id2d_pos: + raise ValueError(f"bad road and AOI pair {road_aoi_key}") + d_pos = road_aoi_id2d_pos[road_aoi_key] + d_lane_id, d_s = d_pos.lane_id, d_pos.s + trip_stop_lane_id_s.append((d_lane_id, d_s)) + assert len(trip_stop_lane_id_s) == len( + trip_stop_aoi_ids + ), f"Bad PublicTransport Route at {aoi_ids}" + p_trip_stops = [] + # bus attribute + p_bus_attr = BusAttribute( + subline_id=sl_id, capacity=sl_capacity, type=bus_type, model="" + ) + for (d_lane_id, d_s), aoi_id in zip(trip_stop_lane_id_s, trip_stop_aoi_ids): + trip_stop = TripStop() + trip_stop.lane_position.CopyFrom(LanePosition(lane_id=d_lane_id, s=d_s)) + trip_stop.aoi_position.CopyFrom(AoiPosition(aoi_id=aoi_id)) + trip_stop.duration = stop_duration_time + p_trip_stops.append(trip_stop) + # eta for bus journey + bus_eta = sum(subline.schedules.offset_times) + sl_drivers = [] + if bus_type == BusType.BUS_TYPE_BUS: + for tm in depart_times: + p = Person() p.CopyFrom(person_template) p.id = person_id if sl_attributes: p.attribute.CopyFrom(dict2pb(sl_attributes, PersonAttribute())) p.bus_attribute.CopyFrom(p_bus_attr) p.home.CopyFrom(Position(aoi_position=AoiPosition(aoi_id=home_aoi_id))) + schedule = cast(Schedule, p.schedules.add()) + schedule.departure_time = tm + schedule.loop_count = 1 + trip = Trip( + mode=cast( + TripMode, + CAR, + ), + end=Position(aoi_position=AoiPosition(aoi_id=end_aoi_id)), + activity="", + model="", + trip_stops=p_trip_stops, + routes=[ + Journey( + driving=DrivingJourneyBody( + road_ids=route_road_ids, eta=bus_eta + ), + type=JourneyType.JOURNEY_TYPE_DRIVING, + ) + ], + ) + schedule.trips.append(trip) person_id += 1 - + sl_drivers.append(p) + elif bus_type == BusType.BUS_TYPE_SUBWAY: + # empty schedule + p = Person() + p.CopyFrom(person_template) + p.id = person_id + if sl_attributes: + p.attribute.CopyFrom(dict2pb(sl_attributes, PersonAttribute())) + p.bus_attribute.CopyFrom(p_bus_attr) + p.home.CopyFrom(Position(aoi_position=AoiPosition(aoi_id=home_aoi_id))) + person_id += 1 + return (person_id, sl_drivers) diff --git a/mosstool/trip/generator/generate_from_od.py b/mosstool/trip/generator/generate_from_od.py index 08fded1..d1898b6 100644 --- a/mosstool/trip/generator/generate_from_od.py +++ b/mosstool/trip/generator/generate_from_od.py @@ -13,14 +13,13 @@ from ...map._map_util.const import * from ...type import (AoiPosition, LanePosition, Map, Person, PersonProfile, - Position, Schedule, Trip, TripMode, v1Person, - v1PersonProfile) + Position, Schedule, Trip, TripMode) from ...util.format_converter import dict2pb, pb2dict from ._util.const import * from ._util.utils import (extract_HWEO_from_od_matrix, gen_bus_drivers, gen_departure_times, gen_profiles, recalculate_trip_mode_prob) -from .template import V1_DEFAULT_PERSON, V2_DEFAULT_PERSON +from .template import DEFAULT_PERSON # from ...util.geo_match_pop import geo2pop @@ -414,8 +413,7 @@ def __init__( bus_expense: float = 5.0, bike_speed: float = 10 / 3.6, bike_penalty: float = 0.9, - template=None, #: Person = DEFAULT_PERSON, - person_version: Union[Literal["v1"], Literal["v2"]] = "v1", + template: Person = DEFAULT_PERSON, add_pop: bool = False, workers: int = cpu_count(), ): @@ -439,7 +437,6 @@ def __init__( - add_pop (bool): Add population to aois. - workers (int): number of workers. """ - self.person_version = person_version global SUBWAY_EXPENSE, BUS_EXPENSE, DRIVING_SPEED, DRIVING_PENALTY, SUBWAY_SPEED, SUBWAY_PENALTY, BUS_SPEED, BUS_PENALTY, BIKE_SPEED, BIKE_PENALTY, PARKING_FEE SUBWAY_EXPENSE, BUS_EXPENSE = subway_expense, bus_expense DRIVING_SPEED, DRIVING_PENALTY, PARKING_FEE = ( @@ -455,10 +452,6 @@ def __init__( self.add_pop = add_pop self.projector = pyproj.Proj(m.header.projection) self.workers = workers - if person_version == "v1": - template = V1_DEFAULT_PERSON - else: - template = V2_DEFAULT_PERSON self.template = template self.template.ClearField("schedules") self.template.ClearField("home") @@ -690,18 +683,12 @@ def _generate_mobi( activities, ) in enumerate(raw_persons): times = np.array(times) * 3600 # hour->second - if self.person_version == "v1": - p = v1Person() - else: - p = Person() + p = Person() p.CopyFrom(self.template) p.id = agent_id p.home.CopyFrom(Position(aoi_position=AoiPosition(aoi_id=person_home))) p.work.CopyFrom(Position(aoi_position=AoiPosition(aoi_id=person_work))) - if self.person_version == "v1": - p.profile.CopyFrom(dict2pb(a_profile, v1PersonProfile())) - else: - p.profile.CopyFrom(dict2pb(a_profile, PersonProfile())) + p.profile.CopyFrom(dict2pb(a_profile, PersonProfile())) for time, aoi_id, trip_mode, activity, trip_model in zip( times, aoi_list[1:], trip_modes, activities, trip_models ): @@ -827,7 +814,6 @@ def generate_public_transport_drivers( stop_duration_time, road_aoi_id2d_pos, sl, - self.person_version ) self.persons.extend(generated_drivers) return self.persons diff --git a/mosstool/trip/generator/random.py b/mosstool/trip/generator/random.py index b06eba6..13feefa 100644 --- a/mosstool/trip/generator/random.py +++ b/mosstool/trip/generator/random.py @@ -4,13 +4,12 @@ import numpy as np from pycityproto.city.geo.v2.geo_pb2 import AoiPosition, LanePosition, Position from pycityproto.city.map.v2.map_pb2 import Aoi, Lane, LaneType, Map -from pycityproto.city.person.v1.person_pb2 import Person as v1Person -from pycityproto.city.person.v2.person_pb2 import Person as v2Person +from pycityproto.city.person.v2.person_pb2 import Person from pycityproto.city.trip.v2.trip_pb2 import Schedule, Trip, TripMode from ...map._map_util.const import JUNC_START_ID from ._util.utils import is_walking -from .template import V1_DEFAULT_PERSON, V2_DEFAULT_PERSON +from .template import DEFAULT_PERSON __all__ = ["PositionMode", "RandomGenerator"] @@ -30,9 +29,7 @@ def __init__( m: Map, position_modes: List[PositionMode], trip_mode: TripMode, - template=None, - # Person = DEFAULT_PERSON, - person_version: Union[Literal["v1"], Literal["v2"]] = "v1", + template: Person = DEFAULT_PERSON, ): """ Args: @@ -41,11 +38,6 @@ def __init__( - trip_mode (TripMode): The target trip mode. - template (Person): The template of generated person object, whose `schedules`, `home` will be replaced and others will be copied. """ - self.person_version = person_version - if person_version == "v1": - template = V1_DEFAULT_PERSON - else: - template = V2_DEFAULT_PERSON self.m = m self.modes = position_modes if len(self.modes) <= 1: @@ -93,7 +85,7 @@ def uniform( schedule_interval_range: Tuple[float, float], seed: Optional[int] = None, start_id: Optional[int] = None, - ) -> List[v1Person]: + ) -> List[Person]: """ Generate a person object by uniform random sampling @@ -111,10 +103,7 @@ def uniform( np.random.seed(seed) persons = [] for i in range(num): - if self.person_version == "v1": - p = v1Person() - else: - p = v2Person() + p = Person() p.CopyFrom(self.template) if start_id is not None: p.id = start_id + i diff --git a/mosstool/trip/generator/template.py b/mosstool/trip/generator/template.py index 2a836cc..139c264 100644 --- a/mosstool/trip/generator/template.py +++ b/mosstool/trip/generator/template.py @@ -1,43 +1,16 @@ -from pycityproto.city.person.v1.person_pb2 import \ - BikeAttribute as v1BikeAttribute -from pycityproto.city.person.v1.person_pb2 import \ - PedestrianAttribute as v1PedestrianAttribute -from pycityproto.city.person.v1.person_pb2 import Person as v1Person -from pycityproto.city.person.v1.person_pb2 import \ - PersonAttribute as v1PersonAttribute -from pycityproto.city.person.v1.person_pb2 import \ - VehicleAttribute as v1VehicleAttribute from pycityproto.city.person.v2.person_pb2 import (BikeAttribute, EmissionAttribute, - PedestrianAttribute, Person as v2Person, - PersonAttribute, + PedestrianAttribute) +from pycityproto.city.person.v2.person_pb2 import Person as v2Person +from pycityproto.city.person.v2.person_pb2 import (PersonAttribute, VehicleAttribute, VehicleEngineEfficiency, VehicleEngineType) __all__ = [ - "V1_DEFAULT_PERSON", - "V2_DEFAULT_PERSON", + "DEFAULT_PERSON", ] - -V1_DEFAULT_PERSON = v1Person( - attribute=v1PersonAttribute( - length=5, - width=2, - max_speed=150 / 3.6, - max_acceleration=3, - max_braking_acceleration=-10, - usual_acceleration=2, - usual_braking_acceleration=-4.5, - ), - vehicle_attribute=v1VehicleAttribute( - lane_change_length=10, - min_gap=1, - ), - pedestrian_attribute=v1PedestrianAttribute(speed=1.34), - bike_attribute=v1BikeAttribute(speed=5), -) -V2_DEFAULT_PERSON = v2Person( +DEFAULT_PERSON = v2Person( attribute=PersonAttribute(), vehicle_attribute=VehicleAttribute( length=5, diff --git a/mosstool/trip/route/preroute.py b/mosstool/trip/route/preroute.py index 460d902..1ce660a 100644 --- a/mosstool/trip/route/preroute.py +++ b/mosstool/trip/route/preroute.py @@ -1,8 +1,7 @@ import logging from typing import cast -from pycityproto.city.person.v1.person_pb2 import Person as v1Person -from pycityproto.city.person.v2.person_pb2 import Person as v2Person +from pycityproto.city.person.v2.person_pb2 import Person from pycityproto.city.routing.v2.routing_pb2 import RouteType from pycityproto.city.routing.v2.routing_service_pb2 import GetRouteRequest from pycityproto.city.trip.v2.trip_pb2 import Schedule, TripMode @@ -21,10 +20,9 @@ async def pre_route( client: RoutingClient, - person: v2Person, + person: Person, in_place: bool = False, - person_version: str = "v1", -) -> v2Person: +) -> Person: """ Fill in the route of the person's all schedules. The function will REMOVE all schedules that can not be routed. @@ -38,10 +36,7 @@ async def pre_route( - None """ if not in_place: - if person_version == "v1": - p = v1Person() - else: - p = v2Person() + p = Person() p.CopyFrom(person) # type:ignore person = p # type:ignore start = person.home diff --git a/mosstool/type/__init__.py b/mosstool/type/__init__.py index c602f35..c142c85 100644 --- a/mosstool/type/__init__.py +++ b/mosstool/type/__init__.py @@ -8,18 +8,9 @@ LongLatPosition, Position) from pycityproto.city.map.v2.map_pb2 import (Aoi, AoiType, Lane, LaneTurn, LaneType, Map) -from pycityproto.city.person.v1.person_pb2 import Consumption as v1Consumption -from pycityproto.city.person.v1.person_pb2 import Education as v1Education -from pycityproto.city.person.v1.person_pb2 import Gender as v1Gender -from pycityproto.city.person.v1.person_pb2 import Person as v1Person -from pycityproto.city.person.v1.person_pb2 import Person -from pycityproto.city.person.v1.person_pb2 import Persons -from pycityproto.city.person.v1.person_pb2 import \ - PersonProfile as v1PersonProfile -from pycityproto.city.person.v1.person_pb2 import Persons as v1Persons from pycityproto.city.person.v2.person_pb2 import (Consumption, Education, - Gender, Person as v2Person, - PersonProfile, Persons as v2Persons) + Gender, Person, + PersonProfile, Persons) from pycityproto.city.routing.v2.routing_pb2 import (DrivingJourneyBody, Journey, JourneyType) from pycityproto.city.routing.v2.routing_service_pb2 import (GetRouteRequest, diff --git a/pyproject.toml b/pyproject.toml index ff96e8d..38c6038 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "mosstool" -version = "0.2.43" +version = "1.0.0" description = "MObility Simulation System toolbox " authors = ["Jun Zhang "] license = "MIT"