import { LngLatLike } from 'maplibre-gl'; import { TravelMode, GeometryType, AvoidType, OverviewType, ApproachType } from '@src/common/interface'; import { NBRequestStatus, StepIntersections, StepManeuver } from './common'; export type DirectionsRouteType = 'fastest' | 'shortest'; export type DirectionsRoadInfo = 'max_speed'; export type DirectionsHazmatType = 'general' | 'circumstantial' | 'explosive' | 'harmfulToWater'; /** * A directions query to be sent to the DirectionsSerivce */ export type DirectionsRequest = { /** The starting point of a route. */ origin: LngLatLike; /** The ending point of a route. */ destination: LngLatLike; /** Coordinates along the route between the Origin and the Destination. */ waypoints?: LngLatLike[]; /** A parameter which which sets the transportation mode for the route. PS: Only the 4w/car profile is enabled by default. The other customised routing profiles are only supported in Premium plan. */ mode?: TravelMode | string; /** The steps flag determines whether to return the individual maneuver instructions that comprise the route in the response. */ steps?: boolean; /** This parameter sets the departure time in Unix epoch time seconds format. Unit: seconds. PS: This parameter is only supported in Premium plan. */ departureTime?: number; /** Unique session ID. If set, the response will reuse cached trip characteristics. PS: This parameter is only supported in Premium plan. */ session?: string; /** Sets the output format of the route geometry in the response. Default: GeometryType.POLYLINE6. */ geometry?: GeometryType; /** If enabled, the API will return alternative routes. You can set the number of routes in the altcount property. */ alternatives?: boolean; /** Sets the number of alternative routes to return. Default: 3. */ altCount?: number; /** Setting this will ensure the route avoids ferry, tolls or highways. */ avoid?: AvoidType[]; /** Output verbosity of overview (whole trip) geometry. Default: full. */ overview?: OverviewType; /** A list indicating the side of the road from which to approach waypoints in a requested route. If provided, the number of approaches must be one more than the number of waypoints. */ approaches?: ApproachType[]; /** Use this option to switch to 6w or truck specific routing. Using this option enables specific settings available only for truck based routing. Accepts `flexible`. */ option?: string; /** * api key for the request */ apiKey?: string; /** * This defines the dimensions of a truck in centimeters (cm). This parameter is effective only when the mode=truck. Maximum dimensions are as follows: * Height = 1000 cm * Width = 5000 cm * Length = 5000 cm */ truckSize?: number[]; /** * This defines the weight of the truck in kilograms (kg). This parameter is effective only when the mode=`truck`. Maximum weight is 100000 kg. */ truckWeight?: number; /** Set the route type that needs to be returned. */ routeType?: DirectionsRouteType; /** Use this parameter to receive segment-wise maximum speed information of the route in the response. `max_speed is` the only allowed value. */ roadInfo?: DirectionsRoadInfo[]; /** * Specify if crossing an international border is expected. When set to false, the API will place a penalty for crossing an international border through a checkpoint. Consequently, alternative routes will be preferred if they are feasible for the given set of `destination` or `waypoints` . A higher penalty is placed on a route crossing international border without a checkpoint, hence such routes will be preferred the least. * * When set to true, there will be no penalty for crossing an international border. * * This feature is available in North America and Singapore region only. Please get in touch with support@nextbillion.ai to enquire/enable other areas. */ crossBorder?: boolean; /** * Specify the total load per axle (including the weight of trailers and shipped goods) of the truck, in tonnes. When used, the service will return routes which are legally allowed to carry the load specified per axle. * * Please note this parameter is effective only when `mode=truck`. */ truckAxleLoad?: number; /** * Specify the type of hazardous material being carried and the service will avoid roads which are not suitable for the type of goods specified. * * Allowed Values: general circumstantial explosive harmfulToWater * * Please note that this parameter is effective only when `mode=truck`. */ hazmatType?: DirectionsHazmatType[]; }; /** * The directions response retrieved from the directions server. */ export type DirectionsResult = { country_code?: string; /** A string indicating the state of the response. This is a separate code than the HTTP status code. On normal valid responses, the value will be Ok. */ status: NBRequestStatus | string; /** error message if status is not 200. */ msg?: string; /** routes calculated. */ routes?: Array; }; /** * @interface DirectionsResponseRoute * The route information returned by the directions service. */ export interface DirectionsResponseRoute { distance: number; distance_full?: number; raw_duration?: number; duration: number; predicted_duration?: number; /** encoded geometry value for step in polyline or polyline6. */ geometry?: string; start_location?: { latitude: number; longitude: number; }; end_location?: { latitude: number; longitude: number; }; geojson?: { coordinates: Array>; }; legs: Array; special_objects?: any; } /** * @interface DirectionsResponseLeg * The leg information in the route. */ export interface DirectionsResponseLeg { distance: { value: number; }; raw_duration?: { value: number; }; duration: { value: number; }; start_location?: { latitude: number; longitude: number; }; end_location?: { latitude: number; longitude: number; }; steps: Array; } /** * @interface DirectionsResponseLegStep * The step information in the leg. */ export interface DirectionsResponseLegStep { name?: string; reference?: string; geometry?: string; distance: { value: number; }; geojson?: { coordinates: Array>; }; intersections?: Array; maneuver?: StepManeuver; duration: { value: number; }; start_location: { latitude: number; longitude: number; }; end_location: { latitude: number; longitude: number; }; } /** * A service for calculating directions between locations. * Can be accessed by `nextbillion.maps.DirectionsService` if you load SDK by CDN url. */ export declare class DirectionsService { /** * Request directions between an origin and a destination. * @param opt request options * @returns directions result of the request */ route(opt: DirectionsRequest): Promise; } //# sourceMappingURL=directions.d.ts.map