@esri/arcgis-rest-routing 4.0.0-beta.3 → 4.0.0
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 +1 -1
- package/dist/bundled/routing.esm.js +14 -10
- package/dist/bundled/routing.esm.js.map +1 -1
- package/dist/bundled/routing.esm.min.js +2 -2
- package/dist/bundled/routing.esm.min.js.map +1 -1
- package/dist/bundled/routing.umd.js +14 -10
- package/dist/bundled/routing.umd.js.map +1 -1
- package/dist/bundled/routing.umd.min.js +2 -2
- package/dist/bundled/routing.umd.min.js.map +1 -1
- package/dist/cjs/closestFacility.js +3 -2
- package/dist/cjs/closestFacility.js.map +1 -1
- package/dist/cjs/originDestinationMatrix.js +3 -2
- package/dist/cjs/originDestinationMatrix.js.map +1 -1
- package/dist/cjs/serviceArea.js +3 -2
- package/dist/cjs/serviceArea.js.map +1 -1
- package/dist/cjs/solveRoute.js +3 -2
- package/dist/cjs/solveRoute.js.map +1 -1
- package/dist/esm/closestFacility.d.ts +3 -2
- package/dist/esm/closestFacility.js +3 -2
- package/dist/esm/closestFacility.js.map +1 -1
- package/dist/esm/originDestinationMatrix.d.ts +3 -2
- package/dist/esm/originDestinationMatrix.js +3 -2
- package/dist/esm/originDestinationMatrix.js.map +1 -1
- package/dist/esm/serviceArea.d.ts +3 -2
- package/dist/esm/serviceArea.js +3 -2
- package/dist/esm/serviceArea.js.map +1 -1
- package/dist/esm/solveRoute.d.ts +3 -2
- package/dist/esm/solveRoute.js +3 -2
- package/dist/esm/solveRoute.js.map +1 -1
- package/package.json +14 -3
|
@@ -15,9 +15,11 @@ function getTravelDirection(key) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
+
* Used to find a route to the nearest of several possible destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/closest-facility-synchronous-service.htm) for more information.
|
|
19
|
+
*
|
|
18
20
|
* ```js
|
|
19
21
|
* import { closestFacility } from '@esri/arcgis-rest-routing';
|
|
20
|
-
*
|
|
22
|
+
*
|
|
21
23
|
* closestFacility({
|
|
22
24
|
* incidents: [
|
|
23
25
|
* [-90.404302, 38.600621],
|
|
@@ -32,7 +34,6 @@ function getTravelDirection(key) {
|
|
|
32
34
|
* })
|
|
33
35
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
34
36
|
* ```
|
|
35
|
-
* Used to find a route to the nearest of several possible destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/closest-facility-synchronous-service.htm) for more information.
|
|
36
37
|
*
|
|
37
38
|
* @param requestOptions Options to pass through to the routing service.
|
|
38
39
|
* @returns A Promise that will resolve with routes and directions for the request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closestFacility.js","sourceRoot":"","sources":["../../src/closestFacility.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,mEAQmC;AAEnC,6CAKsB;AAEtB,gDAAsD;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
|
|
1
|
+
{"version":3,"file":"closestFacility.js","sourceRoot":"","sources":["../../src/closestFacility.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,mEAQmC;AAEnC,6CAKsB;AAEtB,gDAAsD;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;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,eAAe,CAC7B,cAAuC;IAEvC,MAAM,QAAQ,GACZ,cAAc,CAAC,QAAQ,IAAI,+CAAkC,CAAC;IAEhE,cAAc,CAAC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AAC,UAAU,GAAG,IAAA,mCAAsB,EAChD,cAAc,CAAC,UAAU,CAC1B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACb;IAED,gEAAgE;IAChE,IAAI,cAAc,CAAC,QAAQ,EAAE;QAC3B,IAAI,IAAA,yBAAY,EAAC,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,IAAA,mCAAsB,EAC9C,cAAc,CAAC,QAAQ,CACxB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACb;KACF;IAED,OAAO,IAAA,6BAAO,EAAC,GAAG,IAAA,8BAAQ,EAAC,QAAQ,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC,IAAI,CACxE,aAAa,CACd,CAAC;AACJ,CAAC;AArFD,0CAqFC;AAED,SAAS,aAAa,CAAC,GAAQ;IAC7B,qCAAqC;IACrC,IAAI,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,KAAK,IAAI,EAAE;QAC7C,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,IAAA,wBAAe,EAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KAClD;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kBAAe;IACb,eAAe;CAChB,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 IFeature,\n IFeatureSet\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_CLOSEST_FACILITY_URL,\n IEndpointOptions,\n normalizeLocationsList,\n isFeatureSet\n} from \"./helpers.js\";\n\nimport { arcgisToGeoJSON } from \"@terraformer/arcgis\";\n\nexport interface IClosestFacilityOptions extends IEndpointOptions {\n /**\n * Specify one or more locations from which the service searches for the nearby locations. These locations are referred to as incidents.\n */\n incidents: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n\n /**\n * Specify one or more locations that are searched for when finding the closest location.\n */\n facilities: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n /**\n * Specify if the service should return routes.\n */\n returnCFRoutes: boolean;\n travelDirection?: \"incidentsToFacilities\" | \"facilitiesToIncidents\";\n barriers?: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n polylineBarriers?: IFeatureSet;\n polygonBarriers?: IFeatureSet;\n returnDirections?: boolean;\n directionsOutputType?:\n | \"esriDOTComplete\"\n | \"esriDOTCompleteNoEvents\"\n | \"esriDOTInstructionsOnly\"\n | \"esriDOTStandard\"\n | \"esriDOTSummaryOnly\"\n | \"esriDOTFeatureSets\";\n directionsLengthUnits?:\n | \"esriNAUCentimeters\"\n | \"esriNAUDecimalDegrees\"\n | \"esriNAUDecimeters\"\n | \"esriNAUFeet\"\n | \"esriNAUInches\"\n | \"esriNAUKilometers\"\n | \"esriNAUMeters\"\n | \"esriNAUMiles\"\n | \"esriNAUMillimeters\"\n | \"esriNAUNauticalMiles\"\n | \"esriNAUPoints\"\n | \"esriNAUYards\";\n outputLines?: boolean;\n returnFacilities?: boolean;\n returnIncidents?: 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 IClosestFacilityResponse {\n messages: string[];\n routes?: IFeatureSetWithGeoJson;\n directions?: Array<{\n routeId: number;\n routeName: string;\n summary: object;\n features: IFeature[];\n }>;\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 a route to the nearest of several possible destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/closest-facility-synchronous-service.htm) for more information.\n *\n * ```js\n * import { closestFacility } from '@esri/arcgis-rest-routing';\n *\n * closestFacility({\n * incidents: [\n * [-90.404302, 38.600621],\n * [-90.364293, 38.620427],\n * ],\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 routes and directions for the request.\n * @restlink https://developers.arcgis.com/rest/network/api-reference/closest-facility-synchronous-service.htm\n * @inline IClosestFacilityOptions\n */\nexport function closestFacility(\n requestOptions: IClosestFacilityOptions\n): Promise<IClosestFacilityResponse> {\n const endpoint =\n requestOptions.endpoint || ARCGIS_ONLINE_CLOSEST_FACILITY_URL;\n\n requestOptions.params = {\n returnFacilities: true,\n returnDirections: true,\n returnIncidents: true,\n returnBarriers: true,\n returnPolylineBarriers: true,\n returnPolygonBarriers: true,\n preserveObjectID: true,\n ...requestOptions.params\n };\n\n const options = appendCustomParams<IClosestFacilityOptions>(requestOptions, [\n \"returnCFRoutes\",\n // \"travelDirection\",\n \"barriers\",\n \"polylineBarriers\",\n \"polygonBarriers\",\n \"returnDirections\",\n \"directionsOutputType\",\n \"directionsLengthUnits\",\n \"outputLines\",\n \"returnFacilities\",\n \"returnIncidents\",\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_CLOSEST_FACILITY_URL\n ) {\n return Promise.reject(\n \"Finding the closest facility using the ArcGIS service requires authentication\"\n );\n }\n\n if (isFeatureSet(requestOptions.incidents)) {\n options.params.incidents = requestOptions.incidents;\n } else {\n options.params.incidents = normalizeLocationsList(\n requestOptions.incidents\n ).join(\";\");\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)}/solveClosestFacility`, options).then(\n cleanResponse\n );\n}\n\nfunction cleanResponse(res: any): IClosestFacilityResponse {\n // add \"geoJson\" property to \"routes\"\n if (res.routes.spatialReference.wkid === 4326) {\n res.routes.geoJson = arcgisToGeoJSON(res.routes);\n }\n return res;\n}\n\nexport default {\n closestFacility\n};\n"]}
|
|
@@ -7,9 +7,11 @@ const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
|
|
|
7
7
|
const helpers_js_1 = require("./helpers.js");
|
|
8
8
|
const arcgis_1 = require("@terraformer/arcgis");
|
|
9
9
|
/**
|
|
10
|
+
* 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.
|
|
11
|
+
*
|
|
10
12
|
* ```js
|
|
11
13
|
* import { originDestinationMatrix } from '@esri/arcgis-rest-routing';
|
|
12
|
-
*
|
|
14
|
+
*
|
|
13
15
|
* originDestinationMatrix({
|
|
14
16
|
* origins: [
|
|
15
17
|
* [-90.404302, 38.600621],
|
|
@@ -24,7 +26,6 @@ const arcgis_1 = require("@terraformer/arcgis");
|
|
|
24
26
|
* })
|
|
25
27
|
* .then(response) // => { ... }
|
|
26
28
|
* ```
|
|
27
|
-
* 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.
|
|
28
29
|
*
|
|
29
30
|
* @param requestOptions Options to pass through to the routing service.
|
|
30
31
|
* @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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"originDestinationMatrix.js","sourceRoot":"","sources":["../../src/originDestinationMatrix.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,mEAQmC;AAEnC,6CAKsB;AAEtB,gDAAsD;AAiDtD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,uBAAuB,CACrC,cAA+C;IAE/C,MAAM,QAAQ,GACZ,cAAc,CAAC,QAAQ,IAAI,wDAA2C,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,IAAA,wCAAkB,EAChC,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,cA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ACnD;QACA,GAAG,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAA,wBAAe,EAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;KACtE;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kBAAe;IACb,uBAAuB;CACxB,CAAC","sourcesContent":["/* Copyright (c) 2018 Environmental Systems 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 * ```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 * 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 * @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
|
+
{"version":3,"file":"originDestinationMatrix.js","sourceRoot":"","sources":["../../src/originDestinationMatrix.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,mEAQmC;AAEnC,6CAKsB;AAEtB,gDAAsD;AAiDtD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,uBAAuB,CACrC,cAA+C;IAE/C,MAAM,QAAQ,GACZ,cAAc,CAAC,QAAQ,IAAI,wDAA2C,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,IAAA,wCAAkB,EAChC,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,wDAA2C,EACxD;QACA,OAAO,OAAO,CAAC,MAAM,CACnB,iGAAiG,CAClG,CAAC;KACH;IAED,sGAAsG;I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AC;AACb,CAAC;AAED,kBAAe;IACb,uBAAuB;CACxB,CAAC","sourcesContent":["/* Copyright (c) 2018 Environmental Systems 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"]}
|
package/dist/cjs/serviceArea.js
CHANGED
|
@@ -15,9 +15,11 @@ function getTravelDirection(key) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
+
* 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.
|
|
19
|
+
*
|
|
18
20
|
* ```js
|
|
19
21
|
* import { serviceArea } from '@esri/arcgis-rest-routing';
|
|
20
|
-
*
|
|
22
|
+
*
|
|
21
23
|
* serviceArea({
|
|
22
24
|
* facilities: [
|
|
23
25
|
* [-90.444716, 38.635501],
|
|
@@ -28,7 +30,6 @@ function getTravelDirection(key) {
|
|
|
28
30
|
* })
|
|
29
31
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
30
32
|
* ```
|
|
31
|
-
* 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.
|
|
32
33
|
*
|
|
33
34
|
* @param requestOptions Options to pass through to the routing service.
|
|
34
35
|
* @returns A Promise that will resolve with service area polygons for the request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceArea.js","sourceRoot":"","sources":["../../src/serviceArea.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,mEAOmC;AAEnC,6CAKsB;AAEtB,gDAAsD;AAoCtD,SAAS,kBAAkB,CACzB,GAAsD;IAEtD,IAAI,GAAG,KAAK,uBAAuB,EAAE;QACnC,OAAO,m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AAU,CAAC,EAAE;QAC3C,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC;KACvD;SAAM;QACL,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,IAAA,mCAAsB,EAChD,cAAc,CAAC,UAAU,CAC1B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACb;IAED,gEAAgE;IAChE,IAAI,cAAc,CAAC,QAAQ,EAAE;QAC3B,IAAI,IAAA,yBAAY,EAAC,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,IAAA,mCAAsB,EAC9C,cAAc,CAAC,QAAQ,CACxB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACb;KACF;IAED,OAAO,IAAA,6BAAO,EAAC,GAAG,IAAA,8BAAQ,EAAC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CACpE,aAAa,CACd,CAAC;AACJ,CAAC;AApED,kCAoEC;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,IAAA,wBAAe,EAAC,GAAG,CAAC,UAAU,CAAC,CAAC;KAC1D;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kBAAe;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/cjs/solveRoute.js
CHANGED
|
@@ -15,9 +15,11 @@ function isLocation(coords) {
|
|
|
15
15
|
coords.lat !== undefined);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
+
* 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.
|
|
19
|
+
*
|
|
18
20
|
* ```js
|
|
19
21
|
* import { solveRoute } from '@esri/arcgis-rest-routing';
|
|
20
|
-
*
|
|
22
|
+
*
|
|
21
23
|
* solveRoute({
|
|
22
24
|
* stops: [
|
|
23
25
|
* [-117.195677, 34.056383],
|
|
@@ -27,7 +29,6 @@ function isLocation(coords) {
|
|
|
27
29
|
* })
|
|
28
30
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
29
31
|
* ```
|
|
30
|
-
* 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.
|
|
31
32
|
*
|
|
32
33
|
* @param requestOptions Options to pass through to the routing service.
|
|
33
34
|
* @returns A Promise that will resolve with routes and directions for the request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solveRoute.js","sourceRoot":"","sources":["../../src/solveRoute.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,mEAOmC;AAEnC,6CAKsB;AAEtB,gDAAsD;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,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AuC,EAAE,EAAE;gBAC1C,OAAO,CAAC,QAAQ,GAAG,IAAA,+BAAkB,EAAC,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,IAAA,wBAAe,EAAC,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,kBAAe;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"]}
|
|
@@ -47,9 +47,11 @@ export interface IClosestFacilityResponse {
|
|
|
47
47
|
polylineBarriers?: IFeatureSet;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
+
* Used to find a route to the nearest of several possible destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/closest-facility-synchronous-service.htm) for more information.
|
|
51
|
+
*
|
|
50
52
|
* ```js
|
|
51
53
|
* import { closestFacility } from '@esri/arcgis-rest-routing';
|
|
52
|
-
*
|
|
54
|
+
*
|
|
53
55
|
* closestFacility({
|
|
54
56
|
* incidents: [
|
|
55
57
|
* [-90.404302, 38.600621],
|
|
@@ -64,7 +66,6 @@ export interface IClosestFacilityResponse {
|
|
|
64
66
|
* })
|
|
65
67
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
66
68
|
* ```
|
|
67
|
-
* Used to find a route to the nearest of several possible destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/closest-facility-synchronous-service.htm) for more information.
|
|
68
69
|
*
|
|
69
70
|
* @param requestOptions Options to pass through to the routing service.
|
|
70
71
|
* @returns A Promise that will resolve with routes and directions for the request.
|
|
@@ -12,9 +12,11 @@ function getTravelDirection(key) {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
+
* Used to find a route to the nearest of several possible destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/closest-facility-synchronous-service.htm) for more information.
|
|
16
|
+
*
|
|
15
17
|
* ```js
|
|
16
18
|
* import { closestFacility } from '@esri/arcgis-rest-routing';
|
|
17
|
-
*
|
|
19
|
+
*
|
|
18
20
|
* closestFacility({
|
|
19
21
|
* incidents: [
|
|
20
22
|
* [-90.404302, 38.600621],
|
|
@@ -29,7 +31,6 @@ function getTravelDirection(key) {
|
|
|
29
31
|
* })
|
|
30
32
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
31
33
|
* ```
|
|
32
|
-
* Used to find a route to the nearest of several possible destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/closest-facility-synchronous-service.htm) for more information.
|
|
33
34
|
*
|
|
34
35
|
* @param requestOptions Options to pass through to the routing service.
|
|
35
36
|
* @returns A Promise that will resolve with routes and directions for the request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closestFacility.js","sourceRoot":"","sources":["../../src/closestFacility.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,kBAAkB,EAKnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,kCAAkC,EAElC,sBAAsB,EACtB,YAAY,EACb,MAAM,cAAc,CAA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AI,CAAC,GAAG,CAAC,CAAC;SACb;KACF;IAED,OAAO,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC,IAAI,CACxE,aAAa,CACd,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,GAAQ;IAC7B,qCAAqC;IACrC,IAAI,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,KAAK,IAAI,EAAE;QAC7C,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KAClD;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,eAAe;IACb,eAAe;CAChB,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 IFeature,\n IFeatureSet\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_CLOSEST_FACILITY_URL,\n IEndpointOptions,\n normalizeLocationsList,\n isFeatureSet\n} from \"./helpers.js\";\n\nimport { arcgisToGeoJSON } from \"@terraformer/arcgis\";\n\nexport interface IClosestFacilityOptions extends IEndpointOptions {\n /**\n * Specify one or more locations from which the service searches for the nearby locations. These locations are referred to as incidents.\n */\n incidents: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n\n /**\n * Specify one or more locations that are searched for when finding the closest location.\n */\n facilities: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n /**\n * Specify if the service should return routes.\n */\n returnCFRoutes: boolean;\n travelDirection?: \"incidentsToFacilities\" | \"facilitiesToIncidents\";\n barriers?: Array<IPoint | ILocation | [number, number]> | IFeatureSet;\n polylineBarriers?: IFeatureSet;\n polygonBarriers?: IFeatureSet;\n returnDirections?: boolean;\n directionsOutputType?:\n | \"esriDOTComplete\"\n | \"esriDOTCompleteNoEvents\"\n | \"esriDOTInstructionsOnly\"\n | \"esriDOTStandard\"\n | \"esriDOTSummaryOnly\"\n | \"esriDOTFeatureSets\";\n directionsLengthUnits?:\n | \"esriNAUCentimeters\"\n | \"esriNAUDecimalDegrees\"\n | \"esriNAUDecimeters\"\n | \"esriNAUFeet\"\n | \"esriNAUInches\"\n | \"esriNAUKilometers\"\n | \"esriNAUMeters\"\n | \"esriNAUMiles\"\n | \"esriNAUMillimeters\"\n | \"esriNAUNauticalMiles\"\n | \"esriNAUPoints\"\n | \"esriNAUYards\";\n outputLines?: boolean;\n returnFacilities?: boolean;\n returnIncidents?: 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 IClosestFacilityResponse {\n messages: string[];\n routes?: IFeatureSetWithGeoJson;\n directions?: Array<{\n routeId: number;\n routeName: string;\n summary: object;\n features: IFeature[];\n }>;\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 a route to the nearest of several possible destinations. See the [REST Documentation](https://developers.arcgis.com/rest/network/api-reference/closest-facility-synchronous-service.htm) for more information.\n *\n * ```js\n * import { closestFacility } from '@esri/arcgis-rest-routing';\n *\n * closestFacility({\n * incidents: [\n * [-90.404302, 38.600621],\n * [-90.364293, 38.620427],\n * ],\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 routes and directions for the request.\n * @restlink https://developers.arcgis.com/rest/network/api-reference/closest-facility-synchronous-service.htm\n * @inline IClosestFacilityOptions\n */\nexport function closestFacility(\n requestOptions: IClosestFacilityOptions\n): Promise<IClosestFacilityResponse> {\n const endpoint =\n requestOptions.endpoint || ARCGIS_ONLINE_CLOSEST_FACILITY_URL;\n\n requestOptions.params = {\n returnFacilities: true,\n returnDirections: true,\n returnIncidents: true,\n returnBarriers: true,\n returnPolylineBarriers: true,\n returnPolygonBarriers: true,\n preserveObjectID: true,\n ...requestOptions.params\n };\n\n const options = appendCustomParams<IClosestFacilityOptions>(requestOptions, [\n \"returnCFRoutes\",\n // \"travelDirection\",\n \"barriers\",\n \"polylineBarriers\",\n \"polygonBarriers\",\n \"returnDirections\",\n \"directionsOutputType\",\n \"directionsLengthUnits\",\n \"outputLines\",\n \"returnFacilities\",\n \"returnIncidents\",\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_CLOSEST_FACILITY_URL\n ) {\n return Promise.reject(\n \"Finding the closest facility using the ArcGIS service requires authentication\"\n );\n }\n\n if (isFeatureSet(requestOptions.incidents)) {\n options.params.incidents = requestOptions.incidents;\n } else {\n options.params.incidents = normalizeLocationsList(\n requestOptions.incidents\n ).join(\";\");\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)}/solveClosestFacility`, options).then(\n cleanResponse\n );\n}\n\nfunction cleanResponse(res: any): IClosestFacilityResponse {\n // add \"geoJson\" property to \"routes\"\n if (res.routes.spatialReference.wkid === 4326) {\n res.routes.geoJson = arcgisToGeoJSON(res.routes);\n }\n return res;\n}\n\nexport default {\n closestFacility\n};\n"]}
|
|
@@ -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.
|
|
@@ -4,9 +4,11 @@ import { request, cleanUrl, appendCustomParams } from "@esri/arcgis-rest-request
|
|
|
4
4
|
import { ARCGIS_ONLINE_ORIGIN_DESTINATION_MATRIX_URL, normalizeLocationsList, isFeatureSet } from "./helpers.js";
|
|
5
5
|
import { arcgisToGeoJSON } from "@terraformer/arcgis";
|
|
6
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
|
+
*
|
|
7
9
|
* ```js
|
|
8
10
|
* import { originDestinationMatrix } from '@esri/arcgis-rest-routing';
|
|
9
|
-
*
|
|
11
|
+
*
|
|
10
12
|
* originDestinationMatrix({
|
|
11
13
|
* origins: [
|
|
12
14
|
* [-90.404302, 38.600621],
|
|
@@ -21,7 +23,6 @@ import { arcgisToGeoJSON } from "@terraformer/arcgis";
|
|
|
21
23
|
* })
|
|
22
24
|
* .then(response) // => { ... }
|
|
23
25
|
* ```
|
|
24
|
-
* 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.
|
|
25
26
|
*
|
|
26
27
|
* @param requestOptions Options to pass through to the routing service.
|
|
27
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.
|
|
@@ -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,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;;;;;;;;;;;;;;;;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AAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,KAAK,IAAI,EAAE;QAC/D,GAAG,CAAC,QAAQ,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;KACtD;IAED,IACE,GAAG,CAAC,eAAe;QACnB,GAAG,CAAC,eAAe,CAAC,gBAAgB,CAAC,IAAI,KAAK,IAAI,EAClD;QACA,GAAG,CAAC,eAAe,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KACpE;IAED,IACE,GAAG,CAAC,gBAAgB;QACpB,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;CACxB,CAAC","sourcesContent":["/* Copyright (c) 2018 Environmental Systems 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 * ```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 * 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 * @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
|
+
{"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,cAA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AAG,CAAC,QAAQ,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;KACtD;IAED,IACE,GAAG,CAAC,eAAe;QACnB,GAAG,CAAC,eAAe,CAAC,gBAAgB,CAAC,IAAI,KAAK,IAAI,EAClD;QACA,GAAG,CAAC,eAAe,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KACpE;IAED,IACE,GAAG,CAAC,gBAAgB;QACpB,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;CACxB,CAAC","sourcesContent":["/* Copyright (c) 2018 Environmental Systems 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"]}
|
|
@@ -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
|
@@ -12,9 +12,11 @@ function getTravelDirection(key) {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
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
|
+
*
|
|
15
17
|
* ```js
|
|
16
18
|
* import { serviceArea } from '@esri/arcgis-rest-routing';
|
|
17
|
-
*
|
|
19
|
+
*
|
|
18
20
|
* serviceArea({
|
|
19
21
|
* facilities: [
|
|
20
22
|
* [-90.444716, 38.635501],
|
|
@@ -25,7 +27,6 @@ function getTravelDirection(key) {
|
|
|
25
27
|
* })
|
|
26
28
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
27
29
|
* ```
|
|
28
|
-
* 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.
|
|
29
30
|
*
|
|
30
31
|
* @param requestOptions Options to pass through to the routing service.
|
|
31
32
|
* @returns A Promise that will resolve with service area polygons for the request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceArea.js","sourceRoot":"","sources":["../../src/serviceArea.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,kBAAkB,EAInB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,8BAA8B,EAE9B,sBAAsB,EACtB,YAAY,EACb,MAAM,cAAc,CAAC;AAEtB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G,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
|
@@ -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
|
@@ -12,9 +12,11 @@ function isLocation(coords) {
|
|
|
12
12
|
coords.lat !== undefined);
|
|
13
13
|
}
|
|
14
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
|
+
*
|
|
15
17
|
* ```js
|
|
16
18
|
* import { solveRoute } from '@esri/arcgis-rest-routing';
|
|
17
|
-
*
|
|
19
|
+
*
|
|
18
20
|
* solveRoute({
|
|
19
21
|
* stops: [
|
|
20
22
|
* [-117.195677, 34.056383],
|
|
@@ -24,7 +26,6 @@ function isLocation(coords) {
|
|
|
24
26
|
* })
|
|
25
27
|
* .then(response) // => {routes: {features: [{attributes: { ... }, geometry:{ ... }}]}
|
|
26
28
|
* ```
|
|
27
|
-
* 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.
|
|
28
29
|
*
|
|
29
30
|
* @param requestOptions Options to pass through to the routing service.
|
|
30
31
|
* @returns A Promise that will resolve with routes and directions for the request.
|