주문형 이동을 위해 Fleet Engine에서 차량을 만들려면 CreateVehicle
를 사용하세요.
엔드포인트를 CreateVehicleRequest
로 설정합니다. 이 엔드포인트에
Fleet Engine 주문형 관리자 역할을 부여합니다.
주문형 이동 차량 필드
주문형 이동을 위한 차량을 만들 때는 필수 필드를 설정해야 합니다. 나 특정 차량 필드가 다른 차량에 미치는 영향도 알고 있어야 합니다 기능을 제공합니다 자세한 내용은 차량 필드 업데이트를 참고하세요.
주문형 이동의 필수 입력란
vehicle_state
: 기본값은 알 수 없음, 온라인 또는 오프라인. 차량 상태 필드 설정에 관한 정보는 Update 차량 필드가 있다고 가정합니다.supported_trip_types
: 기본값은 알 수 없음(알 수 없음)이지만 다음과 같이 설정해야 합니다. SHARED, EXCLUSIVE 또는 둘 다입니다. 주문형 경로에서 여행 유형을 참고하세요. 가이드를 참조하세요.maximum_capacity
: 차량이 승차할 수 있는 승객 수 (정의에 따라) 드라이버가 제외됩니다.vehicle_type
: 값은AUTO
,TAXI
,TRUCK
,TWO-WHEELER
,BICYCLE
또는PEDESTRIAN
입니다. 차량용 차량 필터링에 사용 가능 검색 이는 도착예정시간과 경로 계산에도 영향을 줍니다. Fleet 엔진 의 이동 수단에 해당하는 경로 및 이동 계산을 제공합니다. 다음 차량 유형 그룹에 따라 여행합니다.AUTO
,TAXI
또는TRUCK
: 고속도로를 예로 들 수 있습니다.TWO_WHEELER
: 예를 들어 오토바이가 없는 경로를 반환하지 않습니다. 허용됩니다.BICYCLE
: 자전거 전용 도로를 예로 들 수 있습니다.PEDESTRIAN
: 보행자 전용 다리와 인도를 예로 들 수 있습니다.
기타 필드
차량을 만들 때 설정할 수 있는 다른 필드는 차량 업데이트를 참고하세요. 필드.
차량 생성 예
CreateVehicle
에서 반환된 값은 생성된 Vehicle
항목입니다.
자바
static final String PROJECT_ID = "project-id";
VehicleServiceBlockingStub vehicleService =
VehicleService.newBlockingStub(channel);
String parent = "providers/" + PROJECT_ID;
Vehicle vehicle = Vehicle.newBuilder()
.setVehicleState(VehicleState.OFFLINE) // Initial state
.addSupportedTripTypes(TripType.EXCLUSIVE)
.setMaximumCapacity(4)
.setVehicleType(VehicleType.newBuilder().setCategory(VehicleType.Category.AUTO))
.addAttributes(VehicleAttribute.newBuilder()
.setKey("on_trip").setValue("false")) // Opaque to the Fleet Engine
// Add .setBackToBackEnabled(true) to make this vehicle eligible for trip
// matching while even if it is on a trip. By default this is disabled.
.build();
CreateVehicleRequest createVehicleRequest =
CreateVehicleRequest.newBuilder() // no need for the header
.setParent(parent)
.setVehicleId("vid-8241890") // Vehicle ID assigned by Rideshare or Delivery Provider
.setVehicle(vehicle) // Initial state
.build();
// In this case, the Vehicle is being created in the OFFLINE state and
// no initial position is being provided. When the Driver App checks
// in with the Rideshare or Delivery Provider, the state can be set to ONLINE and
// the Driver App will update the Vehicle Location.
try {
Vehicle createdVehicle =
vehicleService.createVehicle(createVehicleRequest);
} catch (StatusRuntimeException e) {
Status s = e.getStatus();
switch (s.getCode()) {
case ALREADY_EXISTS:
break;
case PERMISSION_DENIED:
break;
}
return;
}
// If no Exception, Vehicle created successfully.
REST
curl -X POST \
"https://fleetengine.googleapis.com/v1/providers/project-id/vehicles?vehicleId=vid-8241890" \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
--data-binary @- << EOM
{
"vehicleState": "OFFLINE",
"supportedTripTypes": ["EXCLUSIVE"],
"maximumCapacity": 4,
"vehicleType": {"category": "AUTO"},
"attributes": [{"key": "on_trip", "value": "false"}]
}
EOM
providers.vehicles.create 참조를 확인하세요.