package com.tencent.lbssearch.object.param; import android.text.TextUtils; import com.tencent.lbssearch.object.RequestParams; import com.tencent.lbssearch.object.param.RoutePlanningParam; import com.tencent.lbssearch.object.result.DrivingResultObject; import com.tencent.mapsdk.internal.gz; import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Set; /* compiled from: TMS */ public class DrivingParam extends RoutePlanningParam { private int accuracy = -1; private List<List<LatLng>> avoidPolygons; private boolean cache; private String carNumber; private CarType carType = CarType.DEF; private String fromPOI; private Travel fromTravel; private int heading = -1; private final Set<String> mExtraFields = new HashSet(); private int multRoute; private int noStep = 0; private String policy; private RoadType roadType = RoadType.DEF; private int speed = -1; private boolean trafficSpeed; private List<LatLng> waypoints = new ArrayList(); /* compiled from: TMS */ public enum CarType { DEF, NEW_ENERGY } /* compiled from: TMS */ public enum Policy { LEAST_TIME, PICKUP, TRIP } /* compiled from: TMS */ public enum Preference { REAL_TRAFFIC, LEAST_FEE, AVOID_HIGHWAY, NAV_POINT_FIRST } /* compiled from: TMS */ public enum RoadType { DEF, ABOVE_BRIDGE, BELOW_BRIDGE, ON_MAIN_ROAD, ON_SIDE_ROAD, OPPOSITE_SIDE, ON_MAIN_ROAD_BELOW_BRIDGE, ON_SIDE_ROAD_BELOW_BRIDGE } /* compiled from: TMS */ public static class Travel { public List<Point> points = new ArrayList(); /* compiled from: TMS */ public static class Point { private int accuracy = -1; private int directionOfCar = -1; private int directionOfDevice = -1; private LatLng latLng; private int speed = -1; private int time; public Point(LatLng latLng2) { this.latLng = latLng2; } public Point setAccuracy(int i) { this.accuracy = i; return this; } public Point setDirectionOfCar(int i) { this.directionOfCar = i; return this; } public Point setDirectionOfDevice(int i) { this.directionOfDevice = i; return this; } public Point setSpeed(int i) { this.speed = i; return this; } public Point setTime(int i) { this.time = i; return this; } public String toString() { StringBuilder sb2 = new StringBuilder(); LatLng latLng2 = this.latLng; if (latLng2 != null) { sb2.append(latLng2.latitude); sb2.append(","); sb2.append(this.latLng.longitude); sb2.append(","); } sb2.append(this.speed); sb2.append(","); sb2.append(this.accuracy); sb2.append(","); sb2.append(this.directionOfCar); sb2.append(","); sb2.append(this.directionOfDevice); sb2.append(","); sb2.append(this.time); return sb2.toString(); } } public void addPoints(Point... pointArr) { if (pointArr != null) { this.points.addAll(Arrays.asList(pointArr)); } } public String toString() { int size = this.points.size(); if (size > 50) { size = 50; } for (int i = 0; i < size; i++) { Objects.toString(this.points.get(i)); } return super.toString(); } } public DrivingParam() { } public DrivingParam accuracy(int i) { this.accuracy = i; return this; } public DrivingParam addWayPoint(LatLng latLng) { if (this.waypoints.size() < 10) { this.waypoints.add(latLng); } return this; } public DrivingParam addWayPoints(Iterable<LatLng> iterable) { if (iterable != null) { int i = 0; for (LatLng latLng : iterable) { this.waypoints.add(latLng); i++; if (i > 10) { break; } } } return this; } @Override // com.tencent.lbssearch.object.param.ParamObject, com.tencent.lbssearch.object.param.RoutePlanningParam public RequestParams buildParameters() { RequestParams buildParameters = super.buildParameters(); if (!TextUtils.isEmpty(this.fromPOI)) { buildParameters.put("from_poi", this.fromPOI); } int i = this.heading; if (i != -1) { buildParameters.put("heading", i); } int i3 = this.speed; if (i3 != -1) { buildParameters.put("speed", i3); } int i12 = this.accuracy; if (i12 != -1) { buildParameters.put("accuracy", i12); } if (this.trafficSpeed) { buildParameters.put("get_speed", 1); } buildParameters.put("road_type", this.roadType.ordinal()); buildParameters.put("no_step", this.noStep); buildParameters.put("get_mp", this.multRoute); Travel travel = this.fromTravel; if (travel != null && travel.points.size() > 0) { buildParameters.put("from_track", this.fromTravel.toString()); } if (this.waypoints.size() > 0) { StringBuilder sb2 = new StringBuilder(); for (LatLng latLng : this.waypoints) { sb2.append(locationToParamsString(latLng)); sb2.append(";"); } sb2.setLength(sb2.length() - 1); buildParameters.put("waypoints", sb2.toString()); } if (!TextUtils.isEmpty(this.policy)) { buildParameters.put("policy", this.policy); } if (!TextUtils.isEmpty(this.carNumber)) { buildParameters.put("plate_number", this.carNumber); } buildParameters.put("car_type", this.carType.ordinal()); if (!this.mExtraFields.isEmpty()) { buildParameters.put("added_fields", gz.a(this.mExtraFields, ",")); } buildParameters.put("is_cache", this.cache ? "1" : "0"); if (this.avoidPolygons != null) { StringBuffer stringBuffer = new StringBuffer(); for (int i13 = 0; i13 < this.avoidPolygons.size(); i13++) { List<LatLng> list = this.avoidPolygons.get(i13); for (int i14 = 0; i14 < list.size(); i14++) { LatLng latLng2 = list.get(i14); stringBuffer.append(latLng2.latitude); stringBuffer.append(','); stringBuffer.append(latLng2.longitude); if (i14 != list.size() - 1) { stringBuffer.append(';'); } } if (i13 != this.avoidPolygons.size() - 1) { stringBuffer.append('|'); } } buildParameters.put("avoid_polygons", stringBuffer.toString()); } return buildParameters; } public DrivingParam cache(boolean z) { this.cache = z; return this; } public DrivingParam fromPOI(String str) { this.fromPOI = str; return this; } public DrivingParam fromTravel(Travel travel) { this.fromTravel = travel; return this; } @Override // com.tencent.lbssearch.object.param.RoutePlanningParam public Class<DrivingResultObject> getResultClass() { return DrivingResultObject.class; } @Override // com.tencent.lbssearch.object.param.RoutePlanningParam public String getUrl() { return "https://apis.map.qq.com/ws/direction/v1/driving"; } public DrivingParam heading(int i) { this.heading = i; return this; } public DrivingParam policy(Policy policy2, Preference... preferenceArr) { StringBuilder sb2 = new StringBuilder(); if (policy2 != null) { sb2.append(policy2.name()); } if (preferenceArr != null && preferenceArr.length > 0) { for (Preference preference : preferenceArr) { sb2.append(","); sb2.append(preference.name()); } } this.policy = sb2.toString(); return this; } public DrivingParam roadType(RoadType roadType2) { this.roadType = roadType2; return this; } public DrivingParam setAvoidPolygons(List<List<LatLng>> list) { this.avoidPolygons = list; return this; } public DrivingParam setCarNumber(String str) { this.carNumber = str; return this; } public DrivingParam setCarType(CarType carType2) { this.carType = carType2; return this; } public DrivingParam setExtraFields(String... strArr) { this.mExtraFields.addAll(Arrays.asList(strArr)); return this; } public DrivingParam setMultRoute(int i) { this.multRoute = i; return this; } public void setMultyPlan(boolean z) { } public DrivingParam setNoStep(int i) { this.noStep = i; return this; } public DrivingParam speed(int i) { this.speed = i; return this; } public DrivingParam trafficSpeed(boolean z) { this.trafficSpeed = z; return this; } @Override // com.tencent.lbssearch.object.param.RoutePlanningParam public DrivingParam toPOI(String str) { return (DrivingParam) super.toPOI(str); } public DrivingParam policy(RoutePlanningParam.DrivingPolicy drivingPolicy) { StringBuilder sb2 = new StringBuilder(); if (drivingPolicy != null) { sb2.append(drivingPolicy.name()); } this.policy = sb2.toString(); return this; } public DrivingParam(LatLng latLng, LatLng latLng2) { super(latLng, latLng2); } }