このドキュメントでは、共有プール旅行を作成する方法と、 車両に割り当てることができます。フリートがセットアップ済みであることを前提としています。 自動車を作成し、運転手用アプリを使用できるようにして、 コンシューマアプリでも実行できますまた、Google Cloud で提供されている いくつか紹介します。以下の関連ガイドをご覧ください。 必要があります。
- Fleet Engine を設定する
- 車両を作成する
- オンデマンドの賃走の概要の移動のシナリオ
旅程作成の基本
このセクションでは、 Fleet EnginegRPC と REST のいずれかを使用して作成リクエストを発行します。
で確認できます。ルート フィールド
Fleet Engine でルートを作成するには、次のフィールドを使用します。単一または複数の目的地、連続したルート、共有プール ルートなど、さまざまな種類のルートに異なるフィールドを使用できます。マイページ ルートの作成時にオプション フィールドを指定することも、自分で ルートを更新したときに 自動的に設定されます
名前 | 必須 | 説明 |
---|---|---|
親 | ○ | プロジェクト ID を含む文字列。この ID は、使用されている ID と同じである必要があります Fleet Engine インテグレーション全体にわたり、同じサービス アカウントで できます。 |
trip_id | ○ | このルートを一意に識別する文字列。参照に記載されているように、ルート ID には特定の制限があります。 |
trip_type | ○ | 作成するルートのタイプに応じて、TripType に次の値を設定します。
<ph type="x-smartling-placeholder">
|
pickup_point | ○ | ルートの出発地。 |
中間デスティネーション | ○ | 複数の目的地を含むルートのみ: ドライバーがルート間を通る中間の目的地のリスト
ピックアップとドロップオフです |
vehicle_waypoints | ○ | 共有プールのルートのみ: このフィールドでは、複数のルートのウェイポイントをインターリーブできます。
これには、割り当てられた車両の残りのウェイポイントもすべて含まれます。
このルートの乗り降り地点として設定しますこのフィールドは
|
number_of_passengers | いいえ | 旅行の乗客数。 |
dropoff_point | いいえ | ルートの目的地。 |
vehicle_id | いいえ | ルートに割り当てられている車両の ID。 |
例: 共有プーリング ルートを作成する
次のバックエンド統合サンプルは、ルートを作成し、 共有相乗りルートとして車両に割り当てます。
// Vehicle with VEHICLE_ID ID is already created and it is assigned Trip A.
static final String PROJECT_ID = "my-rideshare-co-gcp-project";
static final String TRIP_ID = "shared-trip-A";
static final String VEHICLE_ID = "your-vehicle-id";
static final String TRIP_A_ID = "trip-a-id";
static final String TRIP_B_ID = "trip-b-id";
TripServiceBlockingStub tripService = TripService.newBlockingStub(channel);
String parent = "providers/" + PROJECT_ID;
LatLng tripBPickup =
LatLng.newBuilder().setLatitude(-12.12314).setLongitude(88.142123).build();
LatLng tripBDropoff =
LatLng.newBuilder().setLatitude(-14.12314).setLongitude(90.142123).build();
TerminalLocation tripBPickupTerminalLocation =
TerminalLocation.newBuilder().setPoint(tripBPickup).build();
TerminalLocation tripBDropoffTerminalLocation =
TerminalLocation.newBuilder().setPoint(tripBDropoff).build();
// TripA already exists and it's assigned to a vehicle with VEHICLE_ID ID.
Trip tripB = Trip.newBuilder()
.setTripType(TripType.SHARED)
.setVehicleId(VEHICLE_ID)
.setPickupPoint(tripBPickupTerminalLocation)
.setDropoffPoint(tripBDropoffTerminalLocation)
.addAllVehicleWaypoints(
// This is where you define the arrival order for unvisited waypoints.
// If you don't specify an order, then the Fleet Engine adds Trip B's
// waypoints to the end of Trip A's.
ImmutableList.of(
// Trip B's pickup point.
TripWaypoint.newBuilder()
.setLocation(tripBPickupTerminalLocation)
.setTripId(TRIP_B_ID)
.setWaypointType(WaypointType.PICKUP_WAYPOINT_TYPE)
.build(),
// Trip A's drop-off point.
TripWaypoint.newBuilder()
.setLocation(tripA.getDropoffPoint())
.setTripId(TRIP_A_ID)
.setWaypointType(WaypointType.DROP_OFF_WAYPOINT_TYPE)
.build(),
// Trip B's drop-off point.
TripWaypoint.newBuilder()
.setLocation(tripBDropoffTerminalLocation)
.setTripId(TRIP_B_ID)
.setWaypointType(WaypointType.DROP_OFF_WAYPOINT_TYPE)
.build()))
.build();
// Create Trip request
CreateTripRequest createTripRequest = CreateTripRequest.newBuilder()
.setParent(parent)
.setTripId(TRIP_B_ID)
.setTrip(tripB)
.build();
try {
// createdTrip.remainingWaypoints will contain shared-pool waypoints.
// [tripB.pickup, tripA.dropoff, tripB.dropoff]
Trip createdTrip = tripService.createTrip(createTripRequest);
} catch (StatusRuntimeException e) {
Status s = e.getStatus();
switch (s.getCode()) {
case ALREADY_EXISTS:
break;
case PERMISSION_DENIED:
break;
}
return;
}
共有されているプール旅行を更新する
Fleet Engine で作成したルートを車両に割り当てるには、 Fleet Engine: ルートの到着予定時刻を計算して追跡します。この設定は ルートの更新時にトリガーされます。
共有プールのルートの場合は、訪問していないウェイポイントへの順序を指定する必要があります
ルートの車両ウェイポイントのコレクション(Trip.vehicle_waypoints
)。フリート
エンジンはこのリストを使用して、すべてのルートのルートの地点を自動的に更新します
割り当てられています
たとえば、相乗りの 2 つのルート(Trip A と ルート B:
- ルート A は降車場所に向かっています。
- ルート B が同じ車両に追加されます。
ルート B の 1 つの UpdateTripRequest
で、
vehicleId
を設定し、さらに Trip.vehicle_waypoints
を最適な値に
地点の順序: B 乗車
→ 持ち込み →
B 降車:
getVehicle()
を呼び出すと、remainingWaypoints
が返されます。
B 集荷 → A 配達 → B 配達 が含まれます。getTrip()
またはonTripRemainingWaypointsUpdated
コールバック: ルート A はremainingWaypoints
を返します 次を含む:
B 受け取り → 持ち込み。getTrip()
またはonTripRemainingWaypointsUpdated
コールバック: 「ルート B」は「remainingWaypoints
」を返します 次を含む:
B ピックアップ → 持ち込み → B 降車。
例
次のバックエンド統合サンプルは、 2 つの共有プールルートの車両 ID と地点。
static final String PROJECT_ID = "my-rideshare-co-gcp-project";
static final String TRIP_A_ID = "share-trip-A";
static final String TRIP_B_ID = "share-trip-B";
static final String VEHICLE_ID = "Vehicle";
String tripName = "providers/" + PROJECT_ID + "/trips/" + TRIP_B_ID;
// Get Trip A and Trip B objects from either the Fleet Engine or storage.
Trip tripA = …;
Trip tripB = …;
TripServiceBlockingStub tripService = TripService.newBlockingStub(channel);
// The trip settings to update.
Trip trip = Trip.newBuilder()
.setVehicleId(VEHICLE_ID)
.addAllVehicleWaypoints(
// This is where you define the arrival order for unvisited waypoints.
// If you don't specify an order, then the Fleet Engine adds Trip B's
// waypoints to the end of Trip A's.
ImmutableList.of(
// Trip B's pickup point.
TripWaypoint.newBuilder()
.setLocation(tripB.getPickupPoint())
.setTripId(TRIP_B_ID)
.setWaypointType(WaypointType.PICKUP_WAYPOINT_TYPE)
.build(),
// Trip A's drop-off point.
TripWaypoint.newBuilder()
.setLocation(tripA.getDropoffPoint())
.setTripId(TRIP_A_ID)
.setWaypointType(WaypointType.DROP_OFF_WAYPOINT_TYPE)
.build(),
// Trip B's drop-off point.
TripWaypoint.newBuilder()
.setLocation(tripB.getDropoffPoint())
.setTripId(TRIP_B_ID)
.setWaypointType(WaypointType.DROP_OFF_WAYPOINT_TYPE)
.build()))
.build();
// The trip update request.
UpdateTripRequest updateTripRequest = UpdateTripRequest.newBuilder()
.setName(tripName)
.setTrip(trip)
.setUpdateMask(FieldMask.newBuilder()
.addPaths("vehicle_id")
.addPaths("vehicle_waypoints"))
.build();
// Error handling. If Fleet Engine has both a trip and vehicle with the IDs,
// and if the credentials validate, and if the given vehicle_waypoints list
// is valid, then the service updates the trip.
try {
Trip updatedTrip = tripService.updateTrip(updateTripRequest);
} catch (StatusRuntimeException e) {
Status s = e.getStatus();
switch (s.getCode()) {
case NOT_FOUND: // Either the trip or vehicle does not exist.
break;
case PERMISSION_DENIED:
break;
case INVALID_REQUEST: // vehicle_waypoints is invalid.
break;
}
return;
}