ducimusipsa 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.prettierignore +2 -0
- package/.travis.yml +34 -0
- package/.vscode/launch.json +24 -0
- package/.vscode/settings.json +3 -0
- package/demos/ago-node-cli/README.md +29 -0
- package/demos/ago-node-cli/ago.js +32 -0
- package/demos/ago-node-cli/index.js +11 -0
- package/demos/ago-node-cli/lib/item-export-command.js +48 -0
- package/demos/ago-node-cli/lib/item-search-command.js +35 -0
- package/demos/ago-node-cli/package-lock.json +180 -0
- package/demos/ago-node-cli/package.json +30 -0
- package/demos/attachments/README.md +5 -0
- package/demos/attachments/index.html +164 -0
- package/demos/attachments/package-lock.json +182 -0
- package/demos/attachments/package.json +18 -0
- package/demos/batch-geocoder-node/NYC_Restaurant_Inspection_Results.csv +100 -0
- package/demos/batch-geocoder-node/README.md +15 -0
- package/demos/batch-geocoder-node/batch-geocode.js +115 -0
- package/demos/batch-geocoder-node/config-template.js +18 -0
- package/demos/batch-geocoder-node/package-lock.json +109 -0
- package/demos/batch-geocoder-node/package.json +38 -0
- package/demos/express/README.md +15 -0
- package/demos/express/config.json.template +3 -0
- package/demos/express/package-lock.json +428 -0
- package/demos/express/package.json +18 -0
- package/demos/express/server.js +33 -0
- package/demos/feature-service-browser/README.md +6 -0
- package/demos/feature-service-browser/index.html +122 -0
- package/demos/feature-service-browser/package-lock.json +182 -0
- package/demos/feature-service-browser/package.json +18 -0
- package/demos/geocoder-browser/README.md +10 -0
- package/demos/geocoder-browser/config.js.template +1 -0
- package/demos/geocoder-browser/index.html +131 -0
- package/demos/geocoder-browser/package-lock.json +182 -0
- package/demos/geocoder-browser/package.json +19 -0
- package/demos/geocoder-browser/post-sign-in.html +25 -0
- package/demos/jsapi-integration/README.md +25 -0
- package/demos/jsapi-integration/config.js +6 -0
- package/demos/jsapi-integration/index.html +85 -0
- package/demos/jsapi-integration/package-lock.json +184 -0
- package/demos/jsapi-integration/package.json +19 -0
- package/demos/oauth2-browser/README.md +14 -0
- package/demos/oauth2-browser/authenticate.html +32 -0
- package/demos/oauth2-browser/config.js.template +6 -0
- package/demos/oauth2-browser/index.html +202 -0
- package/demos/oauth2-browser/logo.svg +4 -0
- package/demos/oauth2-browser/package-lock.json +163 -0
- package/demos/oauth2-browser/package.json +18 -0
- package/demos/oauth2-browser/style.css +36 -0
- package/demos/oauth2-browser-retry/README.md +25 -0
- package/demos/oauth2-browser-retry/authenticate.html +21 -0
- package/demos/oauth2-browser-retry/index.html +116 -0
- package/demos/oauth2-browser-retry/logo.svg +4 -0
- package/demos/vue/.env.example +11 -0
- package/demos/vue/.eslintrc.js +17 -0
- package/demos/vue/.postcssrc.js +5 -0
- package/demos/vue/README.md +17 -0
- package/demos/vue/babel.config.js +3 -0
- package/demos/vue/package-lock.json +11323 -0
- package/demos/vue/package.json +33 -0
- package/demos/vue/public/favicon.ico +0 -0
- package/demos/vue/public/index.html +24 -0
- package/demos/vue/src/assets/logo.svg +29 -0
- package/demos/vue/src/components/App.vue +308 -0
- package/demos/vue/src/components/Authenticate.vue +65 -0
- package/demos/vue/src/components/Loader.vue +230 -0
- package/demos/vue/src/main.js +92 -0
- package/docs/FAQ.md +28 -0
- package/docs/HISTORY.md +62 -0
- package/docs/acetate.config.js +223 -0
- package/docs/build-typedoc.js +303 -0
- package/docs/src/_layout.html +82 -0
- package/docs/src/api/_declaration.html +496 -0
- package/docs/src/api/_layout.html +127 -0
- package/docs/src/api/_package.html +13 -0
- package/docs/src/api/index.html +23 -0
- package/docs/src/guides/_layout.html +24 -0
- package/docs/src/guides/amd-requirejs-dojo.md +40 -0
- package/docs/src/guides/babel-and-rollup.md +30 -0
- package/docs/src/guides/babel-and-webpack.md +30 -0
- package/docs/src/guides/browser-authentication.md +41 -0
- package/docs/src/guides/browserify.md +9 -0
- package/docs/src/guides/cli-authentication.md +9 -0
- package/docs/src/guides/client-server-authentication.md +9 -0
- package/docs/src/guides/from-a-cdn.md +36 -0
- package/docs/src/guides/index.md +52 -0
- package/docs/src/guides/node.md +70 -0
- package/docs/src/guides/package-overview.md +8 -0
- package/docs/src/guides/server-authentication.md +9 -0
- package/docs/src/guides/typescript-and-webpack.md +9 -0
- package/docs/src/img/icons.png +0 -0
- package/docs/src/img/icons@2x.png +0 -0
- package/docs/src/index.html +12 -0
- package/docs/src/js/api-search.js +112 -0
- package/docs/src/js/nav-toggle.js +41 -0
- package/docs/src/sass/_highlight.scss +96 -0
- package/docs/src/sass/_icons.scss +157 -0
- package/docs/src/sass/style.scss +169 -0
- package/jasmine.json +7 -0
- package/karma.conf.js +100 -0
- package/lerna.json +8 -0
- package/notes/README.md +88 -0
- package/package.json +129 -0
- package/packages/arcgis-rest-auth/README.md +67 -0
- package/packages/arcgis-rest-auth/package-lock.json +11 -0
- package/packages/arcgis-rest-auth/package.json +53 -0
- package/packages/arcgis-rest-auth/src/ApplicationSession.ts +108 -0
- package/packages/arcgis-rest-auth/src/UserSession.ts +880 -0
- package/packages/arcgis-rest-auth/src/authenticated-request-options.ts +24 -0
- package/packages/arcgis-rest-auth/src/fetch-token.ts +52 -0
- package/packages/arcgis-rest-auth/src/generate-token.ts +39 -0
- package/packages/arcgis-rest-auth/src/index.ts +8 -0
- package/packages/arcgis-rest-auth/test/ApplicationSession.test.ts +124 -0
- package/packages/arcgis-rest-auth/test/UserSession.test.ts +1005 -0
- package/packages/arcgis-rest-auth/test/fetchToken.test.ts +112 -0
- package/packages/arcgis-rest-auth/test/generateToken.test.ts +130 -0
- package/packages/arcgis-rest-auth/test/utils.ts +14 -0
- package/packages/arcgis-rest-auth/tsconfig.json +6 -0
- package/packages/arcgis-rest-common/README.md +57 -0
- package/packages/arcgis-rest-common/package-lock.json +11 -0
- package/packages/arcgis-rest-common/package.json +41 -0
- package/packages/arcgis-rest-common/src/index.ts +10 -0
- package/packages/arcgis-rest-common/src/types/feature.ts +14 -0
- package/packages/arcgis-rest-common/src/types/geometry.ts +47 -0
- package/packages/arcgis-rest-common/src/types/symbol.ts +21 -0
- package/packages/arcgis-rest-common/src/util/location.ts +19 -0
- package/packages/arcgis-rest-common/test/location.test.ts +73 -0
- package/packages/arcgis-rest-common/tsconfig.json +6 -0
- package/packages/arcgis-rest-common-types/README.md +64 -0
- package/packages/arcgis-rest-common-types/package.json +40 -0
- package/packages/arcgis-rest-common-types/src/group.ts +54 -0
- package/packages/arcgis-rest-common-types/src/index.ts +469 -0
- package/packages/arcgis-rest-common-types/src/item.ts +47 -0
- package/packages/arcgis-rest-common-types/src/webmap.ts +1267 -0
- package/packages/arcgis-rest-common-types/tsconfig.json +11 -0
- package/packages/arcgis-rest-feature-service/README.md +73 -0
- package/packages/arcgis-rest-feature-service/package-lock.json +11 -0
- package/packages/arcgis-rest-feature-service/package.json +53 -0
- package/packages/arcgis-rest-feature-service/src/add.ts +90 -0
- package/packages/arcgis-rest-feature-service/src/addAttachment.ts +64 -0
- package/packages/arcgis-rest-feature-service/src/decodeValues.ts +129 -0
- package/packages/arcgis-rest-feature-service/src/delete.ts +97 -0
- package/packages/arcgis-rest-feature-service/src/deleteAttachments.ts +67 -0
- package/packages/arcgis-rest-feature-service/src/getAttachments.ts +64 -0
- package/packages/arcgis-rest-feature-service/src/getLayer.ts +27 -0
- package/packages/arcgis-rest-feature-service/src/helpers.ts +50 -0
- package/packages/arcgis-rest-feature-service/src/index.ts +14 -0
- package/packages/arcgis-rest-feature-service/src/query.ts +183 -0
- package/packages/arcgis-rest-feature-service/src/queryRelated.ts +94 -0
- package/packages/arcgis-rest-feature-service/src/update.ts +90 -0
- package/packages/arcgis-rest-feature-service/src/updateAttachment.ts +73 -0
- package/packages/arcgis-rest-feature-service/test/attachments.test.ts +203 -0
- package/packages/arcgis-rest-feature-service/test/crud.test.ts +263 -0
- package/packages/arcgis-rest-feature-service/test/decodeValues.test.ts +67 -0
- package/packages/arcgis-rest-feature-service/test/getLayer.test.ts +31 -0
- package/packages/arcgis-rest-feature-service/test/mocks/cvdQueryResponse.ts +225 -0
- package/packages/arcgis-rest-feature-service/test/mocks/feature.ts +281 -0
- package/packages/arcgis-rest-feature-service/test/mocks/fields.ts +779 -0
- package/packages/arcgis-rest-feature-service/test/mocks/foo.txt +1 -0
- package/packages/arcgis-rest-feature-service/test/mocks/service.ts +259 -0
- package/packages/arcgis-rest-feature-service/test/query.test.ts +140 -0
- package/packages/arcgis-rest-feature-service/tsconfig.json +6 -0
- package/packages/arcgis-rest-feature-service-admin/README.md +69 -0
- package/packages/arcgis-rest-feature-service-admin/package-lock.json +11 -0
- package/packages/arcgis-rest-feature-service-admin/package.json +56 -0
- package/packages/arcgis-rest-feature-service-admin/src/addTo.ts +74 -0
- package/packages/arcgis-rest-feature-service-admin/src/create.ts +207 -0
- package/packages/arcgis-rest-feature-service-admin/src/index.ts +2 -0
- package/packages/arcgis-rest-feature-service-admin/test/addTo.test.ts +353 -0
- package/packages/arcgis-rest-feature-service-admin/test/create.test.ts +412 -0
- package/packages/arcgis-rest-feature-service-admin/test/mocks/layerDefinition.ts +79 -0
- package/packages/arcgis-rest-feature-service-admin/test/mocks/move.ts +14 -0
- package/packages/arcgis-rest-feature-service-admin/test/mocks/service.ts +72 -0
- package/packages/arcgis-rest-feature-service-admin/tsconfig.json +6 -0
- package/packages/arcgis-rest-geocoder/README.md +83 -0
- package/packages/arcgis-rest-geocoder/package-lock.json +11 -0
- package/packages/arcgis-rest-geocoder/package.json +55 -0
- package/packages/arcgis-rest-geocoder/src/bulk.ts +102 -0
- package/packages/arcgis-rest-geocoder/src/geocode.ts +130 -0
- package/packages/arcgis-rest-geocoder/src/helpers.ts +80 -0
- package/packages/arcgis-rest-geocoder/src/index.ts +8 -0
- package/packages/arcgis-rest-geocoder/src/reverse.ts +83 -0
- package/packages/arcgis-rest-geocoder/src/suggest.ts +69 -0
- package/packages/arcgis-rest-geocoder/test/bulk.test.ts +113 -0
- package/packages/arcgis-rest-geocoder/test/geocode.test.ts +176 -0
- package/packages/arcgis-rest-geocoder/test/helpers.test.ts +111 -0
- package/packages/arcgis-rest-geocoder/test/mocks/responses.ts +629 -0
- package/packages/arcgis-rest-geocoder/test/reverse.test.ts +126 -0
- package/packages/arcgis-rest-geocoder/test/suggest.test.ts +98 -0
- package/packages/arcgis-rest-geocoder/tsconfig.json +6 -0
- package/packages/arcgis-rest-groups/README.md +67 -0
- package/packages/arcgis-rest-groups/package-lock.json +11 -0
- package/packages/arcgis-rest-groups/package.json +55 -0
- package/packages/arcgis-rest-groups/src/create.ts +34 -0
- package/packages/arcgis-rest-groups/src/get.ts +95 -0
- package/packages/arcgis-rest-groups/src/helpers.ts +27 -0
- package/packages/arcgis-rest-groups/src/index.ts +11 -0
- package/packages/arcgis-rest-groups/src/notification.ts +77 -0
- package/packages/arcgis-rest-groups/src/protect.ts +40 -0
- package/packages/arcgis-rest-groups/src/remove.ts +23 -0
- package/packages/arcgis-rest-groups/src/search.ts +64 -0
- package/packages/arcgis-rest-groups/src/update.ts +36 -0
- package/packages/arcgis-rest-groups/test/crud.test.ts +134 -0
- package/packages/arcgis-rest-groups/test/get.test.ts +101 -0
- package/packages/arcgis-rest-groups/test/mocks/responses.ts +141 -0
- package/packages/arcgis-rest-groups/test/notification.test.ts +102 -0
- package/packages/arcgis-rest-groups/test/protect.test.ts +64 -0
- package/packages/arcgis-rest-groups/test/search.test.ts +85 -0
- package/packages/arcgis-rest-groups/tsconfig.json +6 -0
- package/packages/arcgis-rest-items/README.md +69 -0
- package/packages/arcgis-rest-items/package-lock.json +11 -0
- package/packages/arcgis-rest-items/package.json +55 -0
- package/packages/arcgis-rest-items/src/add.ts +103 -0
- package/packages/arcgis-rest-items/src/create.ts +110 -0
- package/packages/arcgis-rest-items/src/get.ts +79 -0
- package/packages/arcgis-rest-items/src/helpers.ts +147 -0
- package/packages/arcgis-rest-items/src/index.ts +11 -0
- package/packages/arcgis-rest-items/src/protect.ts +38 -0
- package/packages/arcgis-rest-items/src/remove.ts +58 -0
- package/packages/arcgis-rest-items/src/search.ts +78 -0
- package/packages/arcgis-rest-items/src/update.ts +134 -0
- package/packages/arcgis-rest-items/test/add.test.ts +256 -0
- package/packages/arcgis-rest-items/test/create.test.ts +371 -0
- package/packages/arcgis-rest-items/test/get.test.ts +181 -0
- package/packages/arcgis-rest-items/test/mocks/foo.zip +0 -0
- package/packages/arcgis-rest-items/test/mocks/item.ts +35 -0
- package/packages/arcgis-rest-items/test/mocks/resources.ts +31 -0
- package/packages/arcgis-rest-items/test/mocks/search.ts +62 -0
- package/packages/arcgis-rest-items/test/protect.test.ts +122 -0
- package/packages/arcgis-rest-items/test/remove.test.ts +161 -0
- package/packages/arcgis-rest-items/test/search.test.ts +159 -0
- package/packages/arcgis-rest-items/test/update.test.ts +450 -0
- package/packages/arcgis-rest-items/tsconfig.json +6 -0
- package/packages/arcgis-rest-request/README.md +68 -0
- package/packages/arcgis-rest-request/package-lock.json +11 -0
- package/packages/arcgis-rest-request/package.json +45 -0
- package/packages/arcgis-rest-request/src/index.ts +15 -0
- package/packages/arcgis-rest-request/src/request.ts +358 -0
- package/packages/arcgis-rest-request/src/utils/ArcGISRequestError.ts +76 -0
- package/packages/arcgis-rest-request/src/utils/ErrorTypes.ts +29 -0
- package/packages/arcgis-rest-request/src/utils/append-custom-params.ts +29 -0
- package/packages/arcgis-rest-request/src/utils/encode-form-data.ts +34 -0
- package/packages/arcgis-rest-request/src/utils/encode-query-string.ts +23 -0
- package/packages/arcgis-rest-request/src/utils/get-portal-url.ts +25 -0
- package/packages/arcgis-rest-request/src/utils/get-portal.ts +45 -0
- package/packages/arcgis-rest-request/src/utils/params.ts +52 -0
- package/packages/arcgis-rest-request/src/utils/process-params.ts +99 -0
- package/packages/arcgis-rest-request/src/utils/retryAuthError.ts +9 -0
- package/packages/arcgis-rest-request/src/utils/warn.ts +11 -0
- package/packages/arcgis-rest-request/test/mocks/errors.ts +68 -0
- package/packages/arcgis-rest-request/test/mocks/geojson-feature-collection.ts +13 -0
- package/packages/arcgis-rest-request/test/mocks/portal.ts +112 -0
- package/packages/arcgis-rest-request/test/mocks/sharing-rest-info.ts +41 -0
- package/packages/arcgis-rest-request/test/mocks/webmap.ts +41 -0
- package/packages/arcgis-rest-request/test/request.test.ts +323 -0
- package/packages/arcgis-rest-request/test/utils/ArcGISAuthError.test.ts +170 -0
- package/packages/arcgis-rest-request/test/utils/ArcGISRequestError.test.ts +51 -0
- package/packages/arcgis-rest-request/test/utils/check-for-errors.test.ts +111 -0
- package/packages/arcgis-rest-request/test/utils/encode-form-data.test.ts +133 -0
- package/packages/arcgis-rest-request/test/utils/get-portal-url.test.ts +37 -0
- package/packages/arcgis-rest-request/test/utils/portal.test.ts +97 -0
- package/packages/arcgis-rest-request/test/utils/process-params.test.ts +193 -0
- package/packages/arcgis-rest-request/tsconfig.json +6 -0
- package/packages/arcgis-rest-routing/README.md +71 -0
- package/packages/arcgis-rest-routing/package-lock.json +11 -0
- package/packages/arcgis-rest-routing/package.json +54 -0
- package/packages/arcgis-rest-routing/src/helpers.ts +16 -0
- package/packages/arcgis-rest-routing/src/index.ts +4 -0
- package/packages/arcgis-rest-routing/src/solveRoute.ts +102 -0
- package/packages/arcgis-rest-routing/test/mocks/responses.ts +825 -0
- package/packages/arcgis-rest-routing/test/solveRoute.test.ts +267 -0
- package/packages/arcgis-rest-routing/tsconfig.json +6 -0
- package/packages/arcgis-rest-sharing/README.md +70 -0
- package/packages/arcgis-rest-sharing/package-lock.json +11 -0
- package/packages/arcgis-rest-sharing/package.json +60 -0
- package/packages/arcgis-rest-sharing/src/access.ts +85 -0
- package/packages/arcgis-rest-sharing/src/group-sharing.ts +211 -0
- package/packages/arcgis-rest-sharing/src/helpers.ts +82 -0
- package/packages/arcgis-rest-sharing/src/index.ts +5 -0
- package/packages/arcgis-rest-sharing/test/access.test.ts +154 -0
- package/packages/arcgis-rest-sharing/test/group-sharing.test.ts +566 -0
- package/packages/arcgis-rest-sharing/test/helpers.test.ts +55 -0
- package/packages/arcgis-rest-sharing/test/mocks/sharing.ts +18 -0
- package/packages/arcgis-rest-sharing/tsconfig.json +6 -0
- package/packages/arcgis-rest-users/README.md +74 -0
- package/packages/arcgis-rest-users/package-lock.json +11 -0
- package/packages/arcgis-rest-users/package.json +54 -0
- package/packages/arcgis-rest-users/src/get.ts +69 -0
- package/packages/arcgis-rest-users/src/index.ts +6 -0
- package/packages/arcgis-rest-users/src/invitation.ts +166 -0
- package/packages/arcgis-rest-users/src/notification.ts +73 -0
- package/packages/arcgis-rest-users/test/get.test.ts +99 -0
- package/packages/arcgis-rest-users/test/invitation.test.ts +169 -0
- package/packages/arcgis-rest-users/test/mocks/invitation.ts +70 -0
- package/packages/arcgis-rest-users/test/mocks/notification.ts +34 -0
- package/packages/arcgis-rest-users/test/mocks/user.ts +173 -0
- package/packages/arcgis-rest-users/test/notification.test.ts +83 -0
- package/packages/arcgis-rest-users/tsconfig.json +6 -0
- package/support/changelog.js +394 -0
- package/support/deploy-doc-site.js +16 -0
- package/support/dev.sh +6 -0
- package/support/publish.sh +43 -0
- package/support/test-helpers.js +8 -0
- package/tsconfig.json +69 -0
- package/tslint.json +16 -0
- package/umd-base-profile.js +82 -0
- package/umd-production-profile.js +13 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
{
|
2
|
+
"name": "@esri/arcgis-rest-geocoder",
|
3
|
+
"version": "1.14.1",
|
4
|
+
"description": "Geocoding helpers for @esri/arcgis-rest-request",
|
5
|
+
"main": "dist/node/index.js",
|
6
|
+
"browser": "dist/umd/geocoder.umd.js",
|
7
|
+
"module": "dist/esm/index.js",
|
8
|
+
"js:next": "dist/esm/index.js",
|
9
|
+
"types": "dist/esm/index.d.ts",
|
10
|
+
"license": "Apache-2.0",
|
11
|
+
"files": [
|
12
|
+
"dist/**"
|
13
|
+
],
|
14
|
+
"dependencies": {
|
15
|
+
"tslib": "^1.7.1"
|
16
|
+
},
|
17
|
+
"devDependencies": {
|
18
|
+
"@esri/arcgis-rest-auth": "^1.14.1",
|
19
|
+
"@esri/arcgis-rest-common-types": "^1.14.1",
|
20
|
+
"@esri/arcgis-rest-request": "^1.14.1"
|
21
|
+
},
|
22
|
+
"peerDependencies": {
|
23
|
+
"@esri/arcgis-rest-auth": "^1.14.1",
|
24
|
+
"@esri/arcgis-rest-common-types": "^1.14.1",
|
25
|
+
"@esri/arcgis-rest-request": "^1.14.1"
|
26
|
+
},
|
27
|
+
"scripts": {
|
28
|
+
"prepare": "npm run build",
|
29
|
+
"build": "npm run build:node && npm run build:umd && npm run build:esm",
|
30
|
+
"build:esm": "tsc -p ./tsconfig.json --module es2015 --outDir ./dist/esm --declaration",
|
31
|
+
"build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js",
|
32
|
+
"build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node",
|
33
|
+
"dev:esm": "tsc -w --module es2015 --outDir ./dist/esm --declaration",
|
34
|
+
"dev:umd": "rollup -w -c ../../umd-base-profile.js",
|
35
|
+
"dev:node": "tsc -w --module commonjs --outDir ./dist/node"
|
36
|
+
},
|
37
|
+
"publishConfig": {
|
38
|
+
"access": "public"
|
39
|
+
},
|
40
|
+
"repository": {
|
41
|
+
"type": "git",
|
42
|
+
"url": "git+https://github.com/Esri/arcgis-rest-js.git"
|
43
|
+
},
|
44
|
+
"contributors": [
|
45
|
+
{
|
46
|
+
"name": "Patrick Arlt",
|
47
|
+
"email": "parlt@esri.com",
|
48
|
+
"url": "http://patrickarlt.com/"
|
49
|
+
}
|
50
|
+
],
|
51
|
+
"bugs": {
|
52
|
+
"url": "https://github.com/Esri/arcgis-rest-js/issues"
|
53
|
+
},
|
54
|
+
"homepage": "https://github.com/Esri/arcgis-rest-js#readme"
|
55
|
+
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request } from "@esri/arcgis-rest-request";
|
5
|
+
|
6
|
+
import { ISpatialReference, IPoint } from "@esri/arcgis-rest-common-types";
|
7
|
+
|
8
|
+
import { worldGeocoder, IEndpointRequestOptions } from "./helpers";
|
9
|
+
|
10
|
+
// it'd be better if doc didnt display these properties in alphabetical order
|
11
|
+
export interface IAddressBulk {
|
12
|
+
/**
|
13
|
+
* A unique id must be passed along for each individual address.
|
14
|
+
*/
|
15
|
+
OBJECTID: number;
|
16
|
+
address?: string;
|
17
|
+
address2?: string;
|
18
|
+
address3?: string;
|
19
|
+
neighborhood?: string;
|
20
|
+
city?: string;
|
21
|
+
subregion?: string;
|
22
|
+
/**
|
23
|
+
* The World Geocoding Service considers US states regions.
|
24
|
+
*/
|
25
|
+
region?: string;
|
26
|
+
postal?: number;
|
27
|
+
postalExt?: number;
|
28
|
+
countryCode?: string;
|
29
|
+
}
|
30
|
+
|
31
|
+
export interface IBulkGeocodeRequestOptions extends IEndpointRequestOptions {
|
32
|
+
addresses: IAddressBulk[];
|
33
|
+
}
|
34
|
+
|
35
|
+
export interface IBulkGeocodeResponse {
|
36
|
+
spatialReference: ISpatialReference;
|
37
|
+
locations: Array<{
|
38
|
+
address: string;
|
39
|
+
location: IPoint;
|
40
|
+
score: number;
|
41
|
+
attributes: object;
|
42
|
+
}>;
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Used to geocode a [batch](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-geocode-addresses.htm) of addresses.
|
47
|
+
*
|
48
|
+
* ```js
|
49
|
+
* import { bulkGeocode } from '@esri/arcgis-rest-geocoder';
|
50
|
+
* import { ApplicationSession } from '@esri/arcgis-rest-auth';
|
51
|
+
*
|
52
|
+
* const addresses = [
|
53
|
+
* { "OBJECTID": 1, "SingleLine": "380 New York Street 92373" },
|
54
|
+
* { "OBJECTID": 2, "SingleLine": "1 World Way Los Angeles 90045" }
|
55
|
+
* ];
|
56
|
+
*
|
57
|
+
* bulkGeocode({ addresses, authentication: session })
|
58
|
+
* .then((response) => {
|
59
|
+
* response.locations[0].location; // => { x: -117, y: 34, spatialReference: { wkid: 4326 } }
|
60
|
+
* });
|
61
|
+
* ```
|
62
|
+
*
|
63
|
+
* @param requestOptions - Request options to pass to the geocoder, including an array of addresses and authentication session.
|
64
|
+
* @returns A Promise that will resolve with the data from the response.
|
65
|
+
*/
|
66
|
+
export function bulkGeocode(
|
67
|
+
requestOptions: IBulkGeocodeRequestOptions // must POST
|
68
|
+
) {
|
69
|
+
const options: IBulkGeocodeRequestOptions = {
|
70
|
+
endpoint: worldGeocoder,
|
71
|
+
params: {
|
72
|
+
forStorage: true,
|
73
|
+
addresses: { records: [] }
|
74
|
+
},
|
75
|
+
...requestOptions
|
76
|
+
};
|
77
|
+
|
78
|
+
requestOptions.addresses.forEach(address => {
|
79
|
+
options.params.addresses.records.push({ attributes: address });
|
80
|
+
});
|
81
|
+
|
82
|
+
// the SAS service doesnt support anonymous requests
|
83
|
+
if (!requestOptions.authentication && options.endpoint === worldGeocoder) {
|
84
|
+
return Promise.reject(
|
85
|
+
"bulk geocoding using the ArcGIS service requires authentication"
|
86
|
+
);
|
87
|
+
}
|
88
|
+
|
89
|
+
return request(options.endpoint + "geocodeAddresses", options).then(
|
90
|
+
response => {
|
91
|
+
const sr = response.spatialReference;
|
92
|
+
response.locations.forEach(function(address: { location: IPoint }) {
|
93
|
+
address.location.spatialReference = sr;
|
94
|
+
});
|
95
|
+
return response;
|
96
|
+
}
|
97
|
+
);
|
98
|
+
}
|
99
|
+
|
100
|
+
export default {
|
101
|
+
bulkGeocode
|
102
|
+
};
|
@@ -0,0 +1,130 @@
|
|
1
|
+
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import {
|
5
|
+
request,
|
6
|
+
IParams,
|
7
|
+
appendCustomParams
|
8
|
+
} from "@esri/arcgis-rest-request";
|
9
|
+
|
10
|
+
import {
|
11
|
+
IExtent,
|
12
|
+
ISpatialReference,
|
13
|
+
IPoint
|
14
|
+
} from "@esri/arcgis-rest-common-types";
|
15
|
+
|
16
|
+
import { worldGeocoder, IEndpointRequestOptions } from "./helpers";
|
17
|
+
|
18
|
+
export interface IGeocodeParams extends IParams {
|
19
|
+
/**
|
20
|
+
* You can create an autocomplete experience by making a call to suggest with partial text and then passing through the magicKey and complete address that are returned to geocode.
|
21
|
+
* ```js
|
22
|
+
* import { suggest, geocode } from '@esri/arcgis-rest-geocoder';
|
23
|
+
* suggest("LAX")
|
24
|
+
* .then((response) => {
|
25
|
+
* geocode({
|
26
|
+
* singleLine: response.suggestions[1].text,
|
27
|
+
* magicKey: response.suggestions[0].magicKey
|
28
|
+
* })
|
29
|
+
* })
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
magicKey?: string;
|
33
|
+
}
|
34
|
+
|
35
|
+
export interface IGeocodeRequestOptions extends IEndpointRequestOptions {
|
36
|
+
/**
|
37
|
+
* use this if all your address info is contained in a single string.
|
38
|
+
*/
|
39
|
+
singleLine?: string;
|
40
|
+
address?: string;
|
41
|
+
address2?: string;
|
42
|
+
address3?: string;
|
43
|
+
neighborhood?: string;
|
44
|
+
city?: string;
|
45
|
+
subregion?: string;
|
46
|
+
/**
|
47
|
+
* The World Geocoding Service expects US states to be passed in as a 'region'.
|
48
|
+
*/
|
49
|
+
region?: string;
|
50
|
+
postal?: number;
|
51
|
+
postalExt?: number;
|
52
|
+
countryCode?: string;
|
53
|
+
}
|
54
|
+
|
55
|
+
export interface IGeocodeResponse {
|
56
|
+
spatialReference: ISpatialReference;
|
57
|
+
candidates: Array<{
|
58
|
+
address: string;
|
59
|
+
location: IPoint;
|
60
|
+
extent?: IExtent;
|
61
|
+
score: number;
|
62
|
+
attributes: object;
|
63
|
+
}>;
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Used to determine the location of a single address or point of interest. See the [REST Documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find-address-candidates.htm) for more information.
|
68
|
+
*
|
69
|
+
* ```js
|
70
|
+
* import { geocode } from '@esri/arcgis-rest-geocoder';
|
71
|
+
*
|
72
|
+
* geocode("LAX")
|
73
|
+
* .then((response) => {
|
74
|
+
* response.candidates[0].location; // => { x: -118.409, y: 33.943, spatialReference: ... }
|
75
|
+
* });
|
76
|
+
*
|
77
|
+
* geocode({
|
78
|
+
* address: "1600 Pennsylvania Ave",
|
79
|
+
* postal: 20500,
|
80
|
+
* countryCode: "USA"
|
81
|
+
* })
|
82
|
+
* .then((response) => {
|
83
|
+
* response.candidates[1].location; // => { x: -77.036533, y: 38.898719, spatialReference: ... }
|
84
|
+
* });
|
85
|
+
* ```
|
86
|
+
*
|
87
|
+
* @param address String representing the address or point of interest or RequestOptions to pass to the endpoint.
|
88
|
+
* @returns A Promise that will resolve with address candidates for the request.
|
89
|
+
*/
|
90
|
+
export function geocode(
|
91
|
+
address: string | IGeocodeRequestOptions
|
92
|
+
): Promise<IGeocodeResponse> {
|
93
|
+
let options: IGeocodeRequestOptions = {
|
94
|
+
endpoint: worldGeocoder,
|
95
|
+
params: {}
|
96
|
+
};
|
97
|
+
|
98
|
+
if (typeof address === "string") {
|
99
|
+
options.params.singleLine = address;
|
100
|
+
} else {
|
101
|
+
options.endpoint = address.endpoint || worldGeocoder;
|
102
|
+
options = {
|
103
|
+
...options,
|
104
|
+
...address
|
105
|
+
};
|
106
|
+
|
107
|
+
appendCustomParams(address, options);
|
108
|
+
}
|
109
|
+
|
110
|
+
// add spatialReference property to individual matches
|
111
|
+
return request(options.endpoint + "findAddressCandidates", options).then(
|
112
|
+
response => {
|
113
|
+
const sr = response.spatialReference;
|
114
|
+
response.candidates.forEach(function(candidate: {
|
115
|
+
location: IPoint;
|
116
|
+
extent?: IExtent;
|
117
|
+
}) {
|
118
|
+
candidate.location.spatialReference = sr;
|
119
|
+
if (candidate.extent) {
|
120
|
+
candidate.extent.spatialReference = sr;
|
121
|
+
}
|
122
|
+
});
|
123
|
+
return response;
|
124
|
+
}
|
125
|
+
);
|
126
|
+
}
|
127
|
+
|
128
|
+
export default {
|
129
|
+
geocode
|
130
|
+
};
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request, IRequestOptions, warn } from "@esri/arcgis-rest-request";
|
5
|
+
|
6
|
+
// https always
|
7
|
+
export const worldGeocoder =
|
8
|
+
"https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/";
|
9
|
+
|
10
|
+
// to do: remove at v2.0.0 (and import from arcgis-rest-common instead)
|
11
|
+
export interface ILocation {
|
12
|
+
latitude?: number;
|
13
|
+
longitude?: number;
|
14
|
+
lat?: number;
|
15
|
+
long?: number;
|
16
|
+
}
|
17
|
+
|
18
|
+
// nice to have: verify custom endpoints contain 'GeocodeServer' and end in a '/'
|
19
|
+
export interface IEndpointRequestOptions extends IRequestOptions {
|
20
|
+
/**
|
21
|
+
* Any ArcGIS Geocoding service (example: http://sampleserver6.arcgisonline.com/arcgis/rest/services/Locators/SanDiego/GeocodeServer )
|
22
|
+
*/
|
23
|
+
endpoint?: string;
|
24
|
+
}
|
25
|
+
|
26
|
+
export interface IGetGeocodeServiceResponse {
|
27
|
+
currentVersion: number;
|
28
|
+
serviceDescription: string;
|
29
|
+
addressFields: any[];
|
30
|
+
countries: string[];
|
31
|
+
capabilities: string;
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Used to fetch metadata from a geocoding service.
|
36
|
+
*
|
37
|
+
* ```js
|
38
|
+
* import { getGeocoderServiceInfo } from '@esri/arcgis-rest-geocoder';
|
39
|
+
*
|
40
|
+
* getGeocoderServiceInfo()
|
41
|
+
* .then((response) => {
|
42
|
+
* response.serviceDescription; // => 'World Geocoder'
|
43
|
+
* });
|
44
|
+
* ```
|
45
|
+
*
|
46
|
+
* @param requestOptions - Request options can contain a custom geocoding service to fetch metadata from.
|
47
|
+
* @returns A Promise that will resolve with the data from the response.
|
48
|
+
*/
|
49
|
+
export function getGeocodeService(
|
50
|
+
requestOptions?: IEndpointRequestOptions
|
51
|
+
): Promise<IGetGeocodeServiceResponse> {
|
52
|
+
const url = (requestOptions && requestOptions.endpoint) || worldGeocoder;
|
53
|
+
|
54
|
+
const options: IEndpointRequestOptions = {
|
55
|
+
httpMethod: "GET",
|
56
|
+
maxUrlLength: 2000,
|
57
|
+
...requestOptions
|
58
|
+
};
|
59
|
+
|
60
|
+
return request(url, options);
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Deprecated. Please use [`getGeocodeService()`](../getGeocodeService/) instead.
|
65
|
+
*
|
66
|
+
* @param requestOptions - Request options can contain a custom geocoding service to fetch metadata from.
|
67
|
+
* @returns A Promise that will resolve with the data from the response.
|
68
|
+
*/
|
69
|
+
export function serviceInfo(
|
70
|
+
requestOptions?: IEndpointRequestOptions
|
71
|
+
): Promise<IGetGeocodeServiceResponse> {
|
72
|
+
warn(
|
73
|
+
"serviceInfo() will be deprecated in the next major release. please use getGeocoderServiceInfo() instead."
|
74
|
+
);
|
75
|
+
return getGeocodeService(requestOptions);
|
76
|
+
}
|
77
|
+
|
78
|
+
export default {
|
79
|
+
getGeocodeService
|
80
|
+
};
|
@@ -0,0 +1,83 @@
|
|
1
|
+
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request } from "@esri/arcgis-rest-request";
|
5
|
+
import { IPoint } from "@esri/arcgis-rest-common-types";
|
6
|
+
|
7
|
+
import { ILocation, worldGeocoder, IEndpointRequestOptions } from "./helpers";
|
8
|
+
|
9
|
+
// to do: remove utility functions and import from arcgis-rest-common at v2
|
10
|
+
function isLocationArray(
|
11
|
+
coords: ILocation | IPoint | [number, number]
|
12
|
+
): coords is [number, number] {
|
13
|
+
return (coords as [number, number]).length === 2;
|
14
|
+
}
|
15
|
+
function isLocation(
|
16
|
+
coords: ILocation | IPoint | [number, number]
|
17
|
+
): coords is ILocation {
|
18
|
+
return (
|
19
|
+
(coords as ILocation).latitude !== undefined ||
|
20
|
+
(coords as ILocation).lat !== undefined
|
21
|
+
);
|
22
|
+
}
|
23
|
+
|
24
|
+
export interface IReverseGeocodeResponse {
|
25
|
+
address: {
|
26
|
+
[key: string]: any;
|
27
|
+
};
|
28
|
+
location: IPoint;
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Used to determine the address of a [location](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-reverse-geocode.htm).
|
33
|
+
*
|
34
|
+
* ```js
|
35
|
+
* import { reverseGeocode } from '@esri/arcgis-rest-geocoder';
|
36
|
+
*
|
37
|
+
* // long, lat
|
38
|
+
* reverseGeocode([-118.409,33.943 ])
|
39
|
+
* .then((response) => {
|
40
|
+
* response.address.PlaceName; // => "LA Airport"
|
41
|
+
* });
|
42
|
+
*
|
43
|
+
* // or
|
44
|
+
* reverseGeocode({ long: -118.409, lat: 33.943 })
|
45
|
+
* reverseGeocode({ latitude: 33.943, latitude: -118.409 })
|
46
|
+
* reverseGeocode({ x: -118.409, y: 33.9425 }) // wgs84 is assumed
|
47
|
+
* reverseGeocode({ x: -13181226, y: 4021085, spatialReference: { wkid: 3857 })
|
48
|
+
* ```
|
49
|
+
*
|
50
|
+
* @param coordinates - the location you'd like to associate an address with.
|
51
|
+
* @param requestOptions - Additional options for the request including authentication.
|
52
|
+
* @returns A Promise that will resolve with the data from the response.
|
53
|
+
*/
|
54
|
+
export function reverseGeocode(
|
55
|
+
coords: IPoint | ILocation | [number, number],
|
56
|
+
requestOptions?: IEndpointRequestOptions
|
57
|
+
): Promise<IReverseGeocodeResponse> {
|
58
|
+
const options: IEndpointRequestOptions = {
|
59
|
+
endpoint: worldGeocoder,
|
60
|
+
params: {},
|
61
|
+
...requestOptions
|
62
|
+
};
|
63
|
+
|
64
|
+
if (isLocationArray(coords)) {
|
65
|
+
options.params.location = coords.join();
|
66
|
+
} else if (isLocation(coords)) {
|
67
|
+
if (coords.lat) {
|
68
|
+
options.params.location = coords.long + "," + coords.lat;
|
69
|
+
}
|
70
|
+
if (coords.latitude) {
|
71
|
+
options.params.location = coords.longitude + "," + coords.latitude;
|
72
|
+
}
|
73
|
+
} else {
|
74
|
+
// if input is a point, we can pass it straight through, with or without a spatial reference
|
75
|
+
options.params.location = coords;
|
76
|
+
}
|
77
|
+
|
78
|
+
return request(options.endpoint + "reverseGeocode", options);
|
79
|
+
}
|
80
|
+
|
81
|
+
export default {
|
82
|
+
reverseGeocode
|
83
|
+
};
|
@@ -0,0 +1,69 @@
|
|
1
|
+
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request } from "@esri/arcgis-rest-request";
|
5
|
+
|
6
|
+
import { worldGeocoder, IEndpointRequestOptions } from "./helpers";
|
7
|
+
|
8
|
+
export interface ISuggestRequestOptions extends IEndpointRequestOptions {
|
9
|
+
/**
|
10
|
+
* You can create an autocomplete experience by making a call to suggest with partial text and then passing through the magicKey and complete address that are returned to geocode.
|
11
|
+
* ```js
|
12
|
+
* import { suggest, geocode } from '@esri/arcgis-rest-geocoder';
|
13
|
+
* suggest("LAX")
|
14
|
+
* .then((response) => {
|
15
|
+
* geocode({
|
16
|
+
* singleLine: response.suggestions[1].text,
|
17
|
+
* magicKey: response.suggestions[1].magicKey
|
18
|
+
* })
|
19
|
+
* })
|
20
|
+
* ```
|
21
|
+
*/
|
22
|
+
magicKey?: string;
|
23
|
+
}
|
24
|
+
|
25
|
+
export interface ISuggestResponse {
|
26
|
+
suggestions: Array<{
|
27
|
+
text: string;
|
28
|
+
magicKey: string;
|
29
|
+
isCollection: boolean;
|
30
|
+
}>;
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Used to return a placename [suggestion](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) for a partial string.
|
35
|
+
*
|
36
|
+
* ```js
|
37
|
+
* import { suggest } from '@esri/arcgis-rest-geocoder';
|
38
|
+
*
|
39
|
+
* suggest("Starb")
|
40
|
+
* .then((response) => {
|
41
|
+
* response.text; // => "Starbucks"
|
42
|
+
* });
|
43
|
+
* ```
|
44
|
+
*
|
45
|
+
* @param requestOptions - Options for the request including authentication and other optional parameters.
|
46
|
+
* @returns A Promise that will resolve with the data from the response.
|
47
|
+
*/
|
48
|
+
export function suggest(
|
49
|
+
partialText: string,
|
50
|
+
requestOptions?: ISuggestRequestOptions
|
51
|
+
): Promise<ISuggestResponse> {
|
52
|
+
const options: ISuggestRequestOptions = {
|
53
|
+
endpoint: worldGeocoder,
|
54
|
+
params: {},
|
55
|
+
...requestOptions
|
56
|
+
};
|
57
|
+
|
58
|
+
options.params.text = partialText;
|
59
|
+
|
60
|
+
if (requestOptions && requestOptions.magicKey) {
|
61
|
+
options.params.magicKey = requestOptions.magicKey;
|
62
|
+
}
|
63
|
+
|
64
|
+
return request(options.endpoint + "suggest", options);
|
65
|
+
}
|
66
|
+
|
67
|
+
export default {
|
68
|
+
suggest
|
69
|
+
};
|
@@ -0,0 +1,113 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { bulkGeocode } from "../src/bulk";
|
5
|
+
|
6
|
+
import * as fetchMock from "fetch-mock";
|
7
|
+
|
8
|
+
import { GeocodeAddresses } from "./mocks/responses";
|
9
|
+
|
10
|
+
const addresses = [
|
11
|
+
{
|
12
|
+
OBJECTID: 1,
|
13
|
+
SingleLine: "380 New York St. Redlands 92373"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
OBJECTID: 2,
|
17
|
+
SingleLine: "1 World Way Los Angeles 90045"
|
18
|
+
}
|
19
|
+
];
|
20
|
+
|
21
|
+
describe("geocode", () => {
|
22
|
+
afterEach(fetchMock.restore);
|
23
|
+
|
24
|
+
it("should make a bulk geocoding request", done => {
|
25
|
+
fetchMock.once("*", GeocodeAddresses);
|
26
|
+
|
27
|
+
const MOCK_AUTH = {
|
28
|
+
getToken() {
|
29
|
+
return Promise.resolve("token");
|
30
|
+
},
|
31
|
+
portal: "https://mapsdev.arcgis.com"
|
32
|
+
};
|
33
|
+
|
34
|
+
bulkGeocode({ addresses, authentication: MOCK_AUTH })
|
35
|
+
.then(response => {
|
36
|
+
expect(fetchMock.called()).toEqual(true);
|
37
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
|
38
|
+
expect(url).toEqual(
|
39
|
+
"https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/geocodeAddresses"
|
40
|
+
);
|
41
|
+
expect(options.method).toBe("POST");
|
42
|
+
expect(options.body).toContain("f=json");
|
43
|
+
expect(options.body).toContain(
|
44
|
+
`addresses=${encodeURIComponent(
|
45
|
+
'{"records":[{"attributes":{"OBJECTID":1,"SingleLine":"380 New York St. Redlands 92373"}},{"attributes":{"OBJECTID":2,"SingleLine":"1 World Way Los Angeles 90045"}}]}'
|
46
|
+
)}`
|
47
|
+
);
|
48
|
+
expect(options.body).toContain("token=token");
|
49
|
+
expect(response.spatialReference.latestWkid).toEqual(4326);
|
50
|
+
expect(response.locations[0].address).toEqual(
|
51
|
+
"380 New York St, Redlands, California, 92373"
|
52
|
+
);
|
53
|
+
expect(response.locations[0].location.x).toEqual(-117.19567031799994);
|
54
|
+
// the only property this lib tacks on
|
55
|
+
expect(response.locations[0].location.spatialReference.wkid).toEqual(
|
56
|
+
4326
|
57
|
+
);
|
58
|
+
done();
|
59
|
+
})
|
60
|
+
.catch(e => {
|
61
|
+
fail(e);
|
62
|
+
});
|
63
|
+
});
|
64
|
+
|
65
|
+
it("should throw an error when a bulk geocoding request is made without a token", done => {
|
66
|
+
fetchMock.once("*", GeocodeAddresses);
|
67
|
+
|
68
|
+
bulkGeocode({ addresses })
|
69
|
+
// tslint:disable-next-line
|
70
|
+
.catch(e => {
|
71
|
+
expect(e).toEqual(
|
72
|
+
"bulk geocoding using the ArcGIS service requires authentication"
|
73
|
+
);
|
74
|
+
done();
|
75
|
+
});
|
76
|
+
});
|
77
|
+
|
78
|
+
it("should send a bulk geocoding request to a custom url without a token", done => {
|
79
|
+
fetchMock.once("*", GeocodeAddresses);
|
80
|
+
|
81
|
+
bulkGeocode({
|
82
|
+
addresses,
|
83
|
+
endpoint:
|
84
|
+
"https://customer.gov/arcgis/rest/services/CompositeGeocoder/GeocodeServer/"
|
85
|
+
})
|
86
|
+
// tslint:disable-next-line
|
87
|
+
.then(response => {
|
88
|
+
expect(fetchMock.called()).toEqual(true);
|
89
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
|
90
|
+
expect(url).toEqual(
|
91
|
+
"https://customer.gov/arcgis/rest/services/CompositeGeocoder/GeocodeServer/geocodeAddresses"
|
92
|
+
);
|
93
|
+
expect(options.method).toBe("POST");
|
94
|
+
expect(options.body).toContain("f=json");
|
95
|
+
expect(options.body).toContain(
|
96
|
+
`addresses=${encodeURIComponent(
|
97
|
+
'{"records":[{"attributes":{"OBJECTID":1,"SingleLine":"380 New York St. Redlands 92373"}},{"attributes":{"OBJECTID":2,"SingleLine":"1 World Way Los Angeles 90045"}}]}'
|
98
|
+
)}`
|
99
|
+
);
|
100
|
+
// expect(options.body).toContain("token=token");
|
101
|
+
expect(response.spatialReference.latestWkid).toEqual(4326);
|
102
|
+
expect(response.locations[0].address).toEqual(
|
103
|
+
"380 New York St, Redlands, California, 92373"
|
104
|
+
);
|
105
|
+
expect(response.locations[0].location.x).toEqual(-117.19567031799994);
|
106
|
+
// the only property this lib tacks on
|
107
|
+
expect(response.locations[0].location.spatialReference.wkid).toEqual(
|
108
|
+
4326
|
109
|
+
);
|
110
|
+
done();
|
111
|
+
});
|
112
|
+
});
|
113
|
+
});
|