UNPKG

azure-maps-rest

Version:

SDK for Azure Maps REST Services

1,013 lines (971 loc) 544 kB
import * as msRest from "@azure/ms-rest-js"; import { AzureServiceClientOptions } from "@azure/ms-rest-azure-js"; import * as GeoJSON from "geojson"; declare namespace atlas { interface AuthenticationManager { initialize(): Promise<void>; signRequest(params: RequestParameters): RequestParameters; } /** * This interface partially defines the Azure Map's web control. Web control version 2.0 or later must be used. * For a full definition see https://docs.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.map?view=azure-iot-typescript-latest */ interface Map { readonly authentication: AuthenticationManager; } interface RequestParameters { headers?: object; url?: string; } module service { export type RestError = msRest.RestError; /** * An aborter instance implements AbortSignal interface, can abort HTTP requests. * * - Call Aborter.none to create a new Aborter instance without timeout. * - Call Aborter.timeout() to create a new Aborter instance with timeout. * * For an existing instance aborter: * - Call aborter.withTimeout() to create and return a child Aborter instance with timeout. * - Call aborter.withValue(key, value) to create and return a child Aborter instance with key/value pair. * - Call aborter.abort() to abort current instance and all children instances. * - Call aborter.getValue(key) to search and get value with corresponding key from current aborter to all parents. * * @export * @class Aborter * @implements {AbortSignalLike} */ export class Aborter implements msRest.AbortSignalLike { /** * Status of whether aborted or not. * * @readonly * @type {boolean} * @memberof Aborter */ readonly aborted: boolean; /** * Creates a new Aborter instance without timeout. * * @readonly * @static * @type {Aborter} * @memberof Aborter */ static readonly none: Aborter; /** * Creates a new Aborter instance with timeout in milliseconds. * Set parameter timeout to 0 will not create a timer. * * @static * @param {number} {timeout} in milliseconds * @returns {Aborter} * @memberof Aborter */ static timeout(timeout: number): Aborter; /** * onabort event listener. * * @memberof Aborter */ onabort?: ((ev?: Event) => any); private _aborted; private timer?; private readonly parent?; private readonly children; private readonly abortEventListeners; private readonly key?; private readonly value?; /** * Private constructor for internal usage, creates an instance of Aborter. * * @param {Aborter} [parent] Optional. Parent aborter. * @param {number} [timeout=0] Optional. Timeout before abort in millisecond, 0 means no timeout. * @param {string} [key] Optional. Immutable key in string. * @param {(string | number | boolean | null)} [value] Optional. Immutable value. * @memberof Aborter */ private constructor(); /** * Create and return a new Aborter instance, which will be appended as a child node of current Aborter. * Current Aborter instance becomes parent node of the new instance. When current or parent Aborter node * triggers timeout event, all children node's abort event will be triggered too. * * When timeout parameter (in millisecond) is larger than 0, the abort event will be triggered when timeout. * Otherwise, call abort() method to manually abort. * * @param {number} {timeout} Timeout in millisecond. * @returns {Aborter} The new Aborter instance created. * @memberof Aborter */ withTimeout(timeout: number): Aborter; /** * Create and return a new Aborter instance, which will be appended as a child node of current Aborter. * Current Aborter instance becomes parent node of the new instance. When current or parent Aborter node * triggers timeout event, all children nodes abort event will be triggered too. * * Immutable key value pair will be set into the new created Aborter instance. * Call getValue() to find out latest value with corresponding key in the chain of * [current node] -> [parent node] and [grand parent node].... * * @param {string} key * @param {(string | number | boolean | null)} [value] * @returns {Aborter} * @memberof Aborter */ withValue(key: string, value?: string | number | boolean | null): Aborter; /** * Find out latest value with corresponding key in the chain of * [current node] -> [parent node] -> [grand parent node] -> ... -> [root node]. * * If key is not found, undefined will be returned. * * @param {string} key * @returns {(string | number | boolean | null | undefined)} * @memberof Aborter */ getValue(key: string): string | number | boolean | null | undefined; /** * Trigger abort event immediately, the onabort and all abort event listeners will be triggered. * Will try to trigger abort event for all children Aborter nodes. * * - If there is a timeout, the timer will be cancelled. * - If aborted is true, nothing will happen. * * @returns * @memberof Aborter */ abort(): void; /** * Added new "abort" event listener, only support "abort" event. * * @param {"abort"} _type Only support "abort" event * @param {(this: AbortSignalLike, ev: any) => any} listener * @memberof Aborter */ addEventListener(_type: "abort", listener: (this: msRest.AbortSignalLike, ev: any) => any): void; /** * Remove "abort" event listener, only support "abort" event. * * @param {"abort"} _type Only support "abort" event * @param {(this: AbortSignalLike, ev: any) => any} listener * @memberof Aborter */ removeEventListener(_type: "abort", listener: (this: msRest.AbortSignalLike, ev: any) => any): void; private cancelByParent; private cancelTimer; } /** * The base interface for a geojson helper extension. */ export interface IBaseGeojson { getFeatures(): GeoJSON.FeatureCollection; } /** * Credential is an abstract class for Azure Maps HTTP requests signing. This * class will host an credentialPolicyCreator factory which generates CredentialPolicy. * * @export * @abstract * @class Credential */ export abstract class Credential implements msRest.RequestPolicyFactory { /** * Creates a RequestPolicy object. * * @param {RequestPolicy} _nextPolicy * @param {RequestPolicyOptions} _options * @returns {RequestPolicy} * @memberof Credential */ create(_nextPolicy: msRest.RequestPolicy, _options: msRest.RequestPolicyOptions): msRest.RequestPolicy; } /** * Credential policy used to sign HTTP(S) requests before sending. This is an * abstract class. * * @export * @abstract * @class CredentialPolicy * @extends {BaseRequestPolicy} */ export abstract class CredentialPolicy extends msRest.BaseRequestPolicy { /** * Sends out request. * * @param {WebResource} request * @returns {Promise<HttpOperationResponse>} * @memberof CredentialPolicy */ sendRequest(request: msRest.WebResource): Promise<msRest.HttpOperationResponse>; /** * Child classes must implement this method with request signing. This method * will be executed in sendRequest(). * * @protected * @abstract * @param {WebResource} request * @returns {WebResource} * @memberof CredentialPolicy */ protected signRequest(request: msRest.WebResource): msRest.WebResource | PromiseLike<msRest.WebResource>; } /** * A factory function that creates a new CredentialPolicy that uses the provided nextPolicy. */ export type CredentialPolicyCreator = (nextPolicy: msRest.RequestPolicy, options: msRest.RequestPolicyOptions) => CredentialPolicy; /** * IRequestLogOptions configures the retry policy's behavior. * * @export * @interface IRequestLogOptions */ export interface IRequestLogOptions { /** * LogWarningIfTryOverThreshold logs a warning if a tried operation takes longer than the specified * duration in ms. Default is 3000ms. * @type {number} * @memberof IRequestLogOptions */ logWarningIfTryOverThreshold: number; } /** * LoggingPolicyFactory is a factory class helping generating LoggingPolicy objects. * * @export * @class LoggingPolicyFactory * @implements {RequestPolicyFactory} */ export class LoggingPolicyFactory implements msRest.RequestPolicyFactory { private readonly loggingOptions?; /** * Creates an instance of LoggingPolicyFactory. * @param {IRequestLogOptions} [loggingOptions] * @memberof LoggingPolicyFactory */ constructor(loggingOptions?: IRequestLogOptions); create(nextPolicy: msRest.RequestPolicy, options: msRest.RequestPolicyOptions): msRest.BaseRequestPolicy; } /** * MapControlCredential for sharing authentication with an `atlas.Map` instance. * * @export * @class MapControlCredential * @extends {Credential} */ export class MapControlCredential extends Credential { /** * An authenticated `atlas.Map` instance. readonly. * * @type {atlas.Map} * @memberof MapControlCredential */ private readonly map; /** * Creates an instance of MapControlCredential. * @param {atlas.Map} map * @memberof MapControlCredential */ constructor(map: atlas.Map); /** * Creates a MapControlCredentialPolicy object. * * @param {RequestPolicy} nextPolicy * @param {RequestPolicyOptions} options * @returns {MapControlCredentialPolicy} * @memberof MapControlCredential */ create(nextPolicy: msRest.RequestPolicy, options: msRest.RequestPolicyOptions): MapControlCredentialPolicy; } /** * MapControlCredentialPolicy is a policy used to sign HTTP requests * with shared authentication from an `atlas.Map` instance. * * @export * @class MapControlCredentialPolicy * @extends {CredentialPolicy} */ export class MapControlCredentialPolicy extends CredentialPolicy { /** * An authenticated `atlas.Map` instance. readonly. * * @type {atlas.Map} * @memberof MapControlCredentialPolicy */ private readonly map; /** * Creates an instance of MapControlCredentialPolicy. * @param {RequestPolicy} nextPolicy * @param {RequestPolicyOptions} options * @param {atlas.Map} map * @memberof MapControlCredentialPolicy */ constructor(nextPolicy: msRest.RequestPolicy, options: msRest.RequestPolicyOptions, map: atlas.Map); /** * Signs request. * * @protected * @param {WebResource} request * @returns {WebResource} * @memberof MapControlCredentialPolicy */ protected signRequest(request: msRest.WebResource): Promise<msRest.WebResource>; } /** * Option interface for MapsURL.newPipeline method. * * @export * @interface INewPipelineOptions */ export interface INewPipelineOptions { retryOptions?: IRetryOptions; logger?: IHttpPipelineLogger; httpClient?: IHttpClient; } /** * Create a new serialization RequestPolicyCreator that will serialized HTTP request bodies as they * pass through the HTTP pipeline. */ export function deserializationPolicy(): RequestPolicyFactory; /** * A MapsURL represents a base URL class for SearchURL, RouteURL and etc. * * @export * @class MapsURL */ export abstract class MapsURL { /** * A static method used to create a new Pipeline object with Credential provided. * * @static * @param {Credential} credential Such as SubscriptionKeyCredential, TokenCredential, and MapControlCredential. * @param {INewPipelineOptions} [pipelineOptions] Optional. Options. * @returns {Pipeline} A new Pipeline object. * @memberof Pipeline */ static newPipeline(credential: Credential, pipelineOptions?: INewPipelineOptions): Pipeline; /** * Base URL string value. * * @type {string} * @memberof MapsURL */ readonly mapsUrl: string; /** * MapsClientContext is a reference to protocol layer operations entry, which is * generated by AutoRest generator. * * @protected * @type {MapsClientContext} * @memberof MapsURL */ protected readonly mapsClientContext: msRest.ServiceClient; /** * Creates an instance of MapsURL. * @param {Pipeline} pipeline * @param {string} mapsUrl * @memberof MapsURL */ protected constructor(pipeline: Pipeline, mapsUrl: string); } /** * A helper extension providing methods for accessing the response data in GeoJSON format. */ export class CarShareGeojson implements IBaseGeojson { /** * @private */ private readonly response; /** * Returns a GeoJSON feature collection built from the results. * The collection will include one Point feature representing the car share vehicle. * The properties of the feature match the properties of the results, except * the `position` property is omitted because it is redundant with the feature's coordinates. */ getFeatures(): GeoJSON.FeatureCollection<GeoJSON.Point>; } /** * A helper extension providing methods for accessing the response data in GeoJSON format. */ export class MetroAreaGeojson implements IBaseGeojson { /** * @private */ private readonly response; /** * Returns a GeoJSON feature collection built from the results. * Each feature in the collection is a Polygon representing one area. * The properties of each feature match the properties of the `MetroAreaResult`, except * the `geometry` property is omitted because it is redundant with the feature's geometry. */ getFeatures(): GeoJSON.FeatureCollection<GeoJSON.Polygon>; } /** * A helper extension providing methods for accessing the response data in GeoJSON format. */ export class NearbyTransitGeojson implements IBaseGeojson { /** * @private */ private readonly response; /** * Returns a GeoJSON feature collection built from the results. * Each feature in the collection is a Point representing one transit object. * The properties of each feature match the properties of the `TransitObjectResult`, except * the `position` property is omitted because it is redundant with the feature's coordinates. */ getFeatures(): GeoJSON.FeatureCollection<GeoJSON.Point>; } /** * A helper extension providing methods for accessing the response data in GeoJSON format. */ export class RealTimeArrivalsGeojson implements IBaseGeojson { /** * @private */ private readonly response; /** * Returns a GeoJSON feature collection built from the results. * Each feature in the collection is a Point representing one arrival. * The properties of each feature match the properties of the `RealTimeArrivalResult`, except * the `position` property of the stop is omitted because it is redundant with the feature's coordinates. */ getFeatures(): GeoJSON.FeatureCollection<GeoJSON.Point>; } /** * A helper extension providing methods for accessing the response data in GeoJSON format. */ export class TransitDockGeojson implements IBaseGeojson { /** * @private */ private readonly response; /** * Returns a GeoJSON feature collection built from the results. * The collection will include one Point feature representing the dock. * The properties of the feature match the properties of the results, except * the `position` property is omitted because it is redundant with the feature's coordinates. */ getFeatures(): GeoJSON.FeatureCollection<GeoJSON.Point>; } /** * A helper extension providing methods for accessing the response data in GeoJSON format. */ export class TransitItineraryGeojson implements IBaseGeojson { /** * @private */ private readonly response; /** * Returns a GeoJSON feature collection built from the itinerary. * Each feature in the collection is a `LineString` representing one leg of the itinerary. * Legs which don't specify start and end positions will be omitted from the collection, * e.g. `"Wait"` or sometimes `"PathWayWalk"`. * If geometry details were requested the LineStrings will follow those geometries. * If geometry details were not requested the LineStrings will directly connect the start and end points of the leg. * The properties of each feature match the properties of the `Leg`, except * the `geometry`, `origin`, and `destination` properties is omitted * because they are redundant with the feature's coordinates. */ getFeatures(): GeoJSON.FeatureCollection<GeoJSON.LineString>; } /** * A helper extension providing methods for accessing the response data in GeoJSON format. */ export class TransitLineGeojson implements IBaseGeojson { /** * @private */ private readonly response; /** * Returns a GeoJSON feature collection built from the results. * If stop details were requested the collection will contain `Point` features representing each stop. * If pattern details were requested the collection will contain `LineString` features representing each pattern. * Features representing stops will have properties matching the `Stop`, except `position` will be omitted. * Features representing patterns will have properties matching the `Pattern`, except geometry will be omitted. */ getFeatures(): GeoJSON.FeatureCollection<GeoJSON.Point | GeoJSON.LineString>; } /** * A helper extension providing methods for accessing the response data in GeoJSON format. */ export class TransitStopGeojson implements IBaseGeojson { /** * @private */ private readonly response; /** * Returns a GeoJSON feature collection built from the results. * The collection will include one Point feature representing the `Stop`. * The properties of the feature match the properties of the results, except * the `position` property of the stop is omitted because it is redundant with the feature's coordinates. */ getFeatures(): GeoJSON.FeatureCollection<GeoJSON.Point>; } // Responses export type GetCarShareInfoResponse = Response<Models.CarShareResponse, Models.MobilityGetCarShareInfoPreviewResponse, CarShareGeojson>; export type GetMetroAreaResponse = Response<Models.MetroAreaResponse, Models.MobilityGetMetroAreaPreviewResponse, MetroAreaGeojson>; export type GetMetroAreaInfoResponse = Response<Models.MetroAreaInfoResponse, Models.MobilityGetMetroAreaInfoPreviewResponse>; export type GetNearbyTransitResponse = Response<Models.NearbyTransitResponse, Models.MobilityGetNearbyTransitPreviewResponse, NearbyTransitGeojson>; export type GetRealTimeArrivalsResponse = Response<Models.RealTimeArrivalsResponse, Models.MobilityGetRealTimeArrivalsPreviewResponse, RealTimeArrivalsGeojson>; export type GetTransitDockInfoResponse = Response<Models.TransitDockInfoResponse, Models.MobilityGetTransitDockInfoPreviewResponse, TransitDockGeojson>; export type GetTransitItineraryResponse = Response<Models.TransitItineraryResponse, Models.MobilityGetTransitItineraryPreviewResponse, TransitItineraryGeojson>; export type GetTransitLineInfoResponse = Response<Models.TransitLineInfoResponse, Models.MobilityGetTransitLineInfoPreviewResponse, TransitLineGeojson>; export type GetTransitRouteResponse = Response<Models.TransitRouteResponse, Models.MobilityGetTransitRoutePreviewResponse>; export type GetTransitStopInfoResponse = Response<Models.TransitStopInfoResponse, Models.MobilityGetTransitStopInfoPreviewResponse, TransitStopGeojson>; // Options export type GetCarShareInfoOptions = Models.MobilityGetCarShareInfoPreviewOptionalParams; export type GetMetroAreaOptions = Models.MobilityGetMetroAreaPreviewOptionalParams; export type GetMetroAreaInfoOptions = Models.MobilityGetMetroAreaInfoPreviewOptionalParams; export type GetNearbyTransitOptions = Models.MobilityGetNearbyTransitPreviewOptionalParams; export type GetRealTimeArrivalsOptions = Models.MobilityGetRealTimeArrivalsPreviewOptionalParams; export type GetTransitDockInfoOptions = Models.MobilityGetTransitDockInfoPreviewOptionalParams; export type GetTransitItineraryOptions = Models.MobilityGetTransitItineraryPreviewOptionalParams; export type GetTransitLineInfoOptions = Models.MobilityGetTransitLineInfoPreviewOptionalParams; export type GetTransitRouteOptions = Models.MobilityGetTransitRoutePreviewOptionalParams; export type GetTransitStopInfoOptions = Models.MobilityGetTransitStopInfoPreviewOptionalParams; export type IHttpClient = msRest.HttpClient; export type IHttpPipelineLogger = msRest.HttpPipelineLogger; export type HttpHeaders = msRest.HttpHeaders; export type HttpPipelineLogLevel = msRest.HttpPipelineLogLevel; export type HttpOperationResponse = msRest.HttpOperationResponse export type WebResource = msRest.WebResource; export type BaseRequestPolicy = msRest.BaseRequestPolicy export type RequestPolicyFactory = msRest.RequestPolicyFactory export type RequestPolicy = msRest.RequestPolicy; export type RequestPolicyOptions = msRest.RequestPolicyOptions; /** * Option interface for Pipeline constructor. * * @export * @interface IPipelineOptions */ export interface IPipelineOptions { logger?: IHttpPipelineLogger; HTTPClient?: IHttpClient; } /** * A Pipeline class containing HTTP request policies. * You can create a default Pipeline by calling MapsURL.newPipeline(). * Or you can create a Pipeline with your own policies by the constructor of Pipeline. * Refer to MapsURL.newPipeline() and provided policies as reference before * implementing your customized Pipeline. * * @export * @class Pipeline */ export class Pipeline { readonly factories: msRest.RequestPolicyFactory[]; readonly options: IPipelineOptions; /** * Creates an instance of Pipeline. Customize HTTPClient by implementing IHttpClient interface. * * @param {RequestPolicyFactory[]} factories * @param {IPipelineOptions} [options={}] * @memberof Pipeline */ constructor(factories: RequestPolicyFactory[], options?: IPipelineOptions); /** * Transfer Pipeline object to ServiceClientOptions object which required by * ServiceClient constructor. * * @returns {ServiceClientOptions} * @memberof Pipeline */ toServiceClientOptions(): msRest.ServiceClientOptions; } // Responses export type GetMapImageryTileResponse = Response<Uint8Array, Models.RenderGetMapImageryTileResponse>; export type GetMapTileResponse = Response<Uint8Array, Models.RenderGetMapTileResponse>; export type GetMapImageResponse = Response<Uint8Array, Models.RenderGetMapImageResponse>; // Options export type GetMapImageOptions = Merge<Models.RenderGetMapImageOptionalParams, { center?: GeoJSON.Position; bbox?: GeoJSON.BBox; }>; export type GetMapTileOptions = Models.RenderGetMapTileOptionalParams; /** * A RenderURL represents a URL to the Azure Maps render operations. * * @export * @class RenderURL * @extends {MapsURL} */ export class RenderURL extends MapsURL { /** * renderContext provided by protocol layer. * * @private * @type {Render} * @memberof RenderURL */ private renderContext; /** * Creates an instance of RenderURL. * @param {Pipeline} pipeline Call MapsURL.newPipeline() to create a default * pipeline, or provide a customized pipeline. * @param {string} mapsUrl A URL string pointing to Azure Maps service, default is * `"https://atlas.microsoft.com"`. * If no protocol is specified, e.g. `"atlas.microsoft.com"`, then `https` will be assumed. * @memberof RenderURL */ constructor(pipeline: Pipeline, mapsUrl?: string); /** * Returns a map image tile with size 256x256, given the x and y coordinates and zoom * level. Zoom level ranges from 0 to 18. The current available style value is 'satellite' which * provides satellite * imagery alone. * * Uses the Get Map Imagery Tile API: https://docs.microsoft.com/rest/api/maps/render/getmapimagerytile * * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation. * @param {number} zoom Zoom level for the desired tile. Zoom value must be in the range: 0-18 (inclusive). * * Please see [Zoom Levels and Tile * Grid](https://docs.microsoft.com/en-us/azure/location-based-services/zoom-levels-and-tile-grid) * for details. * @param {number} xTileIndex X coordinate of the tile on zoom grid. Value must be in the range [0, * 2<sup>`zoom`</sup> -1]. * * Please see [Zoom Levels and Tile * Grid](https://docs.microsoft.com/en-us/azure/location-based-services/zoom-levels-and-tile-grid) * for details. * @param {number} yTileIndex Y coordinate of the tile on zoom grid. Value must be in the range [0, * 2<sup>`zoom`</sup> -1]. * * Please see [Zoom Levels and Tile * Grid](https://docs.microsoft.com/en-us/azure/location-based-services/zoom-levels-and-tile-grid) * for details. * @returns {Promise<GetMapImageryTileResponse>} */ getMapImageryTile(aborter: Aborter, zoom: number, xTileIndex: number, yTileIndex: number): Promise<GetMapImageryTileResponse>; /** * Returns a map tiles in vector or raster format typically to be integrated into a new map control * or SDK. By default, Azure uses vector map tiles for its web map control (see [Zoom Levels and * Tile * Grid](https://docs.microsoft.com/en-us/azure/location-based-services/zoom-levels-and-tile-grid)) * * Uses the Get Map Tile API: https://docs.microsoft.com/rest/api/maps/render/getmaptile * * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation. * @param {Models.TileFormat} format Desired format of the response. Possible values are png & pbf. Possible values * include: 'png', 'pbf' * @param {Models.MapTileLayer} layer Map layer requested. Possible values are basic, hybrid, labels and terra. Possible * values include: 'basic', 'hybrid', 'labels', 'terra' * @param {Models.MapTileStyle} style Map style to be returned. Possible values are main & shaded_relief. Possible values * include: 'main', 'shaded_relief' * @param {number} zoom Zoom level for the desired tile. For _raster_ tiles, value must be in the range: * 0-18 (inclusive). Terra raster tiles, values must be in the range 0-6 (inclusive). For _vector_ * tiles, value must be in the range: 0-22 (inclusive). * * Please see [Zoom Levels and Tile * Grid](https://docs.microsoft.com/en-us/azure/location-based-services/zoom-levels-and-tile-grid) * for details. * @param {number} xTileIndex X coordinate of the tile on zoom grid. Value must be in the range [0, * 2<sup>`zoom`</sup> -1]. * * Please see [Zoom Levels and Tile * Grid](https://docs.microsoft.com/en-us/azure/location-based-services/zoom-levels-and-tile-grid) * for details. * @param {number} yTileIndex Y coordinate of the tile on zoom grid. Value must be in the range [0, * 2<sup>`zoom`</sup> -1]. * * Please see [Zoom Levels and Tile * Grid](https://docs.microsoft.com/en-us/azure/location-based-services/zoom-levels-and-tile-grid) * for details. * @param {GetMapTileOptions} [options] The optional parameters * @returns {Promise<GetMapTileResponse>} */ getMapTile(aborter: Aborter, format: Models.TileFormat, layer: Models.MapTileLayer, style: Models.MapTileStyle, zoom: number, xTileIndex: number, yTileIndex: number, options?: GetMapTileOptions): Promise<GetMapTileResponse>; /** * Renders a user-defined, rectangular image containing a map section * using a zoom level from 0 to 20. The static image service renders a user-defined, rectangular * image containing a map section using a zoom level from 0 to 20. The supported resolution range * for the map image is from 1x1 to 8192x8192. If you are deciding when to use the static image * service over the map tile service, you may want to consider how you would like to interact with * the rendered map. If the map contents will be relatively unchanging, a static map is a good * choice. If you want to support a lot of zooming, panning and changing of the map content, the * map tile service would be a better choice. * * Service also provides Image Composition functionality to get a static image back with additional * data like; pushpins and geometry overlays with following S0 and S1 capabilities. * * In S0 you can: * - Render up to 5 pushpins specified in the request * - Provide one custom image for the pins referenced in the request * - Add labels to the pushpins * * In S1 you can: * - Render pushpins through [Azure Maps Data Service](https://aka.ms/AzureMapsMapDataService) * - Specify multiple pushpin styles * - Provide custom pushpin images stored in [Azure Maps Data * Service](https://aka.ms/AzureMapsMapDataService) * - Render circle, polyline and polygon geometry types. * - Render of supported GeoJSON geometry types uploaded through [Azure Maps Data * Service](https://aka.ms/AzureMapsMapDataService) * * Please see [How-to-Guide](https://aka.ms/AzureMapsHowToGuideImageCompositor) for detailed * examples. * * _Note_ : Either **center** or **bbox** parameter must be supplied to the * API. * <br><br> * The supported Lat and Lon ranges when using the **bbox** parameter, are as follows: * <br><br> * * |Zoom Level | Max Lon Range | Max Lat Range| * |:----------|:----------------|:-------------| * |0 | 360.0 | 170.0 | * |1 | 360.0 | 170.0 | * |2 | 360.0 | 170.0 | * |3 | 360.0 | 170.0 | * |4 | 360.0 | 170.0 | * |5 | 180.0 | 85.0 | * |6 | 90.0 | 42.5 | * |7 | 45.0 | 21.25 | * |8 | 22.5 | 10.625 | * |9 | 11.25 | 5.3125 | * |10 | 5.625 | 2.62625 | * |11 | 2.8125 | 1.328125 | * |12 | 1.40625 | 0.6640625 | * |13 | 0.703125 | 0.33203125 | * |14 | 0.3515625 | 0.166015625 | * |15 | 0.17578125 | 0.0830078125 | * |16 | 0.087890625 | 0.0415039063 | * |17 | 0.0439453125 | 0.0207519531 | * |18 | 0.0219726563 | 0.0103759766 | * |19 | 0.0109863281 | 0.0051879883 | * |20 | 0.0054931641 | 0.0025939941 | * * Uses the Get Map Image API: https://docs.microsoft.com/rest/api/maps/render/getmapimage * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation. * @param {GetMapImageOptions} [options] The options * @returns {Promise<GetMapImageResponse>} */ getMapImage(aborter: Aborter, options: GetMapImageOptions): Promise<GetMapImageResponse>; /** Converts a GeoJSON center position to a string which can be used as a query param. */ private centerToString; /** Converts a GeoJSON bbox to a string which can be used as a query param. */ private bboxToString; } /** * RetryPolicy types. * * @export * @enum {number} */ export enum RetryPolicyType { /** * Exponential retry. Retry time delay grows exponentially. * Literal value `"exponential"` */ EXPONENTIAL = "exponential", /** * Linear retry. Retry time delay grows linearly. * Literal value `"fixed"` */ FIXED = "fixed" } /** * Retry options interface. * * @export * @interface IRetryOptions */ export interface IRetryOptions { /** * Optional. RetryPolicyType, default is exponential retry policy. * * @type {RetryPolicyType} * @memberof RetryOptions */ readonly retryPolicyType?: RetryPolicyType; /** * Optional. Max try number of attempts, default is 4. * A value of 1 means 1 try and no retries. * A value smaller than 1 means default retry number of attempts. * * @type {number} * @memberof IRetryOptions */ readonly maxTries?: number; /** * Optional. Specifies the amount of delay to use before retrying an operation (default is 4s or 4 * 1000ms). * The delay increases (exponentially or linearly) with each retry up to a maximum specified by * maxRetryDelayInMs. If you specify 0, then you must also specify 0 for maxRetryDelayInMs. * * @type {number} * @memberof IRetryOptions */ readonly retryDelayInMs?: number; /** * Optional. Specifies the maximum delay allowed before retrying an operation (default is 120s or 120 * 1000ms). * If you specify 0, then you must also specify 0 for retryDelayInMs. * * @type {number} * @memberof IRetryOptions */ readonly maxRetryDelayInMs?: number; } /** * RetryPolicyFactory is a factory class helping generating RetryPolicy objects. * * @export * @class RetryPolicyFactory * @implements {RequestPolicyFactory} */ export class RetryPolicyFactory implements msRest.RequestPolicyFactory { private retryOptions?; /** * Creates an instance of RetryPolicyFactory. * @param {IRetryOptions} [retryOptions] * @memberof RetryPolicyFactory */ constructor(retryOptions?: IRetryOptions); create(nextPolicy: msRest.RequestPolicy, options: msRest.RequestPolicyOptions): msRest.BaseRequestPolicy; } /** * A helper extension providing methods for accessing the response data in GeoJSON format. */ export class RouteGeojson implements IBaseGeojson { /** * @private */ private readonly response; /** * Returns a GeoJSON feature collection built from the routes. * Each feature in the collection is a MultiLineString representing one route. * The MultiLineString contains LineStrings representing a leg of the route. * The properties of each feature match the properties of the `route`, except * the `legs` property is replaced by a `legSummaries` property which is an array * of the summaries of each leg. The coordinates of each leg are already part * of the MultiLineString's coordinates. Each feature's properties also includes * a resultIndex. The resultIndex is the index of the route within the original `routes` array. */ getFeatures(): GeoJSON.FeatureCollection<GeoJSON.MultiLineString>; } /** * A helper extension providing methods for accessing the response data in GeoJSON format. */ export class RouteRangeGeojson implements IBaseGeojson { /** * @private */ private readonly response; /** * Returns a GeoJSON feature collection built from the reachable range. * The first feature in the collection is a Polygon representing the boundary of the reachable range. * The second feature is a Point representing the center point of the reachable range. */ getFeatures(): GeoJSON.FeatureCollection<GeoJSON.Polygon | GeoJSON.Point>; } // Responses export type CalculateRouteDirectionsResponse = Response<Models.RouteDirectionsResponse, Models.RouteGetRouteDirectionsResponse, RouteGeojson>; export type CalculateRouteRangeResponse = Response<Models.RouteRangeResponse, Models.RouteGetRouteRangeResponse, RouteRangeGeojson>; export type CalculateRouteMatrixResponse = Response<Models.RouteMatrixResponse, Models.RoutePostRouteMatrixPreviewResponse>; // Options export type CalculateRouteDirectionsOptions = Models.RouteGetRouteDirectionsOptionalParams & { /** * Used for reconstructing a route and for calculating zero or * more alternative routes to this reference route. The provided sequence of coordinates is used * as input for route reconstruction. The alternative routes are calculated between the origin and * destination points specified in the base path parameter locations. If both minDeviationDistance * and minDeviationTime are set to zero, then these origin and destination points are expected to * be at (or very near) the beginning and end of the reference route, respectively. Intermediate * locations (waypoints) are not supported when using supportingPoints. * * Setting at least one of minDeviationDistance or minDeviationTime to a value greater than zero * has the following consequences: * * * The origin point of the calculateRoute request must be on (or very near) the input reference * route. If this is not the case, an error is returned. However, the origin point does not need * to be at the beginning of the input reference route (it can be thought of as the current * vehicle position on the reference route). * * The reference route, returned as the first route in the calculateRoute response, will start * at the origin point specified in the calculateRoute request. The initial part of the input * reference route up until the origin point will be excluded from the response. * * The values of minDeviationDistance and minDeviationTime determine how far alternative routes * will be guaranteed to follow the reference route from the origin point onwards. * * The route must use departAt. * * The vehicleHeading is ignored. */ postBody?: Models.RouteDirectionsRequestBody; }; export type CalculateRouteRangeOptions = Models.RouteGetRouteRangeOptionalParams; export type CalculateRouteMatrixOptions = Models.RoutePostRouteMatrixPreviewOptionalParams; // Bodies export type CalculateRouteMatrixRequestBody = Models.RouteMatrixRequestBody; /** * A RouteURL represents a URL to the Azure Maps route operations. * * @export * @class RouteURL * @extends {MapsURL} */ export class RouteURL extends MapsURL { /** * routeContext provided by protocol layer. * * @private * @type {Route} * @memberof RouteURL */ private routeContext; /** * Creates an instance of RouteURL. * @param {Pipeline} pipeline Call MapsURL.newPipeline() to create a default * pipeline, or provide a customized pipeline. * @param {string} mapsUrl A URL string pointing to Azure Maps service, default is * `"https://atlas.microsoft.com"`. * If no protocol is specified, e.g. `"atlas.microsoft.com"`, then `https` will be assumed. * @memberof RouteURL */ constructor(pipeline: Pipeline, mapsUrl?: string); /** * Returns a route between an origin and a destination, passing through waypoints if they are * specified. The route will take into account factors such as current traffic and the typical road * speeds on the requested day of the week and time of day. * * Information returned includes the distance, estimated travel time, and a representation of the * route geometry. Additional routing information such as optimized waypoint order or turn by turn * instructions is also available, depending on the options selected. * * Routing service provides a set of parameters for a detailed description of vehicle-specific * Consumption Model. Please check [Consumption * Model](https://docs.microsoft.com/azure/azure-maps/consumption-model) for detailed explanation * of the concepts and parameters involved. * * If `options.postBody` is specified uses the Post Route Directions API: https://docs.microsoft.com/rest/api/maps/route/postroutedirections * * Otherwise uses the Get Route Directions API: https://docs.microsoft.com/rest/api/maps/route/getroutedirections * * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation. * @param {GeoJSON.Position[]} coordinates An array of coordinates through which the route is calculated. * Each coordinate is an array of `[longitude, latitude]`. A minimum of two coordinates is required. * The first one is the origin and the last is the destination of the route. * Optional coordinates in-between act as WayPoints in the route. You can pass up to 150 WayPoints. * @param {CalculateRouteDirectionsOptions} [options] * @returns {Promise<CalculateRouteDirectionsResponse>} * @memberof RouteURL */ calculateRouteDirections(aborter: Aborter, coordinates: GeoJSON.Position[], options?: CalculateRouteDirectionsOptions): Promise<CalculateRouteDirectionsResponse>; /** * Calculate a set of locations that can be reached from the origin point based * on fuel, energy, or time budget that is specified. A polygon boundary (or Isochrone) is * returned in a counterclockwise orientation as well as the precise polygon center which was the * result of the origin point. * * The returned polygon can be used for further processing such as [Search Inside * Geometry](https://docs.microsoft.com/rest/api/maps/search/getsearchinsidegeometry) to * search for POIs within the provided Isochrone. * * Uses the Get Route Range API: https://docs.microsoft.com/rest/api/maps/route/getrouterange * * @param {Aborter} aborter Create a new Aborter instance with Aborter.none or Aborter.timeout(), * goto documents of Aborter for more examples about request cancellation. * @param {GeoJSON.Position} center The coordinate from which the range calculation should start. * @param {