@esri/arcgis-rest-routing 3.4.3 → 4.0.0-beta.4
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/README.md +4 -5
- package/dist/bundled/routing.esm.js +740 -0
- package/dist/bundled/routing.esm.js.map +1 -0
- package/dist/bundled/routing.esm.min.js +12 -0
- package/dist/bundled/routing.esm.min.js.map +1 -0
- package/dist/bundled/routing.umd.js +758 -0
- package/dist/bundled/routing.umd.js.map +1 -0
- package/dist/bundled/routing.umd.min.js +12 -0
- package/dist/bundled/routing.umd.min.js.map +1 -0
- package/dist/{node → cjs}/closestFacility.js +21 -20
- package/dist/cjs/closestFacility.js.map +1 -0
- package/dist/{node → cjs}/helpers.js +11 -11
- package/dist/cjs/helpers.js.map +1 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/{node → cjs}/originDestinationMatrix.js +25 -25
- package/dist/cjs/originDestinationMatrix.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/{node → cjs}/serviceArea.js +18 -18
- package/dist/cjs/serviceArea.js.map +1 -0
- package/dist/{node → cjs}/solveRoute.js +19 -19
- package/dist/cjs/solveRoute.js.map +1 -0
- package/dist/esm/closestFacility.d.ts +6 -4
- package/dist/esm/closestFacility.js +12 -11
- package/dist/esm/closestFacility.js.map +1 -1
- package/dist/esm/helpers.d.ts +1 -2
- package/dist/esm/helpers.js +15 -15
- package/dist/esm/helpers.js.map +1 -1
- package/dist/esm/index.d.ts +6 -6
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/originDestinationMatrix.d.ts +7 -6
- package/dist/esm/originDestinationMatrix.js +11 -11
- package/dist/esm/originDestinationMatrix.js.map +1 -1
- package/dist/esm/package.json +3 -0
- package/dist/esm/serviceArea.d.ts +5 -4
- package/dist/esm/serviceArea.js +11 -11
- package/dist/esm/serviceArea.js.map +1 -1
- package/dist/esm/solveRoute.d.ts +5 -4
- package/dist/esm/solveRoute.js +13 -13
- package/dist/esm/solveRoute.js.map +1 -1
- package/package.json +58 -41
- package/dist/node/closestFacility.js.map +0 -1
- package/dist/node/helpers.js.map +0 -1
- package/dist/node/index.js +0 -11
- package/dist/node/index.js.map +0 -1
- package/dist/node/originDestinationMatrix.js.map +0 -1
- package/dist/node/serviceArea.js.map +0 -1
- package/dist/node/solveRoute.js.map +0 -1
- package/dist/umd/routing.umd.js +0 -779
- package/dist/umd/routing.umd.js.map +0 -1
- package/dist/umd/routing.umd.min.js +0 -12
- package/dist/umd/routing.umd.min.js.map +0 -1
package/dist/esm/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA;gBACgB;AAWhB,eAAe;AACf,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA;gBACgB;AAWhB,eAAe;AACf,MAAM,CAAC,MAAM,yBAAyB,GACpC,gFAAgF,CAAC;AACnF,MAAM,CAAC,MAAM,kCAAkC,GAC7C,oGAAoG,CAAC;AACvG,MAAM,CAAC,MAAM,8BAA8B,GACzC,6FAA6F,CAAC;AAChG,MAAM,CAAC,MAAM,2CAA2C,GACtD,4HAA4H,CAAC;AAU/H,SAAS,eAAe,CACtB,MAAwE;IAExE,OAAO,CACJ,MAA2B,CAAC,MAAM,KAAK,CAAC;QACxC,MAAmC,CAAC,MAAM,KAAK,CAAC,CAClD,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,MAAwE;IAExE,OAAO,CACJ,MAAoB,CAAC,QAAQ,KAAK,SAAS;QAC3C,MAAoB,CAAC,GAAG,KAAK,SAAS,CACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,SAAuD;IAEvD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAA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AC;QAC7C,SAAS,GAAG,CAAC,CAAC;QAEd,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,WAAW,EAAE,CAAC,GAAG,WAAW,CAAe,CAAC,CAAC;KAC/D;IAED,OAAO;QACL,KAAK,EAAE,CAAC,MAAM,CAAC;KACH,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,GAAQ;IACnC,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\r\n * Apache-2.0 */\r\n\r\nimport { \r\n IRequestOptions,\r\n ILocation,\r\n IPoint,\r\n IPolyline,\r\n Position2D,\r\n IFeatureSet\r\n} from \"@esri/arcgis-rest-request\";\r\n\r\n// https always\r\nexport const ARCGIS_ONLINE_ROUTING_URL =\r\n \"https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World\";\r\nexport const ARCGIS_ONLINE_CLOSEST_FACILITY_URL =\r\n \"https://route.arcgis.com/arcgis/rest/services/World/ClosestFacility/NAServer/ClosestFacility_World\";\r\nexport const ARCGIS_ONLINE_SERVICE_AREA_URL =\r\n \"https://route.arcgis.com/arcgis/rest/services/World/ServiceAreas/NAServer/ServiceArea_World\";\r\nexport const ARCGIS_ONLINE_ORIGIN_DESTINATION_MATRIX_URL =\r\n \"https://route.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/NAServer/OriginDestinationCostMatrix_World\";\r\n\r\n// nice to have: verify custom endpoints contain 'NAServer' and end in a '/'\r\nexport interface IEndpointOptions extends IRequestOptions {\r\n /**\r\n * Any ArcGIS Routing service (example: https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route/ ) to use for the routing service request.\r\n */\r\n endpoint?: string;\r\n}\r\n\r\nfunction isLocationArray(\r\n coords: ILocation | IPoint | [number, number] | [number, number, number]\r\n): coords is [number, number] | [number, number, number] {\r\n return (\r\n (coords as [number, number]).length === 2 ||\r\n (coords as [number, number, number]).length === 3\r\n );\r\n}\r\n\r\nfunction isLocation(\r\n coords: ILocation | IPoint | [number, number] | [number, number, number]\r\n): coords is ILocation {\r\n return (\r\n (coords as ILocation).latitude !== undefined ||\r\n (coords as ILocation).lat !== undefined\r\n );\r\n}\r\n\r\nexport function normalizeLocationsList(\r\n locations: Array<IPoint | ILocation | [number, number]>\r\n): string[] {\r\n return locations.map((coords) => {\r\n if (isLocationArray(coords)) {\r\n return coords.join();\r\n } else if (isLocation(coords)) {\r\n if (coords.lat) {\r\n return coords.long + \",\" + coords.lat;\r\n } else {\r\n return coords.longitude + \",\" + coords.latitude;\r\n }\r\n } else {\r\n return coords.x + \",\" + coords.y;\r\n }\r\n });\r\n}\r\n\r\nexport function decompressGeometry(str: string) {\r\n let xDiffPrev = 0;\r\n let yDiffPrev = 0;\r\n const points = [];\r\n let x;\r\n let y;\r\n\r\n // Split the string into an array on the + and - characters\r\n const strings = str.match(/((\\+|-)[^+-]+)/g);\r\n\r\n // The first value is the coefficient in base 32\r\n const coefficient = parseInt(strings[0], 32);\r\n\r\n for (let j = 1; j < strings.length; j += 2) {\r\n // j is the offset for the x value\r\n // Convert the value from base 32 and add the previous x value\r\n x = parseInt(strings[j], 32) + xDiffPrev;\r\n xDiffPrev = x;\r\n\r\n // j+1 is the offset for the y value\r\n // Convert the value from base 32 and add the previous y value\r\n y = parseInt(strings[j + 1], 32) + yDiffPrev;\r\n yDiffPrev = y;\r\n\r\n points.push([x / coefficient, y / coefficient] as Position2D);\r\n }\r\n\r\n return {\r\n paths: [points]\r\n } as IPolyline;\r\n}\r\n\r\n/**\r\n * User Defined Type Guard that verifies this is a featureSet\r\n */\r\nexport function isFeatureSet(arg: any): arg is IFeatureSet {\r\n return Object.prototype.hasOwnProperty.call(arg, \"features\");\r\n}\r\n"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./solveRoute";
|
|
2
|
-
export * from "./closestFacility";
|
|
3
|
-
export * from "./serviceArea";
|
|
4
|
-
export * from "./originDestinationMatrix";
|
|
5
|
-
export * from "./helpers";
|
|
6
|
-
export {
|
|
1
|
+
export * from "./solveRoute.js";
|
|
2
|
+
export * from "./closestFacility.js";
|
|
3
|
+
export * from "./serviceArea.js";
|
|
4
|
+
export * from "./originDestinationMatrix.js";
|
|
5
|
+
export * from "./helpers.js";
|
|
6
|
+
export type { IRequestOptions, ILocation, IPoint, IPolyline, Position2D, IFeatureSet, IFeature } from "@esri/arcgis-rest-request";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
|
2
2
|
* Apache-2.0 */
|
|
3
|
-
export * from "./solveRoute";
|
|
4
|
-
export * from "./closestFacility";
|
|
5
|
-
export * from "./serviceArea";
|
|
6
|
-
export * from "./originDestinationMatrix";
|
|
7
|
-
export * from "./helpers";
|
|
3
|
+
export * from "./solveRoute.js";
|
|
4
|
+
export * from "./closestFacility.js";
|
|
5
|
+
export * from "./serviceArea.js";
|
|
6
|
+
export * from "./originDestinationMatrix.js";
|
|
7
|
+
export * from "./helpers.js";
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC","sourcesContent":["/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\r\n * Apache-2.0 */\r\n\r\nexport * from \"./solveRoute.js\";\r\nexport * from \"./closestFacility.js\";\r\nexport * from \"./serviceArea.js\";\r\nexport * from \"./originDestinationMatrix.js\";\r\nexport * from \"./helpers.js\";\r\n\r\n// Types that are used in this package are re-exported for convenience and \r\n// to make the links work correctly in the documentation pages.\r\nexport type {\r\n IRequestOptions,\r\n ILocation,\r\n IPoint,\r\n IPolyline,\r\n Position2D,\r\n IFeatureSet,\r\n IFeature\r\n} from \"@esri/arcgis-rest-request\";"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ILocation, IPoint, IFeatureSet } from "@esri/arcgis-rest-
|
|
2
|
-
import { IEndpointOptions } from "./helpers";
|
|
1
|
+
import { ILocation, IPoint, IFeatureSet } from "@esri/arcgis-rest-request";
|
|
2
|
+
import { IEndpointOptions } from "./helpers.js";
|
|
3
3
|
export interface IOriginDestinationMatrixOptions extends IEndpointOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Specify the starting points from which to travel to the destinations.
|
|
@@ -26,10 +26,10 @@ interface IFeatureSetWithGeoJson extends IFeatureSet {
|
|
|
26
26
|
geoJson?: any;
|
|
27
27
|
}
|
|
28
28
|
export interface IOriginDestinationMatrixResponse {
|
|
29
|
-
messages: {
|
|
29
|
+
messages: [{
|
|
30
30
|
type: number;
|
|
31
31
|
description: string;
|
|
32
|
-
}
|
|
32
|
+
}];
|
|
33
33
|
/**
|
|
34
34
|
* Only present if outputType is "esriNAODOutputSparseMatrix". Full description is available at https://developers.arcgis.com/rest/network/api-reference/origin-destination-cost-matrix-synchronous-service.htm#ESRI_SECTION2_114F8364507C4B56B780DFAD505270FB.
|
|
35
35
|
*/
|
|
@@ -45,9 +45,11 @@ export interface IOriginDestinationMatrixResponse {
|
|
|
45
45
|
polygonBarriers?: IFeatureSetWithGeoJson;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
+
* Used to create an origin-destination (OD) cost matrix from multiple origins to multiple destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/origin-destination-cost-matrix-synchronous-service.htm) for more information.
|
|
49
|
+
*
|
|
48
50
|
* ```js
|
|
49
51
|
* import { originDestinationMatrix } from '@esri/arcgis-rest-routing';
|
|
50
|
-
*
|
|
52
|
+
*
|
|
51
53
|
* originDestinationMatrix({
|
|
52
54
|
* origins: [
|
|
53
55
|
* [-90.404302, 38.600621],
|
|
@@ -62,7 +64,6 @@ export interface IOriginDestinationMatrixResponse {
|
|
|
62
64
|
* })
|
|
63
65
|
* .then(response) // => { ... }
|
|
64
66
|
* ```
|
|
65
|
-
* Used to create an origin-destination (OD) cost matrix from multiple origins to multiple destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/origin-destination-cost-matrix-synchronous-service.htm) for more information.
|
|
66
67
|
*
|
|
67
68
|
* @param requestOptions Options to pass through to the routing service.
|
|
68
69
|
* @returns A Promise that will resolve with travel time and/or distance for each origin-destination pair. It returns either odLines or odCostMatrix for this information depending on the outputType you specify.
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
|
2
2
|
* Apache-2.0 */
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ARCGIS_ONLINE_ORIGIN_DESTINATION_MATRIX_URL, normalizeLocationsList, isFeatureSet, } from "./helpers";
|
|
3
|
+
import { request, cleanUrl, appendCustomParams } from "@esri/arcgis-rest-request";
|
|
4
|
+
import { ARCGIS_ONLINE_ORIGIN_DESTINATION_MATRIX_URL, normalizeLocationsList, isFeatureSet } from "./helpers.js";
|
|
6
5
|
import { arcgisToGeoJSON } from "@terraformer/arcgis";
|
|
7
6
|
/**
|
|
7
|
+
* Used to create an origin-destination (OD) cost matrix from multiple origins to multiple destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/origin-destination-cost-matrix-synchronous-service.htm) for more information.
|
|
8
|
+
*
|
|
8
9
|
* ```js
|
|
9
10
|
* import { originDestinationMatrix } from '@esri/arcgis-rest-routing';
|
|
10
|
-
*
|
|
11
|
+
*
|
|
11
12
|
* originDestinationMatrix({
|
|
12
13
|
* origins: [
|
|
13
14
|
* [-90.404302, 38.600621],
|
|
@@ -22,16 +23,15 @@ import { arcgisToGeoJSON } from "@terraformer/arcgis";
|
|
|
22
23
|
* })
|
|
23
24
|
* .then(response) // => { ... }
|
|
24
25
|
* ```
|
|
25
|
-
* Used to create an origin-destination (OD) cost matrix from multiple origins to multiple destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/origin-destination-cost-matrix-synchronous-service.htm) for more information.
|
|
26
26
|
*
|
|
27
27
|
* @param requestOptions Options to pass through to the routing service.
|
|
28
28
|
* @returns A Promise that will resolve with travel time and/or distance for each origin-destination pair. It returns either odLines or odCostMatrix for this information depending on the outputType you specify.
|
|
29
29
|
* @restlink https://developers.arcgis.com/rest/network/api-reference/origin-destination-cost-matrix-synchronous-service.htm
|
|
30
30
|
*/
|
|
31
31
|
export function originDestinationMatrix(requestOptions) {
|
|
32
|
-
|
|
33
|
-
requestOptions.params =
|
|
34
|
-
|
|
32
|
+
const endpoint = requestOptions.endpoint || ARCGIS_ONLINE_ORIGIN_DESTINATION_MATRIX_URL;
|
|
33
|
+
requestOptions.params = Object.assign({ outputType: "esriNAODOutputSparseMatrix", returnOrigins: true, returnDestinations: true, returnBarriers: true, returnPolylineBarriers: true, returnPolygonBarriers: true }, requestOptions.params);
|
|
34
|
+
const options = appendCustomParams(requestOptions, [
|
|
35
35
|
"outputType",
|
|
36
36
|
"barriers",
|
|
37
37
|
"polylineBarriers",
|
|
@@ -40,7 +40,7 @@ export function originDestinationMatrix(requestOptions) {
|
|
|
40
40
|
"returnDestinations",
|
|
41
41
|
"returnBarriers",
|
|
42
42
|
"returnPolylineBarriers",
|
|
43
|
-
"returnPolygonBarriers"
|
|
43
|
+
"returnPolygonBarriers"
|
|
44
44
|
]);
|
|
45
45
|
// the SAAS service does not support anonymous requests
|
|
46
46
|
if (!requestOptions.authentication &&
|
|
@@ -72,7 +72,7 @@ export function originDestinationMatrix(requestOptions) {
|
|
|
72
72
|
options.params.barriers = normalizeLocationsList(requestOptions.barriers).join(";");
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
return request(cleanUrl(endpoint)
|
|
75
|
+
return request(`${cleanUrl(endpoint)}/solveODCostMatrix`, options).then(function (res) {
|
|
76
76
|
return cleanResponse(res, options);
|
|
77
77
|
});
|
|
78
78
|
}
|
|
@@ -104,6 +104,6 @@ function cleanResponse(res, options) {
|
|
|
104
104
|
return res;
|
|
105
105
|
}
|
|
106
106
|
export default {
|
|
107
|
-
originDestinationMatrix
|
|
107
|
+
originDestinationMatrix
|
|
108
108
|
};
|
|
109
109
|
//# sourceMappingURL=originDestinationMatrix.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"originDestinationMatrix.js","sourceRoot":"","sources":["../../src/originDestinationMatrix.ts"],"names":[],"mappings":"AAAA;gBACgB;;AAEhB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,kBAAkB,GAEnB,MAAM,2BAA2B,CAAC;AASnC,OAAO,EACL,2CAA2C,EAE3C,sBAAsB,EACtB,YAAY,GACb,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAiDtD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,uBAAuB,CACrC,cAA+C;IAE/C,IAAM,QAAQ,GACZ,cAAc,CAAC,QAAQ,IAAI,2CAA2C,CAAC;IAEzE,cAAc,CAAC,MAAM,cACnB,UAAU,EAAE,4BAA4B,EACxC,aAAa,EAAE,IAAI,EACnB,kBAAkB,EAAE,IAAI,EACxB,cAAc,EAAE,IAAI,EACpB,sBAAsB,EAAE,IAAI,EAC5B,qBAAqB,EAAE,IAAI,IACxB,cAAc,CAAC,MAAM,CACzB,CAAC;IAEF,IAAM,OAAO,GAAG,kBAAkB,CAChC,cAAc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pB,GAAG,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,KAAK,IAAI,EACnD;QACA,GAAG,CAAC,gBAAgB,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;KACtE;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,eAAe;IACb,uBAAuB,yBAAA;CACxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"originDestinationMatrix.js","sourceRoot":"","sources":["../../src/originDestinationMatrix.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,kBAAkB,EAKnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,2CAA2C,EAE3C,sBAAsB,EACtB,YAAY,EACb,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAiDtD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,uBAAuB,CACrC,cAA+C;IAE/C,MAAM,QAAQ,GACZ,cAAc,CAAC,QAAQ,IAAI,2CAA2C,CAAC;IAEzE,cAAc,CAAC,MAAM,mBACnB,UAAU,EAAE,4BAA4B,EACxC,aAAa,EAAE,IAAI,EACnB,kBAAkB,EAAE,IAAI,EACxB,cAAc,EAAE,IAAI,EACpB,sBAAsB,EAAE,IAAI,EAC5B,qBAAqB,EAAE,IAAI,IACxB,cAAc,CAAC,MAAM,CACzB,CAAC;IAEF,MAAM,OAAO,GAAG,kBAAkB,CAChC,cAAc,EACd;QACE,YAAY;QACZ,UAAU;QACV,kBAAkB;QAClB,iBAAiB;QACjB,eAAe;QACf,oBAAoB;QACpB,gBAAgB;QAChB,wBAAwB;QACxB,uBAAuB;KACxB,CACF,CAAC;IAEF,uDAAuD;IACvD,IACE,CAAC,cAAc,CAAC,cAAc;QAC9B,QAAQ,KAAK,2CAA2C,EACxD;QACA,OAAO,OAAO,CAAC,MAAM,CACnB,iGAAiG,CACl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research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams,\n IRequestOptions,\n ILocation,\n IPoint,\n IFeatureSet\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_ORIGIN_DESTINATION_MATRIX_URL,\n IEndpointOptions,\n normalizeLocationsList,\n isFeatureSet\n} from \"./helpers.js\";\n\nimport { arcgisToGeoJSON } from \"@terraformer/arcgis\";\n\nexport interface IOriginDestinationMatrixOptions extends IEndpointOptions {\n /**\n * Specify the starting points from which to travel to the destinations.\n */\n origins: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n /**\n * Specify the ending point locations to travel to from the origins.\n */\n destinations: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n /**\n * Specify the type of output returned by the service. Defaults to \"esriNAODOutputSparseMatrix\".\n */\n outputType?:\n | \"esriNAODOutputSparseMatrix\"\n | \"esriNAODOutputStraightLines\"\n | \"esriNAODOutputNoLines\";\n barriers?: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n polylineBarriers?: IFeatureSet;\n polygonBarriers?: IFeatureSet;\n returnOrigins?: boolean;\n returnDestinations?: boolean;\n returnBarriers?: boolean;\n returnPolylineBarriers?: boolean;\n returnPolygonBarriers?: boolean;\n}\n\ninterface IFeatureSetWithGeoJson extends IFeatureSet {\n geoJson?: any;\n}\n\nexport interface IOriginDestinationMatrixResponse {\n messages: [{ type: number; description: string }];\n /**\n * Only present if outputType is \"esriNAODOutputSparseMatrix\". Full description is available at https://developers.arcgis.com/rest/network/api-reference/origin-destination-cost-matrix-synchronous-service.htm#ESRI_SECTION2_114F8364507C4B56B780DFAD505270FB.\n */\n odCostMatrix?: any;\n /**\n * Only present if outputType is \"esriNAODOutputStraightLines\" or \"esriNAODOutputNoLines\". Includes the geometry for the straight line connecting each origin-destination pair when the outputType is \"esriNAODOutputStraightLines\".\n */\n odLines?: IFeatureSetWithGeoJson;\n origins?: IFeatureSetWithGeoJson;\n destinations?: IFeatureSetWithGeoJson;\n barriers?: IFeatureSetWithGeoJson;\n polylineBarriers?: IFeatureSetWithGeoJson;\n polygonBarriers?: IFeatureSetWithGeoJson;\n}\n\n/**\n * Used to create an origin-destination (OD) cost matrix from multiple origins to multiple destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/origin-destination-cost-matrix-synchronous-service.htm) for more information.\n *\n * ```js\n * import { originDestinationMatrix } from '@esri/arcgis-rest-routing';\n *\n * originDestinationMatrix({\n * origins: [\n * [-90.404302, 38.600621],\n * [-90.364293, 38.620427],\n * ],\n * destinations: [\n * [-90.444716, 38.635501],\n * [-90.311919, 38.633523],\n * [-90.451147, 38.581107]\n * ],\n * authentication\n * })\n * .then(response) // => { ... }\n * ```\n *\n * @param requestOptions Options to pass through to the routing service.\n * @returns A Promise that will resolve with travel time and/or distance for each origin-destination pair. It returns either odLines or odCostMatrix for this information depending on the outputType you specify.\n * @restlink https://developers.arcgis.com/rest/network/api-reference/origin-destination-cost-matrix-synchronous-service.htm\n */\nexport function originDestinationMatrix(\n requestOptions: IOriginDestinationMatrixOptions\n): Promise<IOriginDestinationMatrixResponse> {\n const endpoint =\n requestOptions.endpoint || ARCGIS_ONLINE_ORIGIN_DESTINATION_MATRIX_URL;\n\n requestOptions.params = {\n outputType: \"esriNAODOutputSparseMatrix\",\n returnOrigins: true,\n returnDestinations: true,\n returnBarriers: true,\n returnPolylineBarriers: true,\n returnPolygonBarriers: true,\n ...requestOptions.params\n };\n\n const options = appendCustomParams<IOriginDestinationMatrixOptions>(\n requestOptions,\n [\n \"outputType\",\n \"barriers\",\n \"polylineBarriers\",\n \"polygonBarriers\",\n \"returnOrigins\",\n \"returnDestinations\",\n \"returnBarriers\",\n \"returnPolylineBarriers\",\n \"returnPolygonBarriers\"\n ]\n );\n\n // the SAAS service does not support anonymous requests\n if (\n !requestOptions.authentication &&\n endpoint === ARCGIS_ONLINE_ORIGIN_DESTINATION_MATRIX_URL\n ) {\n return Promise.reject(\n \"Calculating the origin-destination cost matrix using the ArcGIS service requires authentication\"\n );\n }\n\n // use a formatting helper for input params of this type: Array<IPoint | ILocation | [number, number]>\n if (isFeatureSet(requestOptions.origins)) {\n options.params.origins = requestOptions.origins;\n } else {\n options.params.origins = normalizeLocationsList(\n requestOptions.origins\n ).join(\";\");\n }\n\n if (isFeatureSet(requestOptions.destinations)) {\n options.params.destinations = requestOptions.destinations;\n } else {\n options.params.destinations = normalizeLocationsList(\n requestOptions.destinations\n ).join(\";\");\n }\n\n // optional input param that may need point geometry normalizing\n if (requestOptions.barriers) {\n if (isFeatureSet(requestOptions.barriers)) {\n options.params.barriers = requestOptions.barriers;\n } else {\n // optional point geometry barriers must be normalized, too\n // but not if provided as IFeatureSet type\n // note that optional polylineBarriers and polygonBarriers do not need to be normalized\n options.params.barriers = normalizeLocationsList(\n requestOptions.barriers\n ).join(\";\");\n }\n }\n\n return request(`${cleanUrl(endpoint)}/solveODCostMatrix`, options).then(\n function (res) {\n return cleanResponse(res, options);\n }\n );\n}\n\nfunction cleanResponse(\n res: any,\n options: IRequestOptions\n): IOriginDestinationMatrixResponse {\n // add \"geoJson\" property to each response property that is an arcgis featureSet\n\n // res.odLines only exists and only includes geometry in this condition (out of 3 possible options.params.outputType conditions)\n if (\n options.params.outputType === \"esriNAODOutputStraightLines\" &&\n res.odLines &&\n res.odLines.spatialReference.wkid === 4326\n ) {\n res.odLines.geoJson = arcgisToGeoJSON(res.odLines);\n }\n\n if (res.origins && res.origins.spatialReference.wkid === 4326) {\n res.origins.geoJson = arcgisToGeoJSON(res.origins);\n }\n\n if (res.destinations && res.destinations.spatialReference.wkid === 4326) {\n res.destinations.geoJson = arcgisToGeoJSON(res.destinations);\n }\n\n if (res.barriers && res.barriers.spatialReference.wkid === 4326) {\n res.barriers.geoJson = arcgisToGeoJSON(res.barriers);\n }\n\n if (\n res.polygonBarriers &&\n res.polygonBarriers.spatialReference.wkid === 4326\n ) {\n res.polygonBarriers.geoJson = arcgisToGeoJSON(res.polygonBarriers);\n }\n\n if (\n res.polylineBarriers &&\n res.polylineBarriers.spatialReference.wkid === 4326\n ) {\n res.polylineBarriers.geoJson = arcgisToGeoJSON(res.polylineBarriers);\n }\n\n return res;\n}\n\nexport default {\n originDestinationMatrix\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ILocation, IPoint, IFeatureSet } from "@esri/arcgis-rest-
|
|
2
|
-
import { IEndpointOptions } from "./helpers";
|
|
1
|
+
import { ILocation, IPoint, IFeatureSet } from "@esri/arcgis-rest-request";
|
|
2
|
+
import { IEndpointOptions } from "./helpers.js";
|
|
3
3
|
export interface IServiceAreaOptions extends IEndpointOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Specify one or more locations around which service areas are generated.
|
|
@@ -32,9 +32,11 @@ export interface IServiceAreaResponse {
|
|
|
32
32
|
polylineBarriers?: IFeatureSet;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
+
* Used to find the area that can be reached from the input location within a given travel time or travel distance. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/service-area-synchronous-service.htm) for more information.
|
|
36
|
+
*
|
|
35
37
|
* ```js
|
|
36
38
|
* import { serviceArea } from '@esri/arcgis-rest-routing';
|
|
37
|
-
*
|
|
39
|
+
*
|
|
38
40
|
* serviceArea({
|
|
39
41
|
* facilities: [
|
|
40
42
|
* [-90.444716, 38.635501],
|
|
@@ -45,7 +47,6 @@ export interface IServiceAreaResponse {
|
|
|
45
47
|
* })
|
|
46
48
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
47
49
|
* ```
|
|
48
|
-
* Used to find the area that can be reached from the input location within a given travel time or travel distance. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/service-area-synchronous-service.htm) for more information.
|
|
49
50
|
*
|
|
50
51
|
* @param requestOptions Options to pass through to the routing service.
|
|
51
52
|
* @returns A Promise that will resolve with service area polygons for the request.
|
package/dist/esm/serviceArea.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
|
2
2
|
* Apache-2.0 */
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ARCGIS_ONLINE_SERVICE_AREA_URL, normalizeLocationsList, isFeatureSet, } from "./helpers";
|
|
3
|
+
import { request, cleanUrl, appendCustomParams } from "@esri/arcgis-rest-request";
|
|
4
|
+
import { ARCGIS_ONLINE_SERVICE_AREA_URL, normalizeLocationsList, isFeatureSet } from "./helpers.js";
|
|
6
5
|
import { arcgisToGeoJSON } from "@terraformer/arcgis";
|
|
7
6
|
function getTravelDirection(key) {
|
|
8
7
|
if (key === "incidentsToFacilities") {
|
|
@@ -13,9 +12,11 @@ function getTravelDirection(key) {
|
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
15
|
+
* Used to find the area that can be reached from the input location within a given travel time or travel distance. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/service-area-synchronous-service.htm) for more information.
|
|
16
|
+
*
|
|
16
17
|
* ```js
|
|
17
18
|
* import { serviceArea } from '@esri/arcgis-rest-routing';
|
|
18
|
-
*
|
|
19
|
+
*
|
|
19
20
|
* serviceArea({
|
|
20
21
|
* facilities: [
|
|
21
22
|
* [-90.444716, 38.635501],
|
|
@@ -26,16 +27,15 @@ function getTravelDirection(key) {
|
|
|
26
27
|
* })
|
|
27
28
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
28
29
|
* ```
|
|
29
|
-
* Used to find the area that can be reached from the input location within a given travel time or travel distance. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/service-area-synchronous-service.htm) for more information.
|
|
30
30
|
*
|
|
31
31
|
* @param requestOptions Options to pass through to the routing service.
|
|
32
32
|
* @returns A Promise that will resolve with service area polygons for the request.
|
|
33
33
|
* @restlink https://developers.arcgis.com/rest/network/api-reference/service-area-synchronous-service.htm
|
|
34
34
|
*/
|
|
35
35
|
export function serviceArea(requestOptions) {
|
|
36
|
-
|
|
37
|
-
requestOptions.params =
|
|
38
|
-
|
|
36
|
+
const endpoint = requestOptions.endpoint || ARCGIS_ONLINE_SERVICE_AREA_URL;
|
|
37
|
+
requestOptions.params = Object.assign({ returnFacilities: true, returnBarriers: true, returnPolylineBarriers: true, returnPolygonBarriers: true, preserveObjectID: true }, requestOptions.params);
|
|
38
|
+
const options = appendCustomParams(requestOptions, [
|
|
39
39
|
"barriers",
|
|
40
40
|
"polylineBarriers",
|
|
41
41
|
"polygonBarriers",
|
|
@@ -44,7 +44,7 @@ export function serviceArea(requestOptions) {
|
|
|
44
44
|
"returnBarriers",
|
|
45
45
|
"returnPolylineBarriers",
|
|
46
46
|
"returnPolygonBarriers",
|
|
47
|
-
"preserveObjectID"
|
|
47
|
+
"preserveObjectID"
|
|
48
48
|
]);
|
|
49
49
|
// Set travelDirection
|
|
50
50
|
if (requestOptions.travelDirection) {
|
|
@@ -73,7 +73,7 @@ export function serviceArea(requestOptions) {
|
|
|
73
73
|
options.params.barriers = normalizeLocationsList(requestOptions.barriers).join(";");
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
return request(cleanUrl(endpoint)
|
|
76
|
+
return request(`${cleanUrl(endpoint)}/solveServiceArea`, options).then(cleanResponse);
|
|
77
77
|
}
|
|
78
78
|
function cleanResponse(res) {
|
|
79
79
|
// remove "fieldAliases" because it does not do anything.
|
|
@@ -85,6 +85,6 @@ function cleanResponse(res) {
|
|
|
85
85
|
return res;
|
|
86
86
|
}
|
|
87
87
|
export default {
|
|
88
|
-
serviceArea
|
|
88
|
+
serviceArea
|
|
89
89
|
};
|
|
90
90
|
//# sourceMappingURL=serviceArea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceArea.js","sourceRoot":"","sources":["../../src/serviceArea.ts"],"names":[],"mappings":"AAAA;gBACgB
|
|
1
|
+
{"version":3,"file":"serviceArea.js","sourceRoot":"","sources":["../../src/serviceArea.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c,CAAC,UAAU,CAAC,EAAE;QAC3C,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC;KACvD;SAAM;QACL,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,sBAAsB,CAChD,cAAc,CAAC,UAAU,CAC1B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACb;IAED,gEAAgE;IAChE,IAAI,cAAc,CAAC,QAAQ,EAAE;QAC3B,IAAI,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;YACzC,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,cAAc,CAAC,QAAQ,CAAC;SACnD;aAAM;YACL,2DAA2D;YAC3D,0CAA0C;YAC1C,uFAAuF;YACvF,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,sBAAsB,CAC9C,cAAc,CAAC,QAAQ,CACxB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACb;KACF;IAED,OAAO,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CACpE,aAAa,CACd,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,GAAQ;IAC7B,yDAAyD;IACzD,OAAO,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC;IAEnC,yCAAyC;IACzC,IAAI,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,KAAK,IAAI,EAAE;QACjD,GAAG,CAAC,UAAU,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;KAC1D;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,eAAe;IACb,WAAW;CACZ,CAAC","sourcesContent":["/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams,\n ILocation,\n IPoint,\n IFeatureSet\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_SERVICE_AREA_URL,\n IEndpointOptions,\n normalizeLocationsList,\n isFeatureSet\n} from \"./helpers.js\";\n\nimport { arcgisToGeoJSON } from \"@terraformer/arcgis\";\n\nexport interface IServiceAreaOptions extends IEndpointOptions {\n /**\n * Specify one or more locations around which service areas are generated.\n */\n facilities: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n /**\n * Specify if the service should return routes.\n */\n travelDirection?: \"incidentsToFacilities\" | \"facilitiesToIncidents\";\n barriers?: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n polylineBarriers?: IFeatureSet;\n polygonBarriers?: IFeatureSet;\n outputLines?: boolean;\n returnFacilities?: boolean;\n returnBarriers?: boolean;\n returnPolylineBarriers?: boolean;\n returnPolygonBarriers?: boolean;\n preserveObjectID?: boolean;\n}\n\ninterface IFeatureSetWithGeoJson extends IFeatureSet {\n geoJson?: any;\n}\n\nexport interface IServiceAreaResponse {\n messages: string[];\n saPolygons?: IFeatureSetWithGeoJson;\n incidents?: IFeatureSet;\n facilities?: IFeatureSet;\n barriers?: IFeatureSet;\n polygonBarriers?: IFeatureSet;\n polylineBarriers?: IFeatureSet;\n}\n\nfunction getTravelDirection(\n key: \"incidentsToFacilities\" | \"facilitiesToIncidents\"\n): \"esriNATravelDirectionFromFacility\" | \"esriNATravelDirectionToFacility\" {\n if (key === \"incidentsToFacilities\") {\n return \"esriNATravelDirectionFromFacility\";\n } else {\n return \"esriNATravelDirectionToFacility\";\n }\n}\n\n/**\n * Used to find the area that can be reached from the input location within a given travel time or travel distance. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/service-area-synchronous-service.htm) for more information.\n *\n * ```js\n * import { serviceArea } from '@esri/arcgis-rest-routing';\n *\n * serviceArea({\n * facilities: [\n * [-90.444716, 38.635501],\n * [-90.311919, 38.633523],\n * [-90.451147, 38.581107]\n * ],\n * authentication\n * })\n * .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}\n * ```\n *\n * @param requestOptions Options to pass through to the routing service.\n * @returns A Promise that will resolve with service area polygons for the request.\n * @restlink https://developers.arcgis.com/rest/network/api-reference/service-area-synchronous-service.htm\n */\nexport function serviceArea(\n requestOptions: IServiceAreaOptions\n): Promise<IServiceAreaResponse> {\n const endpoint = requestOptions.endpoint || ARCGIS_ONLINE_SERVICE_AREA_URL;\n\n requestOptions.params = {\n returnFacilities: true,\n returnBarriers: true,\n returnPolylineBarriers: true,\n returnPolygonBarriers: true,\n preserveObjectID: true,\n ...requestOptions.params\n };\n\n const options = appendCustomParams<IServiceAreaOptions>(requestOptions, [\n \"barriers\",\n \"polylineBarriers\",\n \"polygonBarriers\",\n \"outputLines\",\n \"returnFacilities\",\n \"returnBarriers\",\n \"returnPolylineBarriers\",\n \"returnPolygonBarriers\",\n \"preserveObjectID\"\n ]);\n\n // Set travelDirection\n if (requestOptions.travelDirection) {\n options.params.travelDirection = getTravelDirection(\n requestOptions.travelDirection\n );\n }\n\n // the SAAS service does not support anonymous requests\n if (\n !requestOptions.authentication &&\n endpoint === ARCGIS_ONLINE_SERVICE_AREA_URL\n ) {\n return Promise.reject(\n \"Finding service areas using the ArcGIS service requires authentication\"\n );\n }\n\n if (isFeatureSet(requestOptions.facilities)) {\n options.params.facilities = requestOptions.facilities;\n } else {\n options.params.facilities = normalizeLocationsList(\n requestOptions.facilities\n ).join(\";\");\n }\n\n // optional input param that may need point geometry normalizing\n if (requestOptions.barriers) {\n if (isFeatureSet(requestOptions.barriers)) {\n options.params.barriers = requestOptions.barriers;\n } else {\n // optional point geometry barriers must be normalized, too\n // but not if provided as IFeatureSet type\n // note that optional polylineBarriers and polygonBarriers do not need to be normalized\n options.params.barriers = normalizeLocationsList(\n requestOptions.barriers\n ).join(\";\");\n }\n }\n\n return request(`${cleanUrl(endpoint)}/solveServiceArea`, options).then(\n cleanResponse\n );\n}\n\nfunction cleanResponse(res: any): IServiceAreaResponse {\n // remove \"fieldAliases\" because it does not do anything.\n delete res.saPolygons.fieldAliases;\n\n // add \"geoJson\" property to \"saPolygons\"\n if (res.saPolygons.spatialReference.wkid === 4326) {\n res.saPolygons.geoJson = arcgisToGeoJSON(res.saPolygons);\n }\n return res;\n}\n\nexport default {\n serviceArea\n};\n"]}
|
package/dist/esm/solveRoute.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ILocation, IPoint, IFeature, IFeatureSet } from "@esri/arcgis-rest-
|
|
2
|
-
import { IEndpointOptions } from "./helpers";
|
|
1
|
+
import { ILocation, IPoint, IFeature, IFeatureSet } from "@esri/arcgis-rest-request";
|
|
2
|
+
import { IEndpointOptions } from "./helpers.js";
|
|
3
3
|
interface IFeatureSetWithGeoJson extends IFeatureSet {
|
|
4
4
|
geoJson?: {};
|
|
5
5
|
}
|
|
@@ -21,9 +21,11 @@ export interface ISolveRouteResponse {
|
|
|
21
21
|
}>;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
+
* Used to find the best way to get from one location to another or to visit several locations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/route-synchronous-service.htm) for more information.
|
|
25
|
+
*
|
|
24
26
|
* ```js
|
|
25
27
|
* import { solveRoute } from '@esri/arcgis-rest-routing';
|
|
26
|
-
*
|
|
28
|
+
*
|
|
27
29
|
* solveRoute({
|
|
28
30
|
* stops: [
|
|
29
31
|
* [-117.195677, 34.056383],
|
|
@@ -33,7 +35,6 @@ export interface ISolveRouteResponse {
|
|
|
33
35
|
* })
|
|
34
36
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
35
37
|
* ```
|
|
36
|
-
* Used to find the best way to get from one location to another or to visit several locations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/route-synchronous-service.htm) for more information.
|
|
37
38
|
*
|
|
38
39
|
* @param requestOptions Options to pass through to the routing service.
|
|
39
40
|
* @returns A Promise that will resolve with routes and directions for the request.
|
package/dist/esm/solveRoute.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
|
2
2
|
* Apache-2.0 */
|
|
3
|
-
import { __assign } from "tslib";
|
|
4
3
|
import { request, cleanUrl } from "@esri/arcgis-rest-request";
|
|
5
|
-
import { ARCGIS_ONLINE_ROUTING_URL, decompressGeometry, isFeatureSet
|
|
4
|
+
import { ARCGIS_ONLINE_ROUTING_URL, decompressGeometry, isFeatureSet } from "./helpers.js";
|
|
6
5
|
import { arcgisToGeoJSON } from "@terraformer/arcgis";
|
|
7
6
|
function isLocationArray(coords) {
|
|
8
7
|
return (coords.length === 2 ||
|
|
@@ -13,9 +12,11 @@ function isLocation(coords) {
|
|
|
13
12
|
coords.lat !== undefined);
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
15
|
+
* Used to find the best way to get from one location to another or to visit several locations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/route-synchronous-service.htm) for more information.
|
|
16
|
+
*
|
|
16
17
|
* ```js
|
|
17
18
|
* import { solveRoute } from '@esri/arcgis-rest-routing';
|
|
18
|
-
*
|
|
19
|
+
*
|
|
19
20
|
* solveRoute({
|
|
20
21
|
* stops: [
|
|
21
22
|
* [-117.195677, 34.056383],
|
|
@@ -25,14 +26,13 @@ function isLocation(coords) {
|
|
|
25
26
|
* })
|
|
26
27
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
27
28
|
* ```
|
|
28
|
-
* Used to find the best way to get from one location to another or to visit several locations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/route-synchronous-service.htm) for more information.
|
|
29
29
|
*
|
|
30
30
|
* @param requestOptions Options to pass through to the routing service.
|
|
31
31
|
* @returns A Promise that will resolve with routes and directions for the request.
|
|
32
32
|
* @restlink https://developers.arcgis.com/rest/network/api-reference/route-synchronous-service.htm
|
|
33
33
|
*/
|
|
34
34
|
export function solveRoute(requestOptions) {
|
|
35
|
-
|
|
35
|
+
const options = Object.assign({ endpoint: requestOptions.endpoint || ARCGIS_ONLINE_ROUTING_URL, params: {} }, requestOptions);
|
|
36
36
|
// the SAAS service does not support anonymous requests
|
|
37
37
|
if (!requestOptions.authentication &&
|
|
38
38
|
options.endpoint === ARCGIS_ONLINE_ROUTING_URL) {
|
|
@@ -42,7 +42,7 @@ export function solveRoute(requestOptions) {
|
|
|
42
42
|
options.params.stops = requestOptions.stops;
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
-
|
|
45
|
+
const stops = requestOptions.stops.map((coords) => {
|
|
46
46
|
if (isLocationArray(coords)) {
|
|
47
47
|
return coords.join();
|
|
48
48
|
}
|
|
@@ -63,12 +63,12 @@ export function solveRoute(requestOptions) {
|
|
|
63
63
|
});
|
|
64
64
|
options.params.stops = stops.join(";");
|
|
65
65
|
}
|
|
66
|
-
return request(cleanUrl(options.endpoint)
|
|
66
|
+
return request(`${cleanUrl(options.endpoint)}/solve`, options).then(cleanResponse);
|
|
67
67
|
}
|
|
68
68
|
function cleanResponse(res) {
|
|
69
69
|
if (res.directions && res.directions.length > 0) {
|
|
70
|
-
res.directions = res.directions.map(
|
|
71
|
-
direction.features = direction.features.map(
|
|
70
|
+
res.directions = res.directions.map((direction) => {
|
|
71
|
+
direction.features = direction.features.map((feature) => {
|
|
72
72
|
feature.geometry = decompressGeometry(feature.compressedGeometry);
|
|
73
73
|
return feature;
|
|
74
74
|
});
|
|
@@ -77,21 +77,21 @@ function cleanResponse(res) {
|
|
|
77
77
|
}
|
|
78
78
|
// add "geoJson" property to "routes"
|
|
79
79
|
if (res.routes.spatialReference.wkid === 4326) {
|
|
80
|
-
|
|
80
|
+
const features = res.routes.features.map((feature) => {
|
|
81
81
|
return {
|
|
82
82
|
type: "Feature",
|
|
83
83
|
geometry: arcgisToGeoJSON(feature.geometry),
|
|
84
|
-
properties: Object.assign({}, feature.attributes)
|
|
84
|
+
properties: Object.assign({}, feature.attributes)
|
|
85
85
|
};
|
|
86
86
|
});
|
|
87
87
|
res.routes.geoJson = {
|
|
88
88
|
type: "FeatureCollection",
|
|
89
|
-
features
|
|
89
|
+
features
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
return res;
|
|
93
93
|
}
|
|
94
94
|
export default {
|
|
95
|
-
solveRoute
|
|
95
|
+
solveRoute
|
|
96
96
|
};
|
|
97
97
|
//# sourceMappingURL=solveRoute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solveRoute.js","sourceRoot":"","sources":["../../src/solveRoute.ts"],"names":[],"mappings":"AAAA;gBACgB
|
|
1
|
+
{"version":3,"file":"solveRoute.js","sourceRoot":"","sources":["../../src/solveRoute.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EACL,OAAO,EACP,QAAQ,EAKT,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,yBAAyB,EAEzB,kBAAkB,EAClB,YAAY,EACb,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA+BtD,SAAS,eAAe,CACtB,MAAwE;IAExE,OAAO,CACJ,MAA2B,CAAC,MAAM,KAAK,CAAC;QACxC,MAAmC,CAAC,MAAM,KAAK,CAAC,CAClD,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,MAAwE;IAExE,OAAO,CACJ,MAAoB,CAAC,QAAQ,KAAK,SAAS;QAC3C,MAAoB,CAAC,GAAG,KAAK,SAAS,CACxC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,UAAU,CACxB,cAAkC;IAElC,MAAM,OAAO,mBACX,QAAQ,EAAE,cAAc,CAAC,QAAQ,IAAI,yBAAyB,EAC9D,MAAM,EAAE,EAAE,IACP,cAAc,CAClB,CAAC;IAEF,uDAAuD;IACvD,IACE,CAAC,cAAc,CAAC,cAAc;QAC9B,OAAO,CAAC,QAAQ,KAAK,yBAAyB,EAC9C;QACA,OAAO,OAAO,CAAC,MAAM,CACnB,0DAA0D,CAC3D,CAAC;KACH;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C;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,GAAQ;IAC7B,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;QAC/C,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CACjC,CAAC,SAKA,EAAE,EAAE;YACH,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CACzC,CAAC,OAAuC,EAAE,EAAE;gBAC1C,OAAO,CAAC,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;gBAClE,OAAO,OAAO,CAAC;YACjB,CAAC,CACF,CAAC;YACF,OAAO,SAAS,CAAC;QACnB,CAAC,CACF,CAAC;KACH;IAED,qCAAqC;IACrC,IAAI,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,KAAK,IAAI,EAAE;QAC7C,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAY,EAAE,EAAE;YACxD,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAC3C,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC;aAClD,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG;YACnB,IAAI,EAAE,mBAAmB;YACzB,QAAQ;SACT,CAAC;KACH;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,eAAe;IACb,UAAU;CACX,CAAC","sourcesContent":["/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n ILocation,\n IPoint,\n IFeature,\n IFeatureSet\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_ROUTING_URL,\n IEndpointOptions,\n decompressGeometry,\n isFeatureSet\n} from \"./helpers.js\";\n\nimport { arcgisToGeoJSON } from \"@terraformer/arcgis\";\n\ninterface IFeatureWithCompressedGeometry extends IFeature {\n compressedGeometry?: string;\n}\n\ninterface IFeatureSetWithGeoJson extends IFeatureSet {\n geoJson?: {};\n}\n\nexport interface ISolveRouteOptions extends IEndpointOptions {\n /**\n * Specify two or more locations between which the route is to be found.\n */\n stops:\n | Array<IPoint | ILocation | [number, number] | [number, number, number]>\n | IFeatureSet;\n}\n\nexport interface ISolveRouteResponse {\n messages: string[];\n checksum: string;\n routes: IFeatureSetWithGeoJson;\n directions?: Array<{\n routeId: number;\n routeName: string;\n summary: object;\n features: IFeature[];\n }>;\n}\n\nfunction isLocationArray(\n coords: ILocation | IPoint | [number, number] | [number, number, number]\n): coords is [number, number] | [number, number, number] {\n return (\n (coords as [number, number]).length === 2 ||\n (coords as [number, number, number]).length === 3\n );\n}\n\nfunction isLocation(\n coords: ILocation | IPoint | [number, number] | [number, number, number]\n): coords is ILocation {\n return (\n (coords as ILocation).latitude !== undefined ||\n (coords as ILocation).lat !== undefined\n );\n}\n\n/**\n * Used to find the best way to get from one location to another or to visit several locations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/route-synchronous-service.htm) for more information.\n *\n * ```js\n * import { solveRoute } from '@esri/arcgis-rest-routing';\n *\n * solveRoute({\n * stops: [\n * [-117.195677, 34.056383],\n * [-117.918976, 33.812092],\n * ],\n * authentication\n * })\n * .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}\n * ```\n *\n * @param requestOptions Options to pass through to the routing service.\n * @returns A Promise that will resolve with routes and directions for the request.\n * @restlink https://developers.arcgis.com/rest/network/api-reference/route-synchronous-service.htm\n */\nexport function solveRoute(\n requestOptions: ISolveRouteOptions\n): Promise<ISolveRouteResponse> {\n const options: ISolveRouteOptions = {\n endpoint: requestOptions.endpoint || ARCGIS_ONLINE_ROUTING_URL,\n params: {},\n ...requestOptions\n };\n\n // the SAAS service does not support anonymous requests\n if (\n !requestOptions.authentication &&\n options.endpoint === ARCGIS_ONLINE_ROUTING_URL\n ) {\n return Promise.reject(\n \"Routing using the ArcGIS service requires authentication\"\n );\n }\n\n if (isFeatureSet(requestOptions.stops)) {\n options.params.stops = requestOptions.stops;\n } else {\n const stops: string[] = requestOptions.stops.map((coords) => {\n if (isLocationArray(coords)) {\n return coords.join();\n } else if (isLocation(coords)) {\n if (coords.lat) {\n return (\n coords.long + \",\" + coords.lat + (coords.z ? \",\" + coords.z : \"\")\n );\n } else {\n return (\n coords.longitude +\n \",\" +\n coords.latitude +\n (coords.z ? \",\" + coords.z : \"\")\n );\n }\n } else {\n return coords.x + \",\" + coords.y + (coords.z ? \",\" + coords.z : \"\");\n }\n });\n\n options.params.stops = stops.join(\";\");\n }\n\n return request(`${cleanUrl(options.endpoint)}/solve`, options).then(\n cleanResponse\n );\n}\n\nfunction cleanResponse(res: any): ISolveRouteResponse {\n if (res.directions && res.directions.length > 0) {\n res.directions = res.directions.map(\n (direction: {\n features: IFeatureWithCompressedGeometry[];\n routeId: number;\n routeName: string;\n summary: {};\n }) => {\n direction.features = direction.features.map(\n (feature: IFeatureWithCompressedGeometry) => {\n feature.geometry = decompressGeometry(feature.compressedGeometry);\n return feature;\n }\n );\n return direction;\n }\n );\n }\n\n // add \"geoJson\" property to \"routes\"\n if (res.routes.spatialReference.wkid === 4326) {\n const features = res.routes.features.map((feature: any) => {\n return {\n type: \"Feature\",\n geometry: arcgisToGeoJSON(feature.geometry),\n properties: Object.assign({}, feature.attributes)\n };\n });\n\n res.routes.geoJson = {\n type: \"FeatureCollection\",\n features\n };\n }\n return res;\n}\n\nexport default {\n solveRoute\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,65 +1,82 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/arcgis-rest-routing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.4",
|
|
4
4
|
"description": "Routing helpers for @esri/arcgis-rest-js",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"ES6",
|
|
8
|
+
"arcgis",
|
|
9
|
+
"esri",
|
|
10
|
+
"fetch",
|
|
11
|
+
"promise",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/cjs/index.js",
|
|
7
16
|
"module": "dist/esm/index.js",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
17
|
+
"unpkg": "dist/bundled/routing.umd.min.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./dist/esm/index.js",
|
|
21
|
+
"require": "./dist/cjs/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
10
24
|
"types": "dist/esm/index.d.ts",
|
|
11
|
-
"
|
|
25
|
+
"sideEffects": false,
|
|
12
26
|
"files": [
|
|
13
27
|
"dist/**"
|
|
14
28
|
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "npm-run-all --parallel build:*",
|
|
31
|
+
"postbuild": "node ../../scripts/create-dist-package-jsons.js",
|
|
32
|
+
"build:bundled": "rollup -c ../../rollup.js",
|
|
33
|
+
"build:cjs": "tsc --outDir ./dist/cjs -m commonjs",
|
|
34
|
+
"postbuild:cjs": "node ../../scripts/create-dist-package-jsons.js",
|
|
35
|
+
"build:esm": "tsc --outDir ./dist/esm --declaration",
|
|
36
|
+
"postbuild:esm": "node ../../scripts/create-dist-package-jsons.js",
|
|
37
|
+
"dev": "npm-run-all --parallel dev:*",
|
|
38
|
+
"dev:bundled": "rollup -w -c ../../rollup.js",
|
|
39
|
+
"dev:cjs": "tsc -w --outDir ./dist/cjs -m commonjs",
|
|
40
|
+
"dev:esm": "tsc -w --outDir ./dist/esm --declaration"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=12.20.0"
|
|
44
|
+
},
|
|
15
45
|
"dependencies": {
|
|
16
|
-
"@esri/arcgis-rest-types": "^3.4.3",
|
|
17
46
|
"@terraformer/arcgis": "^2.0.7",
|
|
18
47
|
"@types/terraformer__arcgis": "^2.0.0",
|
|
19
|
-
"tslib": "^
|
|
20
|
-
},
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"@esri/arcgis-rest-auth": "^3.4.3",
|
|
23
|
-
"@esri/arcgis-rest-request": "^3.4.3"
|
|
48
|
+
"tslib": "^2.3.0"
|
|
24
49
|
},
|
|
25
50
|
"peerDependencies": {
|
|
26
|
-
"@esri/arcgis-rest-
|
|
27
|
-
"@esri/arcgis-rest-request": "^3.0.0"
|
|
28
|
-
},
|
|
29
|
-
"scripts": {
|
|
30
|
-
"prepare": "npm run build",
|
|
31
|
-
"build": "npm run build:node && npm run build:umd && npm run build:esm",
|
|
32
|
-
"build:esm": "tsc --module es2015 --outDir ./dist/esm --declaration",
|
|
33
|
-
"build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js",
|
|
34
|
-
"build:node": "tsc --module commonjs --outDir ./dist/node",
|
|
35
|
-
"dev:esm": "tsc -w --module es2015 --outDir ./dist/esm --declaration",
|
|
36
|
-
"dev:umd": "rollup -w -c ../../umd-base-profile.js",
|
|
37
|
-
"dev:node": "tsc -w --module commonjs --outDir ./dist/node"
|
|
51
|
+
"@esri/arcgis-rest-request": "4.0.0-beta.10"
|
|
38
52
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@esri/arcgis-rest-request": "4.0.0-beta.10"
|
|
41
55
|
},
|
|
56
|
+
"contributors": [
|
|
57
|
+
"Gavin Rehkemper <gavin@gavinr.com>"
|
|
58
|
+
],
|
|
59
|
+
"homepage": "https://github.com/Esri/arcgis-rest-js#readme",
|
|
42
60
|
"repository": {
|
|
43
61
|
"type": "git",
|
|
44
62
|
"url": "git+https://github.com/Esri/arcgis-rest-js.git",
|
|
45
63
|
"directory": "packages/arcgis-rest-routing"
|
|
46
64
|
},
|
|
47
|
-
"contributors": [
|
|
48
|
-
{
|
|
49
|
-
"name": "Gavin Rehkemper",
|
|
50
|
-
"email": "gavin@gavinr.com"
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
65
|
"bugs": {
|
|
54
66
|
"url": "https://github.com/Esri/arcgis-rest-js/issues"
|
|
55
67
|
},
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public"
|
|
70
|
+
},
|
|
71
|
+
"esri": {
|
|
72
|
+
"keyExports": [
|
|
73
|
+
"closestFacility",
|
|
74
|
+
"decompressGeometry",
|
|
75
|
+
"isFeatureSet",
|
|
76
|
+
"normalizeLocationsList",
|
|
77
|
+
"originDestinationMatrix",
|
|
78
|
+
"serviceArea",
|
|
79
|
+
"solveRoute"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
65
82
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"closestFacility.js","sourceRoot":"","sources":["../../src/closestFacility.ts"],"names":[],"mappings":";AAAA;gBACgB;;;;AAEhB,iEAImC;AASnC,qCAKmB;AAEnB,8CAAsD;AAsEtD,SAAS,kBAAkB,CACzB,GAAsD;IAEtD,IAAI,GAAG,KAAK,uBAAuB,EAAE;QACnC,OAAO,mCAAmC,CAAC;KAC5C;SAAM;QACL,OAAO,iCAAiC,CAAC;KAC1C;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,eAAe,CAC7B,cAAuC;IAEvC,IAAM,QAAQ,GACZ,cAAc,CAAC,QAAQ,IAAI,4CAAkC,CAAC;IAEhE,cAAc,CAAC,MAAM,sBACnB,gBAAgB,EAAE,IAAI,EACtB,gBAAgB,EAAE,IAAI,EACtB,eAAe,EAAE,IAA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,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC;QACzC,SAAS,GAAG,CAAC,CAAC;QAEd,oCAAoC;QACpC,8DAA8D;QAC9D,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC;QAC7C,SAAS,GAAG,CAAC,CAAC;QAEd,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,WAAW,EAAE,CAAC,GAAG,WAAW,CAAe,CAAC,CAAC;KAC/D;IAED,OAAO;QACL,KAAK,EAAE,CAAC,MAAM,CAAC;KACH,CAAC;AACjB,CAAC;AA9BD,gDA8BC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,GAAQ;IACnC,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC;AAFD,oCAEC"}
|
package/dist/node/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
|
3
|
-
* Apache-2.0 */
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
var tslib_1 = require("tslib");
|
|
6
|
-
tslib_1.__exportStar(require("./solveRoute"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./closestFacility"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./serviceArea"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./originDestinationMatrix"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./helpers"), exports);
|
|
11
|
-
//# sourceMappingURL=index.js.map
|