@azure-rest/maps-render 2.0.0-beta.2 → 2.0.0-beta.3
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.
- package/CHANGELOG.md +53 -0
- package/dist/browser/createPathQuery.js +1 -1
- package/dist/browser/createPathQuery.js.map +1 -1
- package/dist/browser/generated/isUnexpected.js +5 -6
- package/dist/browser/generated/isUnexpected.js.map +1 -1
- package/dist/browser/generated/mapsRenderClient.js +13 -11
- package/dist/browser/generated/mapsRenderClient.js.map +1 -1
- package/dist/browser/positionToTileXY.d.ts +1 -1
- package/dist/browser/positionToTileXY.js +1 -1
- package/dist/browser/positionToTileXY.js.map +1 -1
- package/dist/commonjs/createPathQuery.js +1 -1
- package/dist/commonjs/createPathQuery.js.map +1 -1
- package/dist/commonjs/generated/isUnexpected.js +5 -6
- package/dist/commonjs/generated/isUnexpected.js.map +1 -1
- package/dist/commonjs/generated/mapsRenderClient.js +13 -11
- package/dist/commonjs/generated/mapsRenderClient.js.map +1 -1
- package/dist/commonjs/positionToTileXY.d.ts +1 -1
- package/dist/commonjs/positionToTileXY.js +1 -1
- package/dist/commonjs/positionToTileXY.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/esm/createPathQuery.js +1 -1
- package/dist/esm/createPathQuery.js.map +1 -1
- package/dist/esm/generated/isUnexpected.js +5 -6
- package/dist/esm/generated/isUnexpected.js.map +1 -1
- package/dist/esm/generated/mapsRenderClient.js +13 -11
- package/dist/esm/generated/mapsRenderClient.js.map +1 -1
- package/dist/esm/positionToTileXY.d.ts +1 -1
- package/dist/esm/positionToTileXY.js +1 -1
- package/dist/esm/positionToTileXY.js.map +1 -1
- package/dist/react-native/createPathQuery.js +1 -1
- package/dist/react-native/createPathQuery.js.map +1 -1
- package/dist/react-native/generated/isUnexpected.js +5 -6
- package/dist/react-native/generated/isUnexpected.js.map +1 -1
- package/dist/react-native/generated/mapsRenderClient.js +13 -11
- package/dist/react-native/generated/mapsRenderClient.js.map +1 -1
- package/dist/react-native/positionToTileXY.d.ts +1 -1
- package/dist/react-native/positionToTileXY.js +1 -1
- package/dist/react-native/positionToTileXY.js.map +1 -1
- package/package.json +39 -46
- package/review/maps-render-node.api.md +564 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Release History
|
|
2
|
+
|
|
3
|
+
## 2.0.0-beta.3 (Unreleased)
|
|
4
|
+
|
|
5
|
+
### Features Added
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
### Bugs Fixed
|
|
10
|
+
|
|
11
|
+
### Other Changes
|
|
12
|
+
|
|
13
|
+
## 2.0.0-beta.2 (2025-03-14)
|
|
14
|
+
|
|
15
|
+
### Bugs Fixed
|
|
16
|
+
|
|
17
|
+
- Fix ESM module file not found.
|
|
18
|
+
|
|
19
|
+
## 2.0.0-beta.1 (2024-12-10)
|
|
20
|
+
|
|
21
|
+
### Features Added
|
|
22
|
+
|
|
23
|
+
- Added support for `trafficLayer` in the `RenderGetMapStaticImage` endpoint, allowing for new traffic visualization options.
|
|
24
|
+
|
|
25
|
+
### Breaking Changes
|
|
26
|
+
|
|
27
|
+
- The API endpoint for `GetMapStaticImage` has been updated. The `format` parameter has been removed from the path, changing the usage from `(path: "/map/static/{format}", format: "png")` to `(path: "/map/static")`.
|
|
28
|
+
- Replaced `layer` and `style` parameters with `tilesetId` in `RenderGetMapStaticImageQueryParamProperties`, which now supports more detailed map and traffic visualization.
|
|
29
|
+
- Marked fields in various interfaces as readonly, which may impact code that previously modified these properties.
|
|
30
|
+
|
|
31
|
+
### Bugs Fixed
|
|
32
|
+
|
|
33
|
+
- Fix the Microsoft Entra ID authentication when providing `baseUrl`.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## 1.0.0-beta.3 (2024-01-09)
|
|
37
|
+
|
|
38
|
+
### Features Added
|
|
39
|
+
|
|
40
|
+
- Support SAS token authentication.
|
|
41
|
+
|
|
42
|
+
## 1.0.0-beta.2 (2023-07-11)
|
|
43
|
+
|
|
44
|
+
### Other Changes
|
|
45
|
+
|
|
46
|
+
- Deprecate tilesetId "microsoft.dem" and "microsoft.dem.contours" per [announcement of the retirement for DEM tiles in Render API](https://azure.microsoft.com/updates/azure-maps-elevation-apis-and-render-v2-dem-tiles-will-be-retired-on-5-may-2023/)
|
|
47
|
+
- Update README.
|
|
48
|
+
|
|
49
|
+
## 1.0.0-beta.1 (2023-01-10)
|
|
50
|
+
|
|
51
|
+
### Features Added
|
|
52
|
+
|
|
53
|
+
- Initial Release
|
|
@@ -105,7 +105,7 @@ export function createPathQuery(paths) {
|
|
|
105
105
|
const pathQueries = paths.map((path) => {
|
|
106
106
|
if (isCircularPath(path)) {
|
|
107
107
|
const { center, radiusInMeters, options } = path;
|
|
108
|
-
return comosePathVal([center],
|
|
108
|
+
return comosePathVal([center], { ...options, radius: radiusInMeters });
|
|
109
109
|
}
|
|
110
110
|
return comosePathVal(path.coordinates, path.options || {});
|
|
111
111
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPathQuery.js","sourceRoot":"","sources":["../../src/createPathQuery.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAwCnE,SAAS,cAAc,CAAC,IAAkC;IACxD,OAAO,QAAQ,IAAI,IAAI,CAAC;AAC1B,CAAC;AAWD,MAAM,YAAY,GAAgD;IAChE,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,iBAAiB,EAAE,IAAI;IACvB,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO,GAAG,IAAI,YAAY,CAAC;AAC7B,CAAC;AAED,SAAS,aAAa,CAAC,WAAqB,EAAE,OAA8B;IAC1E,uC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,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACrC,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YACjD,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IACH,OAAO,qBAAqB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACpD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { LatLon } from \"@azure/maps-common\";\nimport { createMultiCollection } from \"./createMultiCollection.js\";\n\n/**\n * The options that modify the style of a circular path.\n */\nexport interface CircularPathOptions {\n /** The line color of the path. Range from 000000 to FFFFFF. */\n lineColor?: string;\n /** The line opacity of the path. Range from 0 to 1. */\n lineOpacity?: number;\n /** The line width of the line. Should be greater than 0. */\n lineWidthInPixels?: number;\n}\n\n/**\n * The options that modify the style of a polygonal path.\n */\nexport interface PolygonalPathOptions extends CircularPathOptions {\n /** The fill color of the path. This only works if the path is a closed shape like polygon or circle. Range from 000000 to FFFFFF.*/\n fillColor?: string;\n /** The fill color of the path. This only works if the path is a closed shape like polygon or circle. Range from 0 to 1.*/\n fillOpacity?: number;\n}\n\ninterface PathOptionsForRequest extends PolygonalPathOptions {\n radius?: number;\n}\n\n/**\n * Specify a circular path.\n */\nexport interface CircularPath {\n /** The center of the circular path. */\n center: LatLon;\n /** The radius of the circular path. */\n radiusInMeters: number;\n /** The options that modify the style of the circular path. */\n options?: CircularPathOptions;\n}\n\nfunction isCircularPath(path: PolygonalPath | CircularPath): path is CircularPath {\n return \"center\" in path;\n}\n/**\n * Specify a polygonal path.\n */\nexport interface PolygonalPath {\n /** The coordinates of the polygonal path. The identical coordinate in the first & last position construct a closed polygon.*/\n coordinates: LatLon[];\n /** The options that modify the style of the polygonal path. */\n options?: PolygonalPathOptions;\n}\n\nconst optionKeyMap: Record<keyof PathOptionsForRequest, string> = {\n lineColor: \"lc\",\n lineOpacity: \"la\",\n fillColor: \"fc\",\n fillOpacity: \"fa\",\n lineWidthInPixels: \"lw\",\n radius: \"ra\",\n};\n\nfunction isOptionKey(key: any): key is keyof PathOptionsForRequest {\n return key in optionKeyMap;\n}\n\nfunction comosePathVal(coordinates: LatLon[], options: PathOptionsForRequest): string {\n // compose the coordinates query string\n const coordinatesQueryStr = coordinates.map(([lat, lon]) => `${lon} ${lat}`).join(\"|\");\n // compose the options query string\n const optionsQueryStr = Object.entries(options).reduce<string>((queryStr, [key, val]) => {\n if (!isOptionKey(key)) throw Error(`Unknown key ${key}`);\n queryStr += `${queryStr ? \"|\" : \"\"}${optionKeyMap[key]}${val}`;\n return queryStr;\n }, \"\");\n return optionsQueryStr + \"||\" + coordinatesQueryStr;\n}\n\n/**\n * Create a path query string for _get map static image_ request.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreatePathQuery\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsRender, { CircularPath, PolygonalPath, createPathQuery } from \"@azure-rest/maps-render\";\n * import { createWriteStream } from \"node:fs\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsRender(credential, \"<maps-account-client-id>\");\n *\n * const circularPath: CircularPath = {\n * center: [52.4559, 13.228],\n * radiusInMeters: 10000,\n * options: {\n * lineColor: \"000000\",\n * lineOpacity: 0.9,\n * lineWidthInPixels: 2,\n * },\n * };\n *\n * const linearPath: PolygonalPath = {\n * coordinates: [\n * [52.577, 13.35],\n * [52.6, 13.2988],\n * [52.32, 13.2988],\n * ],\n * options: {\n * lineColor: \"000000\",\n * lineOpacity: 0.9,\n * lineWidthInPixels: 2,\n * },\n * };\n *\n * const polygonPath: PolygonalPath = {\n * coordinates: [\n * [52.577, 13.35],\n * [52.6, 13.2988],\n * [52.32, 13.2988],\n * [52.577, 13.35],\n * ],\n * options: {\n * lineColor: \"000000\",\n * lineOpacity: 0.9,\n * lineWidthInPixels: 2,\n * fillColor: \"FFFFFF\",\n * fillOpacity: 0.8,\n * },\n * };\n *\n * const path = createPathQuery([circularPath, linearPath, polygonPath]);\n * // Send the request\n * const response = await client\n * .path(\"/map/static\")\n * .get({\n * queryParameters: {\n * bbox: [13.228, 52.4559, 13.5794, 52.629],\n * path,\n * },\n * })\n * .asNodeStream();\n *\n * // Handle the error.\n * if (!response.body) {\n * throw Error(\"No response body\");\n * }\n *\n * response.body.pipe(createWriteStream(\"path.png\"));\n * ```\n *\n * @param paths - A collection of {@link PolygonalPath} and {@link CircularPath} that you want to draw on the image.\n * @param options - The options for the style of the path. See the possible options in {@link PolygonalPathOptions} and {@link CircularPathOptions}.\n */\nexport function createPathQuery(paths: Array<PolygonalPath | CircularPath>): string {\n const pathQueries = paths.map((path) => {\n if (isCircularPath(path)) {\n const { center, radiusInMeters, options } = path;\n return comosePathVal([center], { ...options, radius: radiusInMeters });\n }\n return comosePathVal(path.coordinates, path.options || {});\n });\n return createMultiCollection(\"path\", pathQueries);\n}\n"]}
|
|
@@ -13,7 +13,7 @@ const responseMap = {
|
|
|
13
13
|
};
|
|
14
14
|
export function isUnexpected(response) {
|
|
15
15
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
16
|
-
const url = new URL(lroOriginal
|
|
16
|
+
const url = new URL(lroOriginal ?? response.request.url);
|
|
17
17
|
const method = response.request.method;
|
|
18
18
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
19
19
|
if (!pathDetails) {
|
|
@@ -22,7 +22,6 @@ export function isUnexpected(response) {
|
|
|
22
22
|
return !pathDetails.includes(response.status);
|
|
23
23
|
}
|
|
24
24
|
function getParametrizedPathSuccess(method, path) {
|
|
25
|
-
var _a, _b, _c, _d;
|
|
26
25
|
const pathParts = path.split("/");
|
|
27
26
|
// Traverse list to match the longest candidate
|
|
28
27
|
// matchedLen: the length of candidate path
|
|
@@ -41,14 +40,14 @@ function getParametrizedPathSuccess(method, path) {
|
|
|
41
40
|
// track if we have found a match to return the values found.
|
|
42
41
|
let found = true;
|
|
43
42
|
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
const start = candidateParts[i].indexOf("}") + 1, end =
|
|
43
|
+
if (candidateParts[i]?.startsWith("{") &&
|
|
44
|
+
candidateParts[i]?.indexOf("}") !== -1) {
|
|
45
|
+
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length;
|
|
47
46
|
// If the current part of the candidate is a "template" part
|
|
48
47
|
// Try to use the suffix of pattern to match the path
|
|
49
48
|
// {guid} ==> $
|
|
50
49
|
// {guid}:export ==> :export$
|
|
51
|
-
const isMatched = new RegExp(`${
|
|
50
|
+
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || "");
|
|
52
51
|
if (!isMatched) {
|
|
53
52
|
found = false;
|
|
54
53
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAuBlC,MAAM,WAAW,GAA6B;IAC5C,eAAe,EAAE,CAAC,KAAK,CAAC;IACxB,kBAAkB,EAAE,CAAC,KAAK,CAAC;IAC3B,sBAAsB,EAAE,CAAC,KAAK,CAAC;IAC/B,oBAAoB,EAAE,CAAC,KAAK,CAAC;IAC7B,qCAAqC,EAAE,CAAC,KAAK,CAAC;IAC9C,iBAAiB,EAAE,CAAC,KAAK,CAAC;IAC1B,sCAAsC,EAAE,CAAC,KAAK,CAAC;IAC/C,kCAAkC,EAAE,CAAC,KAAK,CAAC;IAC3C,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DAA4D;gBAC5D,qDAAqD;gBACrD,eAAe;gBACf,6BAA6B;gBAC7B,MAAM,SAAS,GAAG,IAAI,MAAM,CAC1B,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAC1C,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;gBAE3B,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;gBACR,CAAC;gBACD,SAAS;YACX,CAAC;YAED,8CAA8C;YAC9C,wDAAwD;YACxD,2CAA2C;YAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvC,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM;YACR,CAAC;QACH,CAAC;QAED,qDAAqD;QACrD,sEAAsE;QACtE,IAAI,KAAK,IAAI,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;YAC/C,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,YAAY,GAAG,KAAK,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n RenderGetMapTile200Response,\n RenderGetMapTileDefaultResponse,\n RenderGetMapTileset200Response,\n RenderGetMapTilesetDefaultResponse,\n RenderGetMapAttribution200Response,\n RenderGetMapAttributionDefaultResponse,\n RenderGetMapStateTile200Response,\n RenderGetMapStateTileDefaultResponse,\n RenderGetCopyrightCaption200Response,\n RenderGetCopyrightCaptionDefaultResponse,\n RenderGetMapStaticImage200Response,\n RenderGetMapStaticImageDefaultResponse,\n RenderGetCopyrightFromBoundingBox200Response,\n RenderGetCopyrightFromBoundingBoxDefaultResponse,\n RenderGetCopyrightForTile200Response,\n RenderGetCopyrightForTileDefaultResponse,\n RenderGetCopyrightForWorld200Response,\n RenderGetCopyrightForWorldDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /map/tile\": [\"200\"],\n \"GET /map/tileset\": [\"200\"],\n \"GET /map/attribution\": [\"200\"],\n \"GET /map/statetile\": [\"200\"],\n \"GET /map/copyright/caption/{format}\": [\"200\"],\n \"GET /map/static\": [\"200\"],\n \"GET /map/copyright/bounding/{format}\": [\"200\"],\n \"GET /map/copyright/tile/{format}\": [\"200\"],\n \"GET /map/copyright/world/{format}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: RenderGetMapTile200Response | RenderGetMapTileDefaultResponse,\n): response is RenderGetMapTileDefaultResponse;\nexport function isUnexpected(\n response: RenderGetMapTileset200Response | RenderGetMapTilesetDefaultResponse,\n): response is RenderGetMapTilesetDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetMapAttribution200Response\n | RenderGetMapAttributionDefaultResponse,\n): response is RenderGetMapAttributionDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetMapStateTile200Response\n | RenderGetMapStateTileDefaultResponse,\n): response is RenderGetMapStateTileDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetCopyrightCaption200Response\n | RenderGetCopyrightCaptionDefaultResponse,\n): response is RenderGetCopyrightCaptionDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetMapStaticImage200Response\n | RenderGetMapStaticImageDefaultResponse,\n): response is RenderGetMapStaticImageDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetCopyrightFromBoundingBox200Response\n | RenderGetCopyrightFromBoundingBoxDefaultResponse,\n): response is RenderGetCopyrightFromBoundingBoxDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetCopyrightForTile200Response\n | RenderGetCopyrightForTileDefaultResponse,\n): response is RenderGetCopyrightForTileDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetCopyrightForWorld200Response\n | RenderGetCopyrightForWorldDefaultResponse,\n): response is RenderGetCopyrightForWorldDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetMapTile200Response\n | RenderGetMapTileDefaultResponse\n | RenderGetMapTileset200Response\n | RenderGetMapTilesetDefaultResponse\n | RenderGetMapAttribution200Response\n | RenderGetMapAttributionDefaultResponse\n | RenderGetMapStateTile200Response\n | RenderGetMapStateTileDefaultResponse\n | RenderGetCopyrightCaption200Response\n | RenderGetCopyrightCaptionDefaultResponse\n | RenderGetMapStaticImage200Response\n | RenderGetMapStaticImageDefaultResponse\n | RenderGetCopyrightFromBoundingBox200Response\n | RenderGetCopyrightFromBoundingBoxDefaultResponse\n | RenderGetCopyrightForTile200Response\n | RenderGetCopyrightForTileDefaultResponse\n | RenderGetCopyrightForWorld200Response\n | RenderGetCopyrightForWorldDefaultResponse,\n): response is\n | RenderGetMapTileDefaultResponse\n | RenderGetMapTilesetDefaultResponse\n | RenderGetMapAttributionDefaultResponse\n | RenderGetMapStateTileDefaultResponse\n | RenderGetCopyrightCaptionDefaultResponse\n | RenderGetMapStaticImageDefaultResponse\n | RenderGetCopyrightFromBoundingBoxDefaultResponse\n | RenderGetCopyrightForTileDefaultResponse\n | RenderGetCopyrightForWorldDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (\n let i = candidateParts.length - 1, j = pathParts.length - 1;\n i >= 1 && j >= 1;\n i--, j--\n ) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.indexOf(\"}\") !== -1\n ) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(\n `${candidateParts[i]?.slice(start, end)}`,\n ).test(pathParts[j] || \"\");\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { __rest } from "tslib";
|
|
4
3
|
import { getClient } from "@azure-rest/core-client";
|
|
5
4
|
import { logger } from "./logger.js";
|
|
6
5
|
/**
|
|
@@ -8,21 +7,24 @@ import { logger } from "./logger.js";
|
|
|
8
7
|
* @param credentials - uniquely identify client credential
|
|
9
8
|
* @param options - the parameter for all optional parameters
|
|
10
9
|
*/
|
|
11
|
-
export default function createClient(credentials,
|
|
12
|
-
|
|
13
|
-
var { apiVersion = "2024-04-01" } = _a, options = __rest(_a, ["apiVersion"]);
|
|
14
|
-
const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `https://atlas.microsoft.com`;
|
|
10
|
+
export default function createClient(credentials, { apiVersion = "2024-04-01", ...options } = {}) {
|
|
11
|
+
const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
15
12
|
const userAgentInfo = `azsdk-js-maps-render-rest/2.0.0-beta.1`;
|
|
16
13
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
17
14
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
18
15
|
: `${userAgentInfo}`;
|
|
19
|
-
options =
|
|
16
|
+
options = {
|
|
17
|
+
...options,
|
|
18
|
+
userAgentOptions: {
|
|
20
19
|
userAgentPrefix,
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
},
|
|
21
|
+
loggingOptions: {
|
|
22
|
+
logger: options.loggingOptions?.logger ?? logger.info,
|
|
23
|
+
},
|
|
24
|
+
credentials: {
|
|
25
|
+
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "subscription-key",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
26
28
|
const client = getClient(endpointUrl, credentials, options);
|
|
27
29
|
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
|
|
28
30
|
client.pipeline.addPolicy({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapsRenderClient.js","sourceRoot":"","sources":["../../../src/generated/mapsRenderClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC
|
|
1
|
+
{"version":3,"file":"mapsRenderClient.js","sourceRoot":"","sources":["../../../src/generated/mapsRenderClient.ts"],"names":[],"mappings":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C,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,UAAU,EAAE,CAAC;gBACvD,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger.js\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsRenderClient } from \"./clientDefinitions.js\";\n\n/** The optional parameters for the client */\nexport interface MapsRenderClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `MapsRenderClient`\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n credentials: KeyCredential,\n { apiVersion = \"2024-04-01\", ...options }: MapsRenderClientOptions = {},\n): MapsRenderClient {\n const endpointUrl =\n options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;\n const userAgentInfo = `azsdk-js-maps-render-rest/2.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n apiKeyHeaderName:\n options.credentials?.apiKeyHeaderName ?? \"subscription-key\",\n },\n };\n const client = getClient(\n endpointUrl,\n credentials,\n options,\n ) as MapsRenderClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LatLon } from "@azure/maps-common";
|
|
2
2
|
/**
|
|
3
3
|
* Calculates the XY tile coordinates that a coordinate falls into for a specific zoom level.
|
|
4
|
-
* Reference: https://learn.microsoft.com/
|
|
4
|
+
* Reference: https://learn.microsoft.com/azure/azure-maps/zoom-levels-and-tile-grid?tabs=typescript#tile-math-source-code
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts snippet:ReadmeSampleRequestMapTiles
|
|
@@ -9,7 +9,7 @@ const MIN_LONGITUDE = -180;
|
|
|
9
9
|
const MAX_LONGITUDE = 180;
|
|
10
10
|
/**
|
|
11
11
|
* Calculates the XY tile coordinates that a coordinate falls into for a specific zoom level.
|
|
12
|
-
* Reference: https://learn.microsoft.com/
|
|
12
|
+
* Reference: https://learn.microsoft.com/azure/azure-maps/zoom-levels-and-tile-grid?tabs=typescript#tile-math-source-code
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts snippet:ReadmeSampleRequestMapTiles
|
|
@@ -1 +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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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 type { 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/
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;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 type { 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/azure/azure-maps/zoom-levels-and-tile-grid?tabs=typescript#tile-math-source-code\n *\n * @example\n * ```ts snippet:ReadmeSampleRequestMapTiles\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsRender, { positionToTileXY } from \"@azure-rest/maps-render\";\n * import { createWriteStream } from \"node:fs\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsRender(credential, \"<maps-account-client-id>\");\n *\n * const zoom = 6;\n * // Use the helper function `positionToTileXY` to get the tile index from the coordinate.\n * const { x, y } = positionToTileXY([47.61559, -122.33817], 6, \"256\");\n * const response = await client\n * .path(\"/map/tile\")\n * .get({\n * queryParameters: {\n * tilesetId: \"microsoft.base.road\",\n * zoom,\n * x,\n * y,\n * },\n * })\n * .asNodeStream();\n *\n * // Handle the error.\n * if (!response.body) {\n * throw Error(\"No response body\");\n * }\n *\n * response.body.pipe(createWriteStream(\"tile.png\"));\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"]}
|
|
@@ -108,7 +108,7 @@ function createPathQuery(paths) {
|
|
|
108
108
|
const pathQueries = paths.map((path) => {
|
|
109
109
|
if (isCircularPath(path)) {
|
|
110
110
|
const { center, radiusInMeters, options } = path;
|
|
111
|
-
return comosePathVal([center],
|
|
111
|
+
return comosePathVal([center], { ...options, radius: radiusInMeters });
|
|
112
112
|
}
|
|
113
113
|
return comosePathVal(path.coordinates, path.options || {});
|
|
114
114
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPathQuery.js","sourceRoot":"","sources":["../../src/createPathQuery.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AA2JlC,0CASC;AAjKD,yEAAmE;AAwCnE,SAAS,cAAc,CAAC,IAAkC;IACxD,OAAO,QAAQ,IAAI,IAAI,CAAC;AAC1B,CAAC;AAWD,MAAM,YAAY,GAAgD;IAChE,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,iBAAiB,EAAE,IAAI;IACvB,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO,GAAG,IAAI,YAAY,CAAC;AAC7B,CAAC;AAED,SAAS,aAAa,CAAC,WAAqB,EAAE,OAA8B;IAC1E,uCAAuC;IACvC,MAAM,mBAAmB,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvF,mCAAmC;IACnC,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GA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,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IACH,OAAO,IAAA,gDAAqB,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACpD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { LatLon } from \"@azure/maps-common\";\nimport { createMultiCollection } from \"./createMultiCollection.js\";\n\n/**\n * The options that modify the style of a circular path.\n */\nexport interface CircularPathOptions {\n /** The line color of the path. Range from 000000 to FFFFFF. */\n lineColor?: string;\n /** The line opacity of the path. Range from 0 to 1. */\n lineOpacity?: number;\n /** The line width of the line. Should be greater than 0. */\n lineWidthInPixels?: number;\n}\n\n/**\n * The options that modify the style of a polygonal path.\n */\nexport interface PolygonalPathOptions extends CircularPathOptions {\n /** The fill color of the path. This only works if the path is a closed shape like polygon or circle. Range from 000000 to FFFFFF.*/\n fillColor?: string;\n /** The fill color of the path. This only works if the path is a closed shape like polygon or circle. Range from 0 to 1.*/\n fillOpacity?: number;\n}\n\ninterface PathOptionsForRequest extends PolygonalPathOptions {\n radius?: number;\n}\n\n/**\n * Specify a circular path.\n */\nexport interface CircularPath {\n /** The center of the circular path. */\n center: LatLon;\n /** The radius of the circular path. */\n radiusInMeters: number;\n /** The options that modify the style of the circular path. */\n options?: CircularPathOptions;\n}\n\nfunction isCircularPath(path: PolygonalPath | CircularPath): path is CircularPath {\n return \"center\" in path;\n}\n/**\n * Specify a polygonal path.\n */\nexport interface PolygonalPath {\n /** The coordinates of the polygonal path. The identical coordinate in the first & last position construct a closed polygon.*/\n coordinates: LatLon[];\n /** The options that modify the style of the polygonal path. */\n options?: PolygonalPathOptions;\n}\n\nconst optionKeyMap: Record<keyof PathOptionsForRequest, string> = {\n lineColor: \"lc\",\n lineOpacity: \"la\",\n fillColor: \"fc\",\n fillOpacity: \"fa\",\n lineWidthInPixels: \"lw\",\n radius: \"ra\",\n};\n\nfunction isOptionKey(key: any): key is keyof PathOptionsForRequest {\n return key in optionKeyMap;\n}\n\nfunction comosePathVal(coordinates: LatLon[], options: PathOptionsForRequest): string {\n // compose the coordinates query string\n const coordinatesQueryStr = coordinates.map(([lat, lon]) => `${lon} ${lat}`).join(\"|\");\n // compose the options query string\n const optionsQueryStr = Object.entries(options).reduce<string>((queryStr, [key, val]) => {\n if (!isOptionKey(key)) throw Error(`Unknown key ${key}`);\n queryStr += `${queryStr ? \"|\" : \"\"}${optionKeyMap[key]}${val}`;\n return queryStr;\n }, \"\");\n return optionsQueryStr + \"||\" + coordinatesQueryStr;\n}\n\n/**\n * Create a path query string for _get map static image_ request.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreatePathQuery\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsRender, { CircularPath, PolygonalPath, createPathQuery } from \"@azure-rest/maps-render\";\n * import { createWriteStream } from \"node:fs\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsRender(credential, \"<maps-account-client-id>\");\n *\n * const circularPath: CircularPath = {\n * center: [52.4559, 13.228],\n * radiusInMeters: 10000,\n * options: {\n * lineColor: \"000000\",\n * lineOpacity: 0.9,\n * lineWidthInPixels: 2,\n * },\n * };\n *\n * const linearPath: PolygonalPath = {\n * coordinates: [\n * [52.577, 13.35],\n * [52.6, 13.2988],\n * [52.32, 13.2988],\n * ],\n * options: {\n * lineColor: \"000000\",\n * lineOpacity: 0.9,\n * lineWidthInPixels: 2,\n * },\n * };\n *\n * const polygonPath: PolygonalPath = {\n * coordinates: [\n * [52.577, 13.35],\n * [52.6, 13.2988],\n * [52.32, 13.2988],\n * [52.577, 13.35],\n * ],\n * options: {\n * lineColor: \"000000\",\n * lineOpacity: 0.9,\n * lineWidthInPixels: 2,\n * fillColor: \"FFFFFF\",\n * fillOpacity: 0.8,\n * },\n * };\n *\n * const path = createPathQuery([circularPath, linearPath, polygonPath]);\n * // Send the request\n * const response = await client\n * .path(\"/map/static\")\n * .get({\n * queryParameters: {\n * bbox: [13.228, 52.4559, 13.5794, 52.629],\n * path,\n * },\n * })\n * .asNodeStream();\n *\n * // Handle the error.\n * if (!response.body) {\n * throw Error(\"No response body\");\n * }\n *\n * response.body.pipe(createWriteStream(\"path.png\"));\n * ```\n *\n * @param paths - A collection of {@link PolygonalPath} and {@link CircularPath} that you want to draw on the image.\n * @param options - The options for the style of the path. See the possible options in {@link PolygonalPathOptions} and {@link CircularPathOptions}.\n */\nexport function createPathQuery(paths: Array<PolygonalPath | CircularPath>): string {\n const pathQueries = paths.map((path) => {\n if (isCircularPath(path)) {\n const { center, radiusInMeters, options } = path;\n return comosePathVal([center], { ...options, radius: radiusInMeters });\n }\n return comosePathVal(path.coordinates, path.options || {});\n });\n return createMultiCollection(\"path\", pathQueries);\n}\n"]}
|
|
@@ -16,7 +16,7 @@ const responseMap = {
|
|
|
16
16
|
};
|
|
17
17
|
function isUnexpected(response) {
|
|
18
18
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
19
|
-
const url = new URL(lroOriginal
|
|
19
|
+
const url = new URL(lroOriginal ?? response.request.url);
|
|
20
20
|
const method = response.request.method;
|
|
21
21
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
22
22
|
if (!pathDetails) {
|
|
@@ -25,7 +25,6 @@ function isUnexpected(response) {
|
|
|
25
25
|
return !pathDetails.includes(response.status);
|
|
26
26
|
}
|
|
27
27
|
function getParametrizedPathSuccess(method, path) {
|
|
28
|
-
var _a, _b, _c, _d;
|
|
29
28
|
const pathParts = path.split("/");
|
|
30
29
|
// Traverse list to match the longest candidate
|
|
31
30
|
// matchedLen: the length of candidate path
|
|
@@ -44,14 +43,14 @@ function getParametrizedPathSuccess(method, path) {
|
|
|
44
43
|
// track if we have found a match to return the values found.
|
|
45
44
|
let found = true;
|
|
46
45
|
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
const start = candidateParts[i].indexOf("}") + 1, end =
|
|
46
|
+
if (candidateParts[i]?.startsWith("{") &&
|
|
47
|
+
candidateParts[i]?.indexOf("}") !== -1) {
|
|
48
|
+
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length;
|
|
50
49
|
// If the current part of the candidate is a "template" part
|
|
51
50
|
// Try to use the suffix of pattern to match the path
|
|
52
51
|
// {guid} ==> $
|
|
53
52
|
// {guid}:export ==> :export$
|
|
54
|
-
const isMatched = new RegExp(`${
|
|
53
|
+
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || "");
|
|
55
54
|
if (!isMatched) {
|
|
56
55
|
found = false;
|
|
57
56
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AA4ElC,oCAsCC;AA3FD,MAAM,WAAW,GAA6B;IAC5C,eAAe,EAAE,CAAC,KAAK,CAAC;IACxB,kBAAkB,EAAE,CAAC,KAAK,CAAC;IAC3B,sBAAsB,EAAE,CAAC,KAAK,CAAC;IAC/B,oBAAoB,EAAE,CAAC,KAAK,CAAC;IAC7B,qCAAqC,EAAE,CAAC,KAAK,CAAC;IAC9C,iBAAiB,EAAE,CAAC,KAAK,CAAC;IAC1B,sCAAsC,EAAE,CAAC,KAAK,CAAC;IAC/C,kCAAkC,EAAE,CAAC,KAAK,CAAC;IAC3C,mCAAmC,EAAE,CAAC,KAAK,CAAC;CAC7C,CAAC;AA2CF,SAAgB,YAAY,CAC1B,QAkB6C;IAW7C,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AA4ElC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ACd,MAAM;gBACR,CAAC;gBACD,SAAS;YACX,CAAC;YAED,8CAA8C;YAC9C,wDAAwD;YACxD,2CAA2C;YAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvC,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM;YACR,CAAC;QACH,CAAC;QAED,qDAAqD;QACrD,sEAAsE;QACtE,IAAI,KAAK,IAAI,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;YAC/C,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,YAAY,GAAG,KAAK,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n RenderGetMapTile200Response,\n RenderGetMapTileDefaultResponse,\n RenderGetMapTileset200Response,\n RenderGetMapTilesetDefaultResponse,\n RenderGetMapAttribution200Response,\n RenderGetMapAttributionDefaultResponse,\n RenderGetMapStateTile200Response,\n RenderGetMapStateTileDefaultResponse,\n RenderGetCopyrightCaption200Response,\n RenderGetCopyrightCaptionDefaultResponse,\n RenderGetMapStaticImage200Response,\n RenderGetMapStaticImageDefaultResponse,\n RenderGetCopyrightFromBoundingBox200Response,\n RenderGetCopyrightFromBoundingBoxDefaultResponse,\n RenderGetCopyrightForTile200Response,\n RenderGetCopyrightForTileDefaultResponse,\n RenderGetCopyrightForWorld200Response,\n RenderGetCopyrightForWorldDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /map/tile\": [\"200\"],\n \"GET /map/tileset\": [\"200\"],\n \"GET /map/attribution\": [\"200\"],\n \"GET /map/statetile\": [\"200\"],\n \"GET /map/copyright/caption/{format}\": [\"200\"],\n \"GET /map/static\": [\"200\"],\n \"GET /map/copyright/bounding/{format}\": [\"200\"],\n \"GET /map/copyright/tile/{format}\": [\"200\"],\n \"GET /map/copyright/world/{format}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: RenderGetMapTile200Response | RenderGetMapTileDefaultResponse,\n): response is RenderGetMapTileDefaultResponse;\nexport function isUnexpected(\n response: RenderGetMapTileset200Response | RenderGetMapTilesetDefaultResponse,\n): response is RenderGetMapTilesetDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetMapAttribution200Response\n | RenderGetMapAttributionDefaultResponse,\n): response is RenderGetMapAttributionDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetMapStateTile200Response\n | RenderGetMapStateTileDefaultResponse,\n): response is RenderGetMapStateTileDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetCopyrightCaption200Response\n | RenderGetCopyrightCaptionDefaultResponse,\n): response is RenderGetCopyrightCaptionDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetMapStaticImage200Response\n | RenderGetMapStaticImageDefaultResponse,\n): response is RenderGetMapStaticImageDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetCopyrightFromBoundingBox200Response\n | RenderGetCopyrightFromBoundingBoxDefaultResponse,\n): response is RenderGetCopyrightFromBoundingBoxDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetCopyrightForTile200Response\n | RenderGetCopyrightForTileDefaultResponse,\n): response is RenderGetCopyrightForTileDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetCopyrightForWorld200Response\n | RenderGetCopyrightForWorldDefaultResponse,\n): response is RenderGetCopyrightForWorldDefaultResponse;\nexport function isUnexpected(\n response:\n | RenderGetMapTile200Response\n | RenderGetMapTileDefaultResponse\n | RenderGetMapTileset200Response\n | RenderGetMapTilesetDefaultResponse\n | RenderGetMapAttribution200Response\n | RenderGetMapAttributionDefaultResponse\n | RenderGetMapStateTile200Response\n | RenderGetMapStateTileDefaultResponse\n | RenderGetCopyrightCaption200Response\n | RenderGetCopyrightCaptionDefaultResponse\n | RenderGetMapStaticImage200Response\n | RenderGetMapStaticImageDefaultResponse\n | RenderGetCopyrightFromBoundingBox200Response\n | RenderGetCopyrightFromBoundingBoxDefaultResponse\n | RenderGetCopyrightForTile200Response\n | RenderGetCopyrightForTileDefaultResponse\n | RenderGetCopyrightForWorld200Response\n | RenderGetCopyrightForWorldDefaultResponse,\n): response is\n | RenderGetMapTileDefaultResponse\n | RenderGetMapTilesetDefaultResponse\n | RenderGetMapAttributionDefaultResponse\n | RenderGetMapStateTileDefaultResponse\n | RenderGetCopyrightCaptionDefaultResponse\n | RenderGetMapStaticImageDefaultResponse\n | RenderGetCopyrightFromBoundingBoxDefaultResponse\n | RenderGetCopyrightForTileDefaultResponse\n | RenderGetCopyrightForWorldDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (\n let i = candidateParts.length - 1, j = pathParts.length - 1;\n i >= 1 && j >= 1;\n i--, j--\n ) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.indexOf(\"}\") !== -1\n ) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(\n `${candidateParts[i]?.slice(start, end)}`,\n ).test(pathParts[j] || \"\");\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.default = createClient;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
6
|
const core_client_1 = require("@azure-rest/core-client");
|
|
8
7
|
const logger_js_1 = require("./logger.js");
|
|
9
8
|
/**
|
|
@@ -11,21 +10,24 @@ const logger_js_1 = require("./logger.js");
|
|
|
11
10
|
* @param credentials - uniquely identify client credential
|
|
12
11
|
* @param options - the parameter for all optional parameters
|
|
13
12
|
*/
|
|
14
|
-
function createClient(credentials,
|
|
15
|
-
|
|
16
|
-
var { apiVersion = "2024-04-01" } = _a, options = tslib_1.__rest(_a, ["apiVersion"]);
|
|
17
|
-
const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `https://atlas.microsoft.com`;
|
|
13
|
+
function createClient(credentials, { apiVersion = "2024-04-01", ...options } = {}) {
|
|
14
|
+
const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
18
15
|
const userAgentInfo = `azsdk-js-maps-render-rest/2.0.0-beta.1`;
|
|
19
16
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
20
17
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
21
18
|
: `${userAgentInfo}`;
|
|
22
|
-
options =
|
|
19
|
+
options = {
|
|
20
|
+
...options,
|
|
21
|
+
userAgentOptions: {
|
|
23
22
|
userAgentPrefix,
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
},
|
|
24
|
+
loggingOptions: {
|
|
25
|
+
logger: options.loggingOptions?.logger ?? logger_js_1.logger.info,
|
|
26
|
+
},
|
|
27
|
+
credentials: {
|
|
28
|
+
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "subscription-key",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
29
31
|
const client = (0, core_client_1.getClient)(endpointUrl, credentials, options);
|
|
30
32
|
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
|
|
31
33
|
client.pipeline.addPolicy({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapsRenderClient.js","sourceRoot":"","sources":["../../../src/generated/mapsRenderClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAkBlC,+BAgDC
|
|
1
|
+
{"version":3,"file":"mapsRenderClient.js","sourceRoot":"","sources":["../../../src/generated/mapsRenderClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAkBlC,+BAgDC;AAhED,yDAAmE;AACnE,2CAAqC;AAUrC;;;;GAIG;AACH,SAAwB,YAAY,CAClC,WAA0B,EAC1B,EAAE,UAAU,GAAG,YAAY,EAAE,GAAG,OAAO,KAA8B,EAAE;IAEvE,MAAM,WAAW,GACf,OAAO,CAAC,QAAQ,IAA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zD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger.js\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsRenderClient } from \"./clientDefinitions.js\";\n\n/** The optional parameters for the client */\nexport interface MapsRenderClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `MapsRenderClient`\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n credentials: KeyCredential,\n { apiVersion = \"2024-04-01\", ...options }: MapsRenderClientOptions = {},\n): MapsRenderClient {\n const endpointUrl =\n options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;\n const userAgentInfo = `azsdk-js-maps-render-rest/2.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n apiKeyHeaderName:\n options.credentials?.apiKeyHeaderName ?? \"subscription-key\",\n },\n };\n const client = getClient(\n endpointUrl,\n credentials,\n options,\n ) as MapsRenderClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LatLon } from "@azure/maps-common";
|
|
2
2
|
/**
|
|
3
3
|
* Calculates the XY tile coordinates that a coordinate falls into for a specific zoom level.
|
|
4
|
-
* Reference: https://learn.microsoft.com/
|
|
4
|
+
* Reference: https://learn.microsoft.com/azure/azure-maps/zoom-levels-and-tile-grid?tabs=typescript#tile-math-source-code
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts snippet:ReadmeSampleRequestMapTiles
|
|
@@ -12,7 +12,7 @@ const MIN_LONGITUDE = -180;
|
|
|
12
12
|
const MAX_LONGITUDE = 180;
|
|
13
13
|
/**
|
|
14
14
|
* Calculates the XY tile coordinates that a coordinate falls into for a specific zoom level.
|
|
15
|
-
* Reference: https://learn.microsoft.com/
|
|
15
|
+
* Reference: https://learn.microsoft.com/azure/azure-maps/zoom-levels-and-tile-grid?tabs=typescript#tile-math-source-code
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts snippet:ReadmeSampleRequestMapTiles
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positionToTileXY.js","sourceRoot":"","sources":["../../src/positionToTileXY.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAqDlC,4CAoBC;AArED,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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corporation.\n// Licensed under the MIT License.\n\nimport type { 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/
|
|
1
|
+
{"version":3,"file":"positionToTileXY.js","sourceRoot":"","sources":["../../src/positionToTileXY.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAqDlC,4CAoBC;AArED,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,SAAgB,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 type { 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/azure/azure-maps/zoom-levels-and-tile-grid?tabs=typescript#tile-math-source-code\n *\n * @example\n * ```ts snippet:ReadmeSampleRequestMapTiles\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsRender, { positionToTileXY } from \"@azure-rest/maps-render\";\n * import { createWriteStream } from \"node:fs\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsRender(credential, \"<maps-account-client-id>\");\n *\n * const zoom = 6;\n * // Use the helper function `positionToTileXY` to get the tile index from the coordinate.\n * const { x, y } = positionToTileXY([47.61559, -122.33817], 6, \"256\");\n * const response = await client\n * .path(\"/map/tile\")\n * .get({\n * queryParameters: {\n * tilesetId: \"microsoft.base.road\",\n * zoom,\n * x,\n * y,\n * },\n * })\n * .asNodeStream();\n *\n * // Handle the error.\n * if (!response.body) {\n * throw Error(\"No response body\");\n * }\n *\n * response.body.pipe(createWriteStream(\"tile.png\"));\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"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.52.10"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -105,7 +105,7 @@ export function createPathQuery(paths) {
|
|
|
105
105
|
const pathQueries = paths.map((path) => {
|
|
106
106
|
if (isCircularPath(path)) {
|
|
107
107
|
const { center, radiusInMeters, options } = path;
|
|
108
|
-
return comosePathVal([center],
|
|
108
|
+
return comosePathVal([center], { ...options, radius: radiusInMeters });
|
|
109
109
|
}
|
|
110
110
|
return comosePathVal(path.coordinates, path.options || {});
|
|
111
111
|
});
|