@azure-rest/maps-render 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +224 -0
  3. package/dist/index.js +365 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist-esm/src/createMultiCollection.js +13 -0
  6. package/dist-esm/src/createMultiCollection.js.map +1 -0
  7. package/dist-esm/src/createPathQuery.js +97 -0
  8. package/dist-esm/src/createPathQuery.js.map +1 -0
  9. package/dist-esm/src/createPinsQuery.js +74 -0
  10. package/dist-esm/src/createPinsQuery.js.map +1 -0
  11. package/dist-esm/src/generated/clientDefinitions.js +4 -0
  12. package/dist-esm/src/generated/clientDefinitions.js.map +1 -0
  13. package/dist-esm/src/generated/index.js +11 -0
  14. package/dist-esm/src/generated/index.js.map +1 -0
  15. package/dist-esm/src/generated/isUnexpected.js +77 -0
  16. package/dist-esm/src/generated/isUnexpected.js.map +1 -0
  17. package/dist-esm/src/generated/mapsRenderClient.js +25 -0
  18. package/dist-esm/src/generated/mapsRenderClient.js.map +1 -0
  19. package/dist-esm/src/generated/outputModels.js +4 -0
  20. package/dist-esm/src/generated/outputModels.js.map +1 -0
  21. package/dist-esm/src/generated/parameters.js +4 -0
  22. package/dist-esm/src/generated/parameters.js.map +1 -0
  23. package/dist-esm/src/generated/responses.js +4 -0
  24. package/dist-esm/src/generated/responses.js.map +1 -0
  25. package/dist-esm/src/index.js +9 -0
  26. package/dist-esm/src/index.js.map +1 -0
  27. package/dist-esm/src/mapsRender.js +29 -0
  28. package/dist-esm/src/mapsRender.js.map +1 -0
  29. package/dist-esm/src/positionToTileXY.js +44 -0
  30. package/dist-esm/src/positionToTileXY.js.map +1 -0
  31. package/package.json +130 -0
  32. package/review/maps-render.api.md +555 -0
  33. package/types/maps-render-rest.d.ts +1225 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../src/generated/responses.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RawHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { HttpResponse } from \"@azure-rest/core-client\";\nimport {\n ErrorResponseOutput,\n MapTilesetOutput,\n MapAttributionOutput,\n CopyrightCaptionOutput,\n CopyrightOutput\n} from \"./outputModels\";\n\nexport interface RenderGetMapTile200Headers {\n /** The content-type for the response. */\n \"content-type\"?: string;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * The Get Map Tiles API allows users to request map tiles in vector or raster formats typically to be integrated into a map control or SDK. Some example tiles that can be requested are Azure Maps road tiles, real-time Weather Radar tiles or the map tiles created using [Azure Maps Creator](https://aka.ms/amcreator). By default, Azure Maps uses vector tiles for its web map control (Web SDK) and Android SDK.\n */\nexport interface RenderGetMapTile200Response extends HttpResponse {\n status: \"200\";\n /** Value may contain any sequence of octets */\n body: Uint8Array;\n headers: RawHttpHeaders & RenderGetMapTile200Headers;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * The Get Map Tiles API allows users to request map tiles in vector or raster formats typically to be integrated into a map control or SDK. Some example tiles that can be requested are Azure Maps road tiles, real-time Weather Radar tiles or the map tiles created using [Azure Maps Creator](https://aka.ms/amcreator). By default, Azure Maps uses vector tiles for its web map control (Web SDK) and Android SDK.\n */\nexport interface RenderGetMapTileDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * The Get Map Tileset API allows users to request metadata for a tileset.\n */\nexport interface RenderGetMapTileset200Response extends HttpResponse {\n status: \"200\";\n body: MapTilesetOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * The Get Map Tileset API allows users to request metadata for a tileset.\n */\nexport interface RenderGetMapTilesetDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * The Get Map Attribution API allows users to request map copyright attribution information for a section of a tileset.\n */\nexport interface RenderGetMapAttribution200Response extends HttpResponse {\n status: \"200\";\n body: MapAttributionOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * The Get Map Attribution API allows users to request map copyright attribution information for a section of a tileset.\n */\nexport interface RenderGetMapAttributionDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface RenderGetMapStateTile200Headers {\n /** The content-type for the response. */\n \"content-type\"?: string;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Fetches state tiles in vector format typically to be integrated into indoor maps module of map control or SDK. The map control will call this API after user turns on dynamic styling (see [Zoom Levels and Tile Grid](https://docs.microsoft.com/azure/location-based-services/zoom-levels-and-tile-grid))\n */\nexport interface RenderGetMapStateTile200Response extends HttpResponse {\n status: \"200\";\n /** Value may contain any sequence of octets */\n body: Uint8Array;\n headers: RawHttpHeaders & RenderGetMapStateTile200Headers;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Fetches state tiles in vector format typically to be integrated into indoor maps module of map control or SDK. The map control will call this API after user turns on dynamic styling (see [Zoom Levels and Tile Grid](https://docs.microsoft.com/azure/location-based-services/zoom-levels-and-tile-grid))\n */\nexport interface RenderGetMapStateTileDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Copyrights API is designed to serve copyright information for Render Tile\n * service. In addition to basic copyright for the whole map, API is serving\n * specific groups of copyrights for some countries/regions.\n *\n * As an alternative to copyrights for map request, one can receive captions\n * for displaying the map provider information on the map.\n */\nexport interface RenderGetCopyrightCaption200Response extends HttpResponse {\n status: \"200\";\n body: CopyrightCaptionOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Copyrights API is designed to serve copyright information for Render Tile\n * service. In addition to basic copyright for the whole map, API is serving\n * specific groups of copyrights for some countries/regions.\n *\n * As an alternative to copyrights for map request, one can receive captions\n * for displaying the map provider information on the map.\n */\nexport interface RenderGetCopyrightCaptionDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface RenderGetMapStaticImage200Headers {\n /** The content-type for the response. */\n \"content-type\"?: string;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * 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.\n *\n * Service also provides Image Composition functionality to get a static image back with additional data like; pushpins and geometry overlays with following capabilities.\n *\n * - Specify multiple pushpin styles\n * - Render circle, polyline and polygon geometry types.\n *\n * Please see [How-to-Guide](https://aka.ms/AzureMapsHowToGuideImageCompositor) for detailed examples.\n *\n * _Note_ : Either **center** or **bbox** parameter must be supplied to the\n * API.\n * <br><br>\n * The supported Lat and Lon ranges when using the **bbox** parameter, are as follows:\n * <br><br>\n *\n * |Zoom Level | Max Lon Range | Max Lat Range|\n * |:----------|:----------------|:-------------|\n * |0 | 360.0 | 170.0 |\n * |1 | 360.0 | 170.0 |\n * |2 | 360.0 | 170.0 |\n * |3 | 360.0 | 170.0 |\n * |4 | 360.0 | 170.0 |\n * |5 | 180.0 | 85.0 |\n * |6 | 90.0 | 42.5 |\n * |7 | 45.0 | 21.25 |\n * |8 | 22.5 | 10.625 |\n * |9 | 11.25 | 5.3125 |\n * |10 | 5.625 | 2.62625 |\n * |11 | 2.8125 | 1.328125 |\n * |12 | 1.40625 | 0.6640625 |\n * |13 | 0.703125 | 0.33203125 |\n * |14 | 0.3515625 | 0.166015625 |\n * |15 | 0.17578125 | 0.0830078125 |\n * |16 | 0.087890625 | 0.0415039063 |\n * |17 | 0.0439453125 | 0.0207519531 |\n * |18 | 0.0219726563 | 0.0103759766 |\n * |19 | 0.0109863281 | 0.0051879883 |\n * |20 | 0.0054931641 | 0.0025939941 |\n */\nexport interface RenderGetMapStaticImage200Response extends HttpResponse {\n status: \"200\";\n /** Value may contain any sequence of octets */\n body: Uint8Array;\n headers: RawHttpHeaders & RenderGetMapStaticImage200Headers;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * 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.\n *\n * Service also provides Image Composition functionality to get a static image back with additional data like; pushpins and geometry overlays with following capabilities.\n *\n * - Specify multiple pushpin styles\n * - Render circle, polyline and polygon geometry types.\n *\n * Please see [How-to-Guide](https://aka.ms/AzureMapsHowToGuideImageCompositor) for detailed examples.\n *\n * _Note_ : Either **center** or **bbox** parameter must be supplied to the\n * API.\n * <br><br>\n * The supported Lat and Lon ranges when using the **bbox** parameter, are as follows:\n * <br><br>\n *\n * |Zoom Level | Max Lon Range | Max Lat Range|\n * |:----------|:----------------|:-------------|\n * |0 | 360.0 | 170.0 |\n * |1 | 360.0 | 170.0 |\n * |2 | 360.0 | 170.0 |\n * |3 | 360.0 | 170.0 |\n * |4 | 360.0 | 170.0 |\n * |5 | 180.0 | 85.0 |\n * |6 | 90.0 | 42.5 |\n * |7 | 45.0 | 21.25 |\n * |8 | 22.5 | 10.625 |\n * |9 | 11.25 | 5.3125 |\n * |10 | 5.625 | 2.62625 |\n * |11 | 2.8125 | 1.328125 |\n * |12 | 1.40625 | 0.6640625 |\n * |13 | 0.703125 | 0.33203125 |\n * |14 | 0.3515625 | 0.166015625 |\n * |15 | 0.17578125 | 0.0830078125 |\n * |16 | 0.087890625 | 0.0415039063 |\n * |17 | 0.0439453125 | 0.0207519531 |\n * |18 | 0.0219726563 | 0.0103759766 |\n * |19 | 0.0109863281 | 0.0051879883 |\n * |20 | 0.0054931641 | 0.0025939941 |\n */\nexport interface RenderGetMapStaticImageDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Returns copyright information for a given bounding box. Bounding-box requests should specify the minimum and maximum longitude and latitude (EPSG-3857) coordinates\n */\nexport interface RenderGetCopyrightFromBoundingBox200Response\n extends HttpResponse {\n status: \"200\";\n body: CopyrightOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Returns copyright information for a given bounding box. Bounding-box requests should specify the minimum and maximum longitude and latitude (EPSG-3857) coordinates\n */\nexport interface RenderGetCopyrightFromBoundingBoxDefaultResponse\n extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Copyrights API is designed to serve copyright information for Render Tile service. In addition to basic copyright for the whole map, API is serving specific groups of copyrights for some countries/regions.\n * Returns the copyright information for a given tile. To obtain the copyright information for a particular tile, the request should specify the tile's zoom level and x and y coordinates (see: Zoom Levels and Tile Grid).\n */\nexport interface RenderGetCopyrightForTile200Response extends HttpResponse {\n status: \"200\";\n body: CopyrightOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Copyrights API is designed to serve copyright information for Render Tile service. In addition to basic copyright for the whole map, API is serving specific groups of copyrights for some countries/regions.\n * Returns the copyright information for a given tile. To obtain the copyright information for a particular tile, the request should specify the tile's zoom level and x and y coordinates (see: Zoom Levels and Tile Grid).\n */\nexport interface RenderGetCopyrightForTileDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Copyrights API is designed to serve copyright information for Render Tile service. In addition to basic copyright for the whole map, API is serving specific groups of copyrights for some countries/regions.\n * Returns the copyright information for the world. To obtain the default copyright information for the whole world, do not specify a tile or bounding box.\n */\nexport interface RenderGetCopyrightForWorld200Response extends HttpResponse {\n status: \"200\";\n body: CopyrightOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n * Copyrights API is designed to serve copyright information for Render Tile service. In addition to basic copyright for the whole map, API is serving specific groups of copyrights for some countries/regions.\n * Returns the copyright information for the world. To obtain the default copyright information for the whole world, do not specify a tile or bounding box.\n */\nexport interface RenderGetCopyrightForWorldDefaultResponse\n extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import MapsRender from "./mapsRender";
4
+ export * from "./generated";
5
+ export * from "./positionToTileXY";
6
+ export * from "./createPinsQuery";
7
+ export * from "./createPathQuery";
8
+ export default MapsRender;
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,eAAe,UAAU,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport MapsRender from \"./mapsRender\";\n\nexport * from \"./generated\";\nexport * from \"./positionToTileXY\";\nexport * from \"./createPinsQuery\";\nexport * from \"./createPathQuery\";\nexport default MapsRender;\n"]}
@@ -0,0 +1,29 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { isTokenCredential } from "@azure/core-auth";
4
+ import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
5
+ import { createMapsClientIdPolicy } from "@azure/maps-common";
6
+ import createClient from "./generated/mapsRenderClient";
7
+ export default function MapsRender(credential, clientIdOrOptions = {}, maybeOptions = {}) {
8
+ const options = typeof clientIdOrOptions === "string" ? maybeOptions : clientIdOrOptions;
9
+ /**
10
+ * maps service requires a header "ms-x-client-id", which is different from the standard AAD.
11
+ * So we need to do our own implementation.
12
+ * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication
13
+ */
14
+ if (isTokenCredential(credential)) {
15
+ const clientId = typeof clientIdOrOptions === "string" ? clientIdOrOptions : "";
16
+ if (!clientId) {
17
+ throw Error("Client id is needed for TokenCredential");
18
+ }
19
+ const client = createClient(undefined, options);
20
+ client.pipeline.addPolicy(bearerTokenAuthenticationPolicy({
21
+ credential,
22
+ scopes: `${options.baseUrl || "https://atlas.microsoft.com"}/.default`,
23
+ }));
24
+ client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));
25
+ return client;
26
+ }
27
+ return createClient(credential, options);
28
+ }
29
+ //# sourceMappingURL=mapsRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapsRender.js","sourceRoot":"","sources":["../../src/mapsRender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAsB,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,8BAA8B,CAAC;AAyCxD,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,UAAgD,EAChD,oBAA4C,EAAE,EAC9C,eAA8B,EAAE;IAEhC,MAAM,OAAO,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAEzF;;;;OAIG;IACH,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE;QACjC,MAAM,QAAQ,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,KAAK,CAAC,yCAAyC,CAAC,CAAC;SACxD;QACD,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,CACvB,+BAA+B,CAAC;YAC9B,UAAU;YACV,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,6BAA6B,WAAW;SACvE,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC;KACf;IACD,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientOptions } from \"@azure-rest/core-client\";\nimport { AzureKeyCredential, isTokenCredential, TokenCredential } from \"@azure/core-auth\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport { MapsRenderClient } from \"./generated\";\nimport createClient from \"./generated/mapsRenderClient\";\n\n/**\n * Creates an instance of MapsRenderClient from a subscription key.\n *\n * @example\n * ```ts\n * import MapsRender from \"@azure-rest/maps-Render\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsRender(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Render Client\n */\nexport default function MapsRender(\n credential: AzureKeyCredential,\n options?: ClientOptions\n): MapsRenderClient;\n/**\n * Creates an instance of MapsRender from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts\n * import MapsRenderClient from \"@azure-rest/maps-render\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsRender(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the Render Client\n */\nexport default function MapsRender(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions\n): MapsRenderClient;\nexport default function MapsRender(\n credential: TokenCredential | AzureKeyCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {}\n): MapsRenderClient {\n const options = typeof clientIdOrOptions === \"string\" ? maybeOptions : clientIdOrOptions;\n\n /**\n * maps service requires a header \"ms-x-client-id\", which is different from the standard AAD.\n * So we need to do our own implementation.\n * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication\n */\n if (isTokenCredential(credential)) {\n const clientId = typeof clientIdOrOptions === \"string\" ? clientIdOrOptions : \"\";\n if (!clientId) {\n throw Error(\"Client id is needed for TokenCredential\");\n }\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: `${options.baseUrl || \"https://atlas.microsoft.com\"}/.default`,\n })\n );\n client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));\n return client;\n }\n return createClient(credential, options);\n}\n"]}
@@ -0,0 +1,44 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ function clip(n, minValue, maxValue) {
4
+ return Math.min(Math.max(n, minValue), maxValue);
5
+ }
6
+ const MIN_LATITUDE = -85.05112878;
7
+ const MAX_LATITUDE = 85.05112878;
8
+ const MIN_LONGITUDE = -180;
9
+ const MAX_LONGITUDE = 180;
10
+ /**
11
+ * Calculates the XY tile coordinates that a coordinate falls into for a specific zoom level.
12
+ * Reference: https://learn.microsoft.com/en-us/azure/azure-maps/zoom-levels-and-tile-grid?tabs=typescript#tile-math-source-code
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const zoom = 6;
17
+ * const { x, y } = positionToTileXY([47.61559, -122.33817], 6, "256");
18
+ * const response = await client
19
+ * .path("/map/tile")
20
+ * .get({
21
+ * queryParameters: { tilesetId: "microsoft.base.road", zoom, x, y },
22
+ * })
23
+ * ```
24
+ *
25
+ * @param position - Position coordinate in the format [latitude, longitude].
26
+ * @param zoom - Zoom level.
27
+ * @param tileSize - The size of the tiles in the tile pyramid.
28
+ * @returns Tile XY coordinates.
29
+ */
30
+ export function positionToTileXY(position, zoom, tileSize) {
31
+ const latitude = clip(position[0], MIN_LATITUDE, MAX_LATITUDE);
32
+ const longitude = clip(position[1], MIN_LONGITUDE, MAX_LONGITUDE);
33
+ const x = (longitude + 180) / 360;
34
+ const sinLatitude = Math.sin((latitude * Math.PI) / 180);
35
+ const y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
36
+ const tileSizeInNum = parseInt(tileSize);
37
+ // tileSize needed in calculations as in rare cases the multiplying/rounding/dividing can make the difference of a pixel which can result in a completely different tile.
38
+ const mapSize = Math.ceil(tileSizeInNum * Math.pow(2, zoom));
39
+ return {
40
+ x: Math.floor(clip(x * mapSize + 0.5, 0, mapSize - 1) / tileSizeInNum),
41
+ y: Math.floor(clip(y * mapSize + 0.5, 0, mapSize - 1) / tileSizeInNum),
42
+ };
43
+ }
44
+ //# sourceMappingURL=positionToTileXY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positionToTileXY.js","sourceRoot":"","sources":["../../src/positionToTileXY.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,SAAS,IAAI,CAAC,CAAS,EAAE,QAAgB,EAAE,QAAgB;IACzD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,WAAW,CAAC;AAClC,MAAM,YAAY,GAAG,WAAW,CAAC;AACjC,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC;AAC3B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAgB,EAChB,IAAY,EACZ,QAAuB;IAEvB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;IAElE,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IAClC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;IACzD,MAAM,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IAEhF,MAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzC,yKAAyK;IACzK,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IAE7D,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,GAAG,GAAG,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC;QACtE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,GAAG,GAAG,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC;KACvE,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LatLon } from \"@azure/maps-common\";\n\nfunction clip(n: number, minValue: number, maxValue: number): number {\n return Math.min(Math.max(n, minValue), maxValue);\n}\n\nconst MIN_LATITUDE = -85.05112878;\nconst MAX_LATITUDE = 85.05112878;\nconst MIN_LONGITUDE = -180;\nconst MAX_LONGITUDE = 180;\n/**\n * Calculates the XY tile coordinates that a coordinate falls into for a specific zoom level.\n * Reference: https://learn.microsoft.com/en-us/azure/azure-maps/zoom-levels-and-tile-grid?tabs=typescript#tile-math-source-code\n *\n * @example\n * ```ts\n * const zoom = 6;\n * const { x, y } = positionToTileXY([47.61559, -122.33817], 6, \"256\");\n * const response = await client\n * .path(\"/map/tile\")\n * .get({\n * queryParameters: { tilesetId: \"microsoft.base.road\", zoom, x, y },\n * })\n * ```\n *\n * @param position - Position coordinate in the format [latitude, longitude].\n * @param zoom - Zoom level.\n * @param tileSize - The size of the tiles in the tile pyramid.\n * @returns Tile XY coordinates.\n */\nexport function positionToTileXY(\n position: LatLon,\n zoom: number,\n tileSize: \"512\" | \"256\"\n): { x: number; y: number } {\n const latitude = clip(position[0], MIN_LATITUDE, MAX_LATITUDE);\n const longitude = clip(position[1], MIN_LONGITUDE, MAX_LONGITUDE);\n\n const x = (longitude + 180) / 360;\n const sinLatitude = Math.sin((latitude * Math.PI) / 180);\n const y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);\n\n const tileSizeInNum = parseInt(tileSize);\n // tileSize needed in calculations as in rare cases the multiplying/rounding/dividing can make the difference of a pixel which can result in a completely different tile.\n const mapSize = Math.ceil(tileSizeInNum * Math.pow(2, zoom));\n\n return {\n x: Math.floor(clip(x * mapSize + 0.5, 0, mapSize - 1) / tileSizeInNum),\n y: Math.floor(clip(y * mapSize + 0.5, 0, mapSize - 1) / tileSizeInNum),\n };\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,130 @@
1
+ {
2
+ "name": "@azure-rest/maps-render",
3
+ "sdk-type": "client",
4
+ "author": "Microsoft Corporation",
5
+ "version": "1.0.0-beta.1",
6
+ "description": "A generated SDK for MapsRenderClient.",
7
+ "keywords": [
8
+ "node",
9
+ "azure",
10
+ "cloud",
11
+ "typescript",
12
+ "browser",
13
+ "isomorphic"
14
+ ],
15
+ "license": "MIT",
16
+ "main": "dist/index.js",
17
+ "module": "./dist-esm/src/index.js",
18
+ "types": "./types/maps-render-rest.d.ts",
19
+ "repository": "github:Azure/azure-sdk-for-js",
20
+ "bugs": {
21
+ "url": "https://github.com/Azure/azure-sdk-for-js/issues"
22
+ },
23
+ "files": [
24
+ "dist/",
25
+ "dist-esm/src/",
26
+ "types/maps-render-rest.d.ts",
27
+ "README.md",
28
+ "LICENSE",
29
+ "review/*"
30
+ ],
31
+ "engines": {
32
+ "node": ">=14.0.0"
33
+ },
34
+ "scripts": {
35
+ "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
36
+ "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
37
+ "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
38
+ "build:samples": "dev-tool samples publish --force",
39
+ "build:test": "tsc -p . && dev-tool run bundle",
40
+ "build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local",
41
+ "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
42
+ "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
43
+ "execute:samples": "dev-tool samples run samples-dev",
44
+ "extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
45
+ "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
46
+ "generate:client": "autorest --typescript swagger/README.md && npm run format",
47
+ "integration-test:browser": "dev-tool run test:browser",
48
+ "integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
49
+ "integration-test": "npm run integration-test:node && npm run integration-test:browser",
50
+ "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
51
+ "lint": "eslint package.json api-extractor.json src test --ext .ts",
52
+ "pack": "npm pack 2>&1",
53
+ "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser",
54
+ "test:node": "npm run clean && npm run build:test && npm run unit-test:node",
55
+ "test": "npm run clean && npm run build:test && npm run unit-test",
56
+ "unit-test": "npm run unit-test:node && npm run unit-test:browser",
57
+ "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
58
+ "unit-test:browser": "dev-tool run test:browser",
59
+ "build": "npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && api-extractor run --local"
60
+ },
61
+ "sideEffects": false,
62
+ "autoPublish": false,
63
+ "dependencies": {
64
+ "@azure/core-auth": "^1.3.0",
65
+ "@azure-rest/core-client": "1.0.0-beta.10",
66
+ "@azure/core-rest-pipeline": "^1.8.0",
67
+ "@azure/maps-common": "^1.0.0-beta.2",
68
+ "tslib": "^2.2.0"
69
+ },
70
+ "devDependencies": {
71
+ "@azure/test-utils": "^1.0.0",
72
+ "@microsoft/api-extractor": "^7.31.1",
73
+ "autorest": "latest",
74
+ "@types/node": "^14.0.0",
75
+ "dotenv": "^8.2.0",
76
+ "eslint": "^8.0.0",
77
+ "mkdirp": "^1.0.4",
78
+ "prettier": "^2.5.1",
79
+ "rimraf": "^3.0.0",
80
+ "source-map-support": "^0.5.9",
81
+ "typescript": "~4.6.0",
82
+ "@azure/dev-tool": "^1.0.0",
83
+ "@azure/eslint-plugin-azure-sdk": "^3.0.0",
84
+ "@azure-tools/test-credential": "^1.0.0",
85
+ "@azure/identity": "^2.0.1",
86
+ "@azure-tools/test-recorder": "^2.0.0",
87
+ "mocha": "^7.1.1",
88
+ "@types/mocha": "^7.0.2",
89
+ "mocha-junit-reporter": "^1.18.0",
90
+ "cross-env": "^7.0.2",
91
+ "@types/chai": "^4.2.8",
92
+ "chai": "^4.2.0",
93
+ "karma-chrome-launcher": "^3.0.0",
94
+ "karma-coverage": "^2.0.0",
95
+ "karma-edge-launcher": "^0.4.2",
96
+ "karma-env-preprocessor": "^0.1.1",
97
+ "karma-firefox-launcher": "^1.1.0",
98
+ "karma-ie-launcher": "^1.0.0",
99
+ "karma-junit-reporter": "^2.0.1",
100
+ "karma-mocha-reporter": "^2.2.5",
101
+ "karma-mocha": "^2.0.1",
102
+ "karma-source-map-support": "~1.4.0",
103
+ "karma-sourcemap-loader": "^0.3.8",
104
+ "karma": "^6.2.0",
105
+ "nyc": "^15.0.0"
106
+ },
107
+ "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-render-rest/README.md",
108
+ "//metadata": {
109
+ "constantPaths": [
110
+ {
111
+ "path": "swagger/README.md",
112
+ "prefix": "package-version"
113
+ }
114
+ ]
115
+ },
116
+ "browser": {
117
+ "./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js"
118
+ },
119
+ "//sampleConfiguration": {
120
+ "productName": "Azure Maps Render",
121
+ "productSlugs": [
122
+ "azure",
123
+ "azure-maps"
124
+ ],
125
+ "requiredResources": {
126
+ "Azure Maps Resource": "https://docs.microsoft.com/azure/azure-maps/how-to-create-template"
127
+ },
128
+ "disableDocsMs": true
129
+ }
130
+ }