@esri/arcgis-rest-demographics 3.4.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 +10 -11
- package/dist/bundled/demographics.esm.js +242 -0
- package/dist/bundled/demographics.esm.js.map +1 -0
- package/dist/bundled/demographics.esm.min.js +7 -0
- package/dist/bundled/demographics.esm.min.js.map +1 -0
- package/dist/bundled/demographics.umd.js +254 -0
- package/dist/bundled/demographics.umd.js.map +1 -0
- package/dist/bundled/demographics.umd.min.js +7 -0
- package/dist/bundled/demographics.umd.min.js.map +1 -0
- package/dist/{node → cjs}/getAvailableCountries.js +12 -11
- package/dist/cjs/getAvailableCountries.js.map +1 -0
- package/dist/{node → cjs}/getAvailableDataCollections.js +14 -16
- package/dist/cjs/getAvailableDataCollections.js.map +1 -0
- package/dist/{node → cjs}/getAvailableGeographyLevels.js +12 -9
- package/dist/cjs/getAvailableGeographyLevels.js.map +1 -0
- package/dist/{node → cjs}/getGeography.js +11 -10
- package/dist/cjs/getGeography.js.map +1 -0
- package/dist/cjs/helpers.js +9 -0
- package/dist/cjs/helpers.js.map +1 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/{node → cjs}/queryDemographicData.js +10 -9
- package/dist/cjs/queryDemographicData.js.map +1 -0
- package/dist/esm/getAvailableCountries.d.ts +7 -5
- package/dist/esm/getAvailableCountries.js +11 -10
- package/dist/esm/getAvailableCountries.js.map +1 -1
- package/dist/esm/getAvailableDataCollections.d.ts +9 -7
- package/dist/esm/getAvailableDataCollections.js +13 -15
- package/dist/esm/getAvailableDataCollections.js.map +1 -1
- package/dist/esm/getAvailableGeographyLevels.d.ts +4 -2
- package/dist/esm/getAvailableGeographyLevels.js +11 -8
- package/dist/esm/getAvailableGeographyLevels.js.map +1 -1
- package/dist/esm/getGeography.d.ts +4 -2
- package/dist/esm/getGeography.js +10 -9
- package/dist/esm/getGeography.js.map +1 -1
- package/dist/esm/helpers.d.ts +1 -2
- package/dist/esm/helpers.js +3 -3
- package/dist/esm/helpers.js.map +1 -1
- package/dist/esm/index.d.ts +6 -5
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +3 -0
- package/dist/esm/queryDemographicData.d.ts +4 -2
- package/dist/esm/queryDemographicData.js +9 -8
- package/dist/esm/queryDemographicData.js.map +1 -1
- package/package.json +54 -47
- package/dist/node/getAvailableCountries.js.map +0 -1
- package/dist/node/getAvailableDataCollections.js.map +0 -1
- package/dist/node/getAvailableGeographyLevels.js.map +0 -1
- package/dist/node/getGeography.js.map +0 -1
- package/dist/node/helpers.js +0 -9
- package/dist/node/helpers.js.map +0 -1
- package/dist/node/index.js +0 -11
- package/dist/node/index.js.map +0 -1
- package/dist/node/queryDemographicData.js.map +0 -1
- package/dist/umd/demographics.umd.js +0 -271
- package/dist/umd/demographics.umd.js.map +0 -1
- package/dist/umd/demographics.umd.min.js +0 -7
- package/dist/umd/demographics.umd.min.js.map +0 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/* @preserve
|
|
2
|
+
* @esri/arcgis-rest-demographics - v4.0.0-beta.5 - Apache-2.0
|
|
3
|
+
* Copyright (c) 2017-2022 Esri, Inc.
|
|
4
|
+
* Mon Apr 18 2022 16:42:05 GMT+0000 (Coordinated Universal Time)
|
|
5
|
+
*/
|
|
6
|
+
(function (global, factory) {
|
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/arcgis-rest-request')) :
|
|
8
|
+
typeof define === 'function' && define.amd ? define(['exports', '@esri/arcgis-rest-request'], factory) :
|
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisRest = global.arcgisRest || {}, global.arcgisRest));
|
|
10
|
+
})(this, (function (exports, arcgisRestRequest) { 'use strict';
|
|
11
|
+
|
|
12
|
+
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
13
|
+
* Apache-2.0 */
|
|
14
|
+
const ARCGIS_ONLINE_GEOENRICHMENTSERVER_URL = "https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver";
|
|
15
|
+
const ARCGIS_ONLINE_GEOENRICHMENT_URL = `${ARCGIS_ONLINE_GEOENRICHMENTSERVER_URL}/Geoenrichment`;
|
|
16
|
+
const ARCGIS_ONLINE_STANDARD_GEOGRAPHY_QUERY_URL = `${ARCGIS_ONLINE_GEOENRICHMENTSERVER_URL}/StandardGeographyQuery`;
|
|
17
|
+
|
|
18
|
+
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
19
|
+
* Apache-2.0 */
|
|
20
|
+
/**
|
|
21
|
+
* Return a list of information for all countries. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/countries.htm) for more information.
|
|
22
|
+
*
|
|
23
|
+
* ```js
|
|
24
|
+
* import { getAvailableCountries } from '@esri/arcgis-rest-demographics';
|
|
25
|
+
*
|
|
26
|
+
* getAvailableCountries()
|
|
27
|
+
* .then((response) => {
|
|
28
|
+
* response; // => { countries: [ ... ] }
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
33
|
+
* @returns A Promise that will resolve with available geography levels for the request.
|
|
34
|
+
*/
|
|
35
|
+
function getAvailableCountries(requestOptions) {
|
|
36
|
+
let options = {};
|
|
37
|
+
let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/countries`;
|
|
38
|
+
if (!requestOptions) {
|
|
39
|
+
options.params = {};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
if (requestOptions.endpoint) {
|
|
43
|
+
endpoint = `${requestOptions.endpoint}/countries`;
|
|
44
|
+
}
|
|
45
|
+
options = arcgisRestRequest.appendCustomParams(requestOptions, [], { params: Object.assign({}, requestOptions.params) });
|
|
46
|
+
if (requestOptions.countryCode) {
|
|
47
|
+
endpoint = `${endpoint}/${requestOptions.countryCode}`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return arcgisRestRequest.request(arcgisRestRequest.cleanUrl(endpoint), options).then((response) => {
|
|
51
|
+
return response;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
56
|
+
* Apache-2.0 */
|
|
57
|
+
/**
|
|
58
|
+
* Used to determine the data collections available for usage with the Geoenrichment service. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/data-collections.htm) for more information.
|
|
59
|
+
*
|
|
60
|
+
* ```js
|
|
61
|
+
* import { getAvailableDataCollections } from '@esri/arcgis-rest-demographics';
|
|
62
|
+
*
|
|
63
|
+
* getAvailableDataCollections()
|
|
64
|
+
* .then((response) => {
|
|
65
|
+
* response; // => { DataCollections: [ ... ] }
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* getAvailableDataCollections({
|
|
69
|
+
* countryCode: "se",
|
|
70
|
+
* dataCollection: "EducationalAttainment"
|
|
71
|
+
* })
|
|
72
|
+
* .then((response) => {
|
|
73
|
+
* response.; // => { DataCollections: [ ... ] }
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
78
|
+
* @returns A Promise that will resolve with data collections for the request.
|
|
79
|
+
*/
|
|
80
|
+
function getAvailableDataCollections(requestOptions) {
|
|
81
|
+
let options = {};
|
|
82
|
+
let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/dataCollections`;
|
|
83
|
+
if (!requestOptions) {
|
|
84
|
+
options.params = {};
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
if (requestOptions.endpoint) {
|
|
88
|
+
endpoint = `${requestOptions.endpoint}/dataCollections`;
|
|
89
|
+
}
|
|
90
|
+
options = arcgisRestRequest.appendCustomParams(requestOptions, ["addDerivativeVariables", "suppressNullValues"], { params: Object.assign({}, requestOptions.params) });
|
|
91
|
+
if (options.params.addDerivativeVariables) {
|
|
92
|
+
options.params.addDerivativeVariables = JSON.stringify(options.params.addDerivativeVariables);
|
|
93
|
+
}
|
|
94
|
+
if (requestOptions.countryCode) {
|
|
95
|
+
endpoint = `${endpoint}/${requestOptions.countryCode}`;
|
|
96
|
+
if (requestOptions.dataCollection) {
|
|
97
|
+
endpoint = `${endpoint}/${requestOptions.dataCollection}`;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// add spatialReference property to individual matches
|
|
102
|
+
return arcgisRestRequest.request(`${arcgisRestRequest.cleanUrl(endpoint)}`, options).then((response) => {
|
|
103
|
+
return response;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
108
|
+
* Apache-2.0 */
|
|
109
|
+
/**
|
|
110
|
+
* Returns a list of available geography data layers, which can then be used in [getGeography()](). See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/standard-geography-levels.htm) for more information.
|
|
111
|
+
*
|
|
112
|
+
* ```js
|
|
113
|
+
* import { getAvailableGeographyLevels } from '@esri/arcgis-rest-demographics';
|
|
114
|
+
* //
|
|
115
|
+
* getAvailableGeographyLevels()
|
|
116
|
+
* .then((response) => {
|
|
117
|
+
* response; // => { geographyLevels: [ ... ] }
|
|
118
|
+
* });
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
122
|
+
* @returns A Promise that will resolve with available geography levels for the request.
|
|
123
|
+
*/
|
|
124
|
+
function getAvailableGeographyLevels(requestOptions) {
|
|
125
|
+
let options = {};
|
|
126
|
+
let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/StandardGeographyLevels`;
|
|
127
|
+
if (!requestOptions) {
|
|
128
|
+
options.params = {};
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
if (requestOptions.endpoint) {
|
|
132
|
+
endpoint = `${requestOptions.endpoint}/StandardGeographyLevels`;
|
|
133
|
+
}
|
|
134
|
+
options = arcgisRestRequest.appendCustomParams(requestOptions, [], {
|
|
135
|
+
params: Object.assign({}, requestOptions.params)
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return arcgisRestRequest.request(`${arcgisRestRequest.cleanUrl(endpoint)}`, options).then((response) => {
|
|
139
|
+
return response;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
144
|
+
* Apache-2.0 */
|
|
145
|
+
/**
|
|
146
|
+
* Used to get standard geography IDs and features for the supported geographic levels. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/standard-geography-query.htm) and the [best practices post](https://www.esri.com/arcgis-blog/products/arcgis-online/uncategorized/best-practices-how-to-query-standard-geographies-branches) for more information.
|
|
147
|
+
*
|
|
148
|
+
* ```js
|
|
149
|
+
* import { getGeography } from '@esri/arcgis-rest-demographics';
|
|
150
|
+
* //
|
|
151
|
+
* getGeography({
|
|
152
|
+
* sourceCountry: "CA",
|
|
153
|
+
* geographyIDs: ["35"]
|
|
154
|
+
* })
|
|
155
|
+
* .then((response) => {
|
|
156
|
+
* response.; // => { results: [ ... ] }
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @param requestOptions Options to pass through to the service. All properties are optional, but either `geographyIds` or `geographyQuery` must be sent at a minimum.
|
|
161
|
+
* @returns A Promise that will resolve with return data defined and optionally geometry for the feature.
|
|
162
|
+
*/
|
|
163
|
+
function getGeography(requestOptions) {
|
|
164
|
+
const endpoint = `${requestOptions.endpoint || ARCGIS_ONLINE_STANDARD_GEOGRAPHY_QUERY_URL}/execute`;
|
|
165
|
+
const options = arcgisRestRequest.appendCustomParams(requestOptions, [
|
|
166
|
+
"sourceCountry",
|
|
167
|
+
"optionalCountryDataset",
|
|
168
|
+
"geographyLayers",
|
|
169
|
+
"geographyIDs",
|
|
170
|
+
"geographyQuery",
|
|
171
|
+
"returnSubGeographyLayer",
|
|
172
|
+
"subGeographyLayer",
|
|
173
|
+
"subGeographyQuery",
|
|
174
|
+
"outSR",
|
|
175
|
+
"returnGeometry",
|
|
176
|
+
"returnCentroids",
|
|
177
|
+
"generalizationLevel",
|
|
178
|
+
"useFuzzySearch",
|
|
179
|
+
"featureLimit",
|
|
180
|
+
"featureOffset",
|
|
181
|
+
"langCode"
|
|
182
|
+
], { params: Object.assign({}, requestOptions.params) });
|
|
183
|
+
// the SAAS service does not support anonymous requests
|
|
184
|
+
if (!requestOptions.authentication) {
|
|
185
|
+
return Promise.reject("Geoenrichment using the ArcGIS service requires authentication");
|
|
186
|
+
}
|
|
187
|
+
// These parameters are passed as JSON-style strings:
|
|
188
|
+
["geographyLayers", "geographyIDs"].forEach((parameter) => {
|
|
189
|
+
if (options.params[parameter]) {
|
|
190
|
+
options.params[parameter] = JSON.stringify(options.params[parameter]);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
// add spatialReference property to individual matches
|
|
194
|
+
return arcgisRestRequest.request(`${arcgisRestRequest.cleanUrl(endpoint)}`, options).then((response) => {
|
|
195
|
+
return response;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
200
|
+
* Apache-2.0 */
|
|
201
|
+
/**
|
|
202
|
+
* Used to get facts about a location or area. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/enrich.htm) for more information.
|
|
203
|
+
*
|
|
204
|
+
* ```js
|
|
205
|
+
* import { queryDemographicData } from '@esri/arcgis-rest-demographics';
|
|
206
|
+
* //
|
|
207
|
+
* queryDemographicData({
|
|
208
|
+
* studyAreas: [{"geometry":{"x":-117.1956,"y":34.0572}}],
|
|
209
|
+
* authentication
|
|
210
|
+
* })
|
|
211
|
+
* .then((response) => {
|
|
212
|
+
* response; // => { results: [ ... ] }
|
|
213
|
+
* });
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* @param requestOptions Options to pass through to the service.
|
|
217
|
+
* @returns A Promise that will resolve with results for the request.
|
|
218
|
+
*/
|
|
219
|
+
function queryDemographicData(requestOptions) {
|
|
220
|
+
const options = arcgisRestRequest.appendCustomParams(requestOptions, [
|
|
221
|
+
"studyAreas",
|
|
222
|
+
"dataCollections",
|
|
223
|
+
"analysisVariables",
|
|
224
|
+
"addDerivativeVariables",
|
|
225
|
+
"returnGeometry",
|
|
226
|
+
"inSR",
|
|
227
|
+
"outSR"
|
|
228
|
+
], { params: Object.assign({}, requestOptions.params) });
|
|
229
|
+
// the SAAS service does not support anonymous requests
|
|
230
|
+
if (!requestOptions.authentication) {
|
|
231
|
+
return Promise.reject("Geoenrichment using the ArcGIS service requires authentication");
|
|
232
|
+
}
|
|
233
|
+
// These parameters are passed as JSON-style strings:
|
|
234
|
+
["dataCollections", "analysisVariables"].forEach((parameter) => {
|
|
235
|
+
if (options.params[parameter]) {
|
|
236
|
+
options.params[parameter] = JSON.stringify(options.params[parameter]);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
// add spatialReference property to individual matches
|
|
240
|
+
return arcgisRestRequest.request(`${arcgisRestRequest.cleanUrl(`${requestOptions.endpoint || ARCGIS_ONLINE_GEOENRICHMENT_URL}/enrich`)}`, options).then((response) => {
|
|
241
|
+
return response;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
exports.getAvailableCountries = getAvailableCountries;
|
|
246
|
+
exports.getAvailableDataCollections = getAvailableDataCollections;
|
|
247
|
+
exports.getAvailableGeographyLevels = getAvailableGeographyLevels;
|
|
248
|
+
exports.getGeography = getGeography;
|
|
249
|
+
exports.queryDemographicData = queryDemographicData;
|
|
250
|
+
|
|
251
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
252
|
+
|
|
253
|
+
}));
|
|
254
|
+
//# sourceMappingURL=demographics.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demographics.umd.js","sources":["../../src/helpers.ts","../../src/getAvailableCountries.ts","../../src/getAvailableDataCollections.ts","../../src/getAvailableGeographyLevels.ts","../../src/getGeography.ts","../../src/queryDemographicData.ts"],"sourcesContent":["/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n IRequestOptions,\n IFeatureSet\n} from \"@esri/arcgis-rest-request\";\n\nconst ARCGIS_ONLINE_GEOENRICHMENTSERVER_URL = \"https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver\"\nexport const ARCGIS_ONLINE_GEOENRICHMENT_URL = `${ARCGIS_ONLINE_GEOENRICHMENTSERVER_URL}/Geoenrichment`;\nexport const ARCGIS_ONLINE_STANDARD_GEOGRAPHY_QUERY_URL = `${ARCGIS_ONLINE_GEOENRICHMENTSERVER_URL}/StandardGeographyQuery`;\n\nexport interface IEndpointOptions extends IRequestOptions {\n /**\n * Any ArcGIS Geoenrichment service (example: https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver/Geoenrichment )\n */\n endpoint?: string;\n}\n\nexport interface IGeoenrichmentResult {\n paramName: string;\n dataType: string;\n value: {\n version: string;\n FeatureSet: IFeatureSet[];\n };\n}","/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams,\n IExtent\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetAvailableCountriesOptions extends IEndpointOptions {\n /**\n * View a description for a given country. If not specified, will return a list of all countries.\n */\n countryCode?: string;\n}\n\nexport interface IGetAvailableCountriesResponse {\n messages?: string[];\n countries?: ICountry[];\n childResources?: any[];\n}\nexport interface ICountry {\n id: string;\n name: string;\n abbr3: string;\n altName: string;\n continent: string;\n distanceUnits: string;\n esriUnits: string;\n defaultExtent: IExtent;\n defaultDatasetID: string;\n datasets?: string[];\n hierarchies?: IHierarchy[];\n defaultDataCollection: string;\n dataCollections: string;\n defaultReportTemplate: string;\n currencySymbol: string;\n currencyFormat: string;\n}\nexport interface IHierarchy {\n ID: string;\n alias: string;\n shortDescription: string;\n default: boolean;\n longDescription: string;\n locales?: string[];\n datasets?: string[];\n levelsInfo: ILevelsInfo;\n variablesInfo: IVariablesInfo;\n populationToPolygonSizeRating: number;\n apportionmentConfidence: number;\n apportionmentThresholds?: IApportionmentThreshold[];\n hasMarginOfErrorData?: boolean;\n}\nexport interface ILevelsInfo {\n geographyLevels?: string[];\n}\nexport interface IVariablesInfo {\n categories?: string[];\n}\nexport interface IApportionmentThreshold {\n method: string;\n dataLayer: string;\n pointsLayer?: string;\n maximumSize?: number;\n}\n\n/**\n * Return a list of information for all countries. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/countries.htm) for more information.\n *\n * ```js\n * import { getAvailableCountries } from '@esri/arcgis-rest-demographics';\n *\n * getAvailableCountries()\n * .then((response) => {\n * response; // => { countries: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the geoenrichment service.\n * @returns A Promise that will resolve with available geography levels for the request.\n */\nexport function getAvailableCountries(\n requestOptions?: IGetAvailableCountriesOptions\n): Promise<IGetAvailableCountriesResponse> {\n let options: IEndpointOptions = {};\n let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/countries`;\n if (!requestOptions) {\n options.params = {};\n } else {\n if (requestOptions.endpoint) {\n endpoint = `${requestOptions.endpoint}/countries`;\n }\n\n options = appendCustomParams<IGetAvailableCountriesOptions>(\n requestOptions,\n [],\n { params: { ...requestOptions.params } }\n );\n if (requestOptions.countryCode) {\n endpoint = `${endpoint}/${requestOptions.countryCode}`;\n }\n }\n\n return request(cleanUrl(endpoint), options).then((response: any) => {\n return response;\n });\n}\n","/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetAvailableDataCollectionsOptions extends IEndpointOptions {\n /**\n * Optional parameter to specify an array of string values that describe what derivative variables to include in the output.\n */\n addDerivativeVariables?: string[];\n /**\n * Optional parameter to return only values that are not NULL in the output response.\n */\n suppressNullValues?: boolean;\n /**\n * View a description for a single data collection within a given country. If not specified, will return a list of data collections that can be run in any country.\n */\n countryCode?: string;\n dataCollection?: string;\n}\n\nexport interface IGetAvailableDataCollectionsResponse {\n DataCollections?: IDataCollection[] | null;\n}\nexport interface IDataCollection {\n dataCollectionID: string;\n metadata: IMetadata;\n data?: IDataInfo[] | null;\n}\nexport interface IMetadata {\n title: string;\n name: string;\n shortDescription: string;\n longDescription: string;\n url: string;\n keywords: string;\n creationDate: number;\n lastRevisionDate: number;\n webmap: string;\n author: string;\n countries?: string | null;\n IsRoyalties: boolean;\n categories?: ICategory[] | null;\n filters?: IFilter[] | null;\n datasets?: string | null;\n hierarchies: string;\n coverage?: string | null;\n mobileinfographics?: string | null;\n icon?: string | null;\n}\nexport interface ICategory {\n id: string;\n name: string;\n alias: string;\n description: string;\n displayOrder: string;\n}\nexport interface IFilter {\n id: string;\n name: string;\n aliasname: string;\n type: string;\n rangeMax?: string | null;\n rangeMin?: string | null;\n enumValues?: string | null;\n}\nexport interface IDataInfo {\n id: string;\n alias: string;\n type: string;\n precision: number;\n length?: null;\n averageBase?: null;\n averageBaseAlias?: null;\n description: string;\n fieldCategory: string;\n indexBase?: number | null;\n percentBase?: string | null;\n percentBaseAlias?: string | null;\n popularity?: number | null;\n units: string;\n vintage?: string | null;\n hideInDataBrowser: boolean;\n filteringTags?: IFilteringTag[] | null;\n derivative: boolean;\n provider: string;\n indexType?: string | null;\n}\nexport interface IFilteringTag {\n id: string;\n name: string;\n value: string;\n}\n\n/**\n * Used to determine the data collections available for usage with the Geoenrichment service. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/data-collections.htm) for more information.\n *\n * ```js\n * import { getAvailableDataCollections } from '@esri/arcgis-rest-demographics';\n *\n * getAvailableDataCollections()\n * .then((response) => {\n * response; // => { DataCollections: [ ... ] }\n * });\n *\n * getAvailableDataCollections({\n * countryCode: \"se\",\n * dataCollection: \"EducationalAttainment\"\n * })\n * .then((response) => {\n * response.; // => { DataCollections: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the geoenrichment service.\n * @returns A Promise that will resolve with data collections for the request.\n */\nexport function getAvailableDataCollections(\n requestOptions?: IGetAvailableDataCollectionsOptions\n): Promise<IGetAvailableDataCollectionsResponse> {\n let options: IGetAvailableDataCollectionsOptions = {};\n let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/dataCollections`;\n\n if (!requestOptions) {\n options.params = {};\n } else {\n if (requestOptions.endpoint) {\n endpoint = `${requestOptions.endpoint}/dataCollections`;\n }\n options = appendCustomParams<IGetAvailableDataCollectionsOptions>(\n requestOptions,\n [\"addDerivativeVariables\", \"suppressNullValues\"],\n { params: { ...requestOptions.params } }\n );\n\n if (options.params.addDerivativeVariables) {\n options.params.addDerivativeVariables = JSON.stringify(\n options.params.addDerivativeVariables\n );\n }\n\n if (requestOptions.countryCode) {\n endpoint = `${endpoint}/${requestOptions.countryCode}`;\n if (requestOptions.dataCollection) {\n endpoint = `${endpoint}/${requestOptions.dataCollection}`;\n }\n }\n }\n\n // add spatialReference property to individual matches\n return request(`${cleanUrl(endpoint)}`, options).then((response: any) => {\n return response;\n });\n}\n","/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetAvailableGeographyLevelsResponse {\n messages?: string[] | null;\n childResources?: any[] | null;\n childDatasets?: any[] | null;\n childHierarchies?: any[] | null;\n geographyLevels?: IGeographyLevel[] | null;\n}\nexport interface IGeographyLevel {\n countryID: string;\n countryName: string;\n datasets?: IDataset[] | null;\n hierarchies?: IGeographyLevelHierarchy[] | null;\n}\nexport interface IDataset {\n datasetID: string;\n branches?: IBranch[] | null;\n levels?: ILevel[] | null;\n}\nexport interface IBranch {\n id: string;\n name: string;\n levels?: string[] | null;\n}\nexport interface ILevel {\n id: string;\n name: string;\n isWholeCountry: boolean;\n adminLevel: string;\n singularName: string;\n pluralName: string;\n description?: string | null;\n}\nexport interface IGeographyLevelHierarchy {\n ID: string;\n branches?: IBranch[] | null;\n levels?: ILevel[] | null;\n}\n\n/**\n * Returns a list of available geography data layers, which can then be used in [getGeography()](). See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/standard-geography-levels.htm) for more information.\n *\n * ```js\n * import { getAvailableGeographyLevels } from '@esri/arcgis-rest-demographics';\n * //\n * getAvailableGeographyLevels()\n * .then((response) => {\n * response; // => { geographyLevels: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the geoenrichment service.\n * @returns A Promise that will resolve with available geography levels for the request.\n */\nexport function getAvailableGeographyLevels(\n requestOptions?: IEndpointOptions\n): Promise<IGetAvailableGeographyLevelsResponse> {\n let options: IEndpointOptions = {};\n let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/StandardGeographyLevels`;\n\n if (!requestOptions) {\n options.params = {};\n } else {\n if (requestOptions.endpoint) {\n endpoint = `${requestOptions.endpoint}/StandardGeographyLevels`;\n }\n options = appendCustomParams<IEndpointOptions>(requestOptions, [], {\n params: { ...requestOptions.params }\n });\n }\n\n return request(`${cleanUrl(endpoint)}`, options).then((response: any) => {\n return response;\n });\n}\n","/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_STANDARD_GEOGRAPHY_QUERY_URL,\n IGeoenrichmentResult,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetGeographyOptions extends IEndpointOptions {\n /**\n * Specify the source country for the search.\n */\n sourceCountry?: string;\n /**\n * Specify a specific dataset within a defined country.\n */\n optionalCountryDataset?: string;\n /**\n * Specify which standard geography layers are being queried or searched.\n */\n geographyLayers?: string[] | string;\n /**\n * Specify which IDs for the standard geography layers are being queried or searched.\n */\n geographyIDs?: string[];\n /**\n * Specify the text to query and search the standard geography layers specified.\n */\n geographyQuery?: string;\n /**\n * Return all the subgeographic areas that are within a parent geography.\n */\n returnSubGeographyLayer?: boolean;\n /**\n * Return all the subgeographic areas that are within a parent geography.\n */\n subGeographyLayer?: string;\n /**\n * Filter the results of the subgeography features that are returned by a search term.\n */\n subGeographyQuery?: string;\n /**\n * Request the output geometries in a specified spatial reference system.\n */\n outSR?: number;\n /**\n * Request the output geometries in the response.\n */\n returnGeometry?: boolean;\n /**\n * Request the output geometry to return the center point for each feature.\n */\n returnCentroids?: boolean;\n /**\n * Integer that specifies the level of generalization or detail in the area representations of the administrative boundary or standard geographic data layers.\n */\n generalizationLevel?: number;\n /**\n * Define if text provided in the geographyQuery parameter should utilize fuzzy search logic.\n */\n useFuzzySearch?: boolean;\n /**\n * Limits the number of features that are returned from the geographyQuery parameter.\n */\n featureLimit?: number;\n /**\n * Starts the results on the number of the records specified.\n */\n featureOffset?: number;\n /**\n * Specifies the language you wish to receive your GeoEnrichment results.\n */\n langCode?: string;\n}\n\nexport interface IGetGeographyResponse {\n results: IGeoenrichmentResult[] | null;\n messages: string[] | null;\n}\n\n/**\n * Used to get standard geography IDs and features for the supported geographic levels. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/standard-geography-query.htm) and the [best practices post](https://www.esri.com/arcgis-blog/products/arcgis-online/uncategorized/best-practices-how-to-query-standard-geographies-branches) for more information.\n *\n * ```js\n * import { getGeography } from '@esri/arcgis-rest-demographics';\n * //\n * getGeography({\n * sourceCountry: \"CA\",\n * geographyIDs: [\"35\"]\n * })\n * .then((response) => {\n * response.; // => { results: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the service. All properties are optional, but either `geographyIds` or `geographyQuery` must be sent at a minimum.\n * @returns A Promise that will resolve with return data defined and optionally geometry for the feature.\n */\nexport function getGeography(\n requestOptions?: IGetGeographyOptions\n): Promise<IGetGeographyResponse> {\n const endpoint = `${\n requestOptions.endpoint || ARCGIS_ONLINE_STANDARD_GEOGRAPHY_QUERY_URL\n }/execute`;\n\n const options = appendCustomParams<IGetGeographyOptions>(\n requestOptions,\n [\n \"sourceCountry\",\n \"optionalCountryDataset\",\n \"geographyLayers\",\n \"geographyIDs\",\n \"geographyQuery\",\n \"returnSubGeographyLayer\",\n \"subGeographyLayer\",\n \"subGeographyQuery\",\n \"outSR\",\n \"returnGeometry\",\n \"returnCentroids\",\n \"generalizationLevel\",\n \"useFuzzySearch\",\n \"featureLimit\",\n \"featureOffset\",\n \"langCode\"\n ],\n { params: { ...requestOptions.params } }\n );\n\n // the SAAS service does not support anonymous requests\n if (!requestOptions.authentication) {\n return Promise.reject(\n \"Geoenrichment using the ArcGIS service requires authentication\"\n );\n }\n\n // These parameters are passed as JSON-style strings:\n [\"geographyLayers\", \"geographyIDs\"].forEach((parameter) => {\n if (options.params[parameter]) {\n options.params[parameter] = JSON.stringify(options.params[parameter]);\n }\n });\n\n // add spatialReference property to individual matches\n return request(`${cleanUrl(endpoint)}`, options).then((response: any) => {\n return response;\n });\n}\n","/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IGeoenrichmentResult,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IQueryDemographicDataOptions extends IEndpointOptions {\n /**\n * Defines the area on a map which is being analyzed\n */\n studyAreas: any[];\n /**\n * A Data Collection is a preassembled list of attributes that will be used to enrich the input features. Enrichment attributes can describe various types of information such as demographic characteristics and geographic context of the locations or areas submitted as input features in studyAreas.\n */\n dataCollections?: string[];\n /**\n * Specify a subset of variables to be returned from one or more Data Collections\n */\n analysisVariables?: string[];\n /**\n * Specify an array of string values that describe what derivative variables to include in the output\n */\n addDerivativeVariables?: boolean;\n /**\n * Request the output geometries in the response\n */\n returnGeometry?: boolean;\n /**\n * Define the input geometries in the studyAreas parameter in a specified spatial reference system\n */\n inSR?: number;\n /**\n * Request the output geometries in a specified spatial reference system\n */\n outSR?: number;\n}\n\nexport interface IQueryDemographicDataResponse {\n results: IGeoenrichmentResult[] | null;\n messages: string[] | null;\n}\n\n/**\n * Used to get facts about a location or area. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/enrich.htm) for more information.\n *\n * ```js\n * import { queryDemographicData } from '@esri/arcgis-rest-demographics';\n * //\n * queryDemographicData({\n * studyAreas: [{\"geometry\":{\"x\":-117.1956,\"y\":34.0572}}],\n * authentication\n * })\n * .then((response) => {\n * response; // => { results: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the service.\n * @returns A Promise that will resolve with results for the request.\n */\nexport function queryDemographicData(\n requestOptions?: IQueryDemographicDataOptions\n): Promise<IQueryDemographicDataResponse> {\n const options = appendCustomParams<IQueryDemographicDataOptions>(\n requestOptions,\n [\n \"studyAreas\",\n \"dataCollections\",\n \"analysisVariables\",\n \"addDerivativeVariables\",\n \"returnGeometry\",\n \"inSR\",\n \"outSR\"\n ],\n { params: { ...requestOptions.params } }\n );\n\n // the SAAS service does not support anonymous requests\n if (!requestOptions.authentication) {\n return Promise.reject(\n \"Geoenrichment using the ArcGIS service requires authentication\"\n );\n }\n\n // These parameters are passed as JSON-style strings:\n [\"dataCollections\", \"analysisVariables\"].forEach((parameter) => {\n if (options.params[parameter]) {\n options.params[parameter] = JSON.stringify(options.params[parameter]);\n }\n });\n\n // add spatialReference property to individual matches\n return request(\n `${cleanUrl(\n `${requestOptions.endpoint || ARCGIS_ONLINE_GEOENRICHMENT_URL}/enrich`\n )}`,\n options\n ).then((response: any) => {\n return response;\n });\n}\n"],"names":["appendCustomParams","request","cleanUrl"],"mappings":";;;;;;;;;;;EAAA;;EAQA,MAAM,qCAAqC,GAAG,6EAA6E,CAAA;EACpH,MAAM,+BAA+B,GAAG,GAAG,qCAAqC,gBAAgB,CAAC;EACjG,MAAM,0CAA0C,GAAG,GAAG,qCAAqC,yBAAyB;;ECV3H;;EAyEA;;;;;;;;;;;;;;;WAegB,qBAAqB,CACnC,cAA8C;MAE9C,IAAI,OAAO,GAAqB,EAAE,CAAC;MACnC,IAAI,QAAQ,GAAG,GAAG,+BAA+B,YAAY,CAAC;MAC9D,IAAI,CAAC,cAAc,EAAE;UACnB,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;OACrB;WAAM;UACL,IAAI,cAAc,CAAC,QAAQ,EAAE;cAC3B,QAAQ,GAAG,GAAG,cAAc,CAAC,QAAQ,YAAY,CAAC;WACnD;UAED,OAAO,GAAGA,oCAAkB,CAC1B,cAAc,EACd,EAAE,EACF,EAAE,MAAM,oBAAO,cAAc,CAAC,MAAM,CAAE,EAAE,CACzC,CAAC;UACF,IAAI,cAAc,CAAC,WAAW,EAAE;cAC9B,QAAQ,GAAG,GAAG,QAAQ,IAAI,cAAc,CAAC,WAAW,EAAE,CAAC;WACxD;OACF;MAED,OAAOC,yBAAO,CAACC,0BAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAa;UAC7D,OAAO,QAAQ,CAAC;OACjB,CAAC,CAAC;EACL;;ECjHA;;EAuGA;;;;;;;;;;;;;;;;;;;;;;;WAuBgB,2BAA2B,CACzC,cAAoD;MAEpD,IAAI,OAAO,GAAwC,EAAE,CAAC;MACtD,IAAI,QAAQ,GAAG,GAAG,+BAA+B,kBAAkB,CAAC;MAEpE,IAAI,CAAC,cAAc,EAAE;UACnB,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;OACrB;WAAM;UACL,IAAI,cAAc,CAAC,QAAQ,EAAE;cAC3B,QAAQ,GAAG,GAAG,cAAc,CAAC,QAAQ,kBAAkB,CAAC;WACzD;UACD,OAAO,GAAGF,oCAAkB,CAC1B,cAAc,EACd,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,EAChD,EAAE,MAAM,oBAAO,cAAc,CAAC,MAAM,CAAE,EAAE,CACzC,CAAC;UAEF,IAAI,OAAO,CAAC,MAAM,CAAC,sBAAsB,EAAE;cACzC,OAAO,CAAC,MAAM,CAAC,sBAAsB,GAAG,IAAI,CAAC,SAAS,CACpD,OAAO,CAAC,MAAM,CAAC,sBAAsB,CACtC,CAAC;WACH;UAED,IAAI,cAAc,CAAC,WAAW,EAAE;cAC9B,QAAQ,GAAG,GAAG,QAAQ,IAAI,cAAc,CAAC,WAAW,EAAE,CAAC;cACvD,IAAI,cAAc,CAAC,cAAc,EAAE;kBACjC,QAAQ,GAAG,GAAG,QAAQ,IAAI,cAAc,CAAC,cAAc,EAAE,CAAC;eAC3D;WACF;OACF;;MAGD,OAAOC,yBAAO,CAAC,GAAGC,0BAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAa;UAClE,OAAO,QAAQ,CAAC;OACjB,CAAC,CAAC;EACL;;EClKA;;EAoDA;;;;;;;;;;;;;;;WAegB,2BAA2B,CACzC,cAAiC;MAEjC,IAAI,OAAO,GAAqB,EAAE,CAAC;MACnC,IAAI,QAAQ,GAAG,GAAG,+BAA+B,0BAA0B,CAAC;MAE5E,IAAI,CAAC,cAAc,EAAE;UACnB,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;OACrB;WAAM;UACL,IAAI,cAAc,CAAC,QAAQ,EAAE;cAC3B,QAAQ,GAAG,GAAG,cAAc,CAAC,QAAQ,0BAA0B,CAAC;WACjE;UACD,OAAO,GAAGF,oCAAkB,CAAmB,cAAc,EAAE,EAAE,EAAE;cACjE,MAAM,oBAAO,cAAc,CAAC,MAAM,CAAE;WACrC,CAAC,CAAC;OACJ;MAED,OAAOC,yBAAO,CAAC,GAAGC,0BAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAa;UAClE,OAAO,QAAQ,CAAC;OACjB,CAAC,CAAC;EACL;;ECvFA;;EAuFA;;;;;;;;;;;;;;;;;;WAkBgB,YAAY,CAC1B,cAAqC;MAErC,MAAM,QAAQ,GAAG,GACf,cAAc,CAAC,QAAQ,IAAI,0CAC7B,UAAU,CAAC;MAEX,MAAM,OAAO,GAAGF,oCAAkB,CAChC,cAAc,EACd;UACE,eAAe;UACf,wBAAwB;UACxB,iBAAiB;UACjB,cAAc;UACd,gBAAgB;UAChB,yBAAyB;UACzB,mBAAmB;UACnB,mBAAmB;UACnB,OAAO;UACP,gBAAgB;UAChB,iBAAiB;UACjB,qBAAqB;UACrB,gBAAgB;UAChB,cAAc;UACd,eAAe;UACf,UAAU;OACX,EACD,EAAE,MAAM,oBAAO,cAAc,CAAC,MAAM,CAAE,EAAE,CACzC,CAAC;;MAGF,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE;UAClC,OAAO,OAAO,CAAC,MAAM,CACnB,gEAAgE,CACjE,CAAC;OACH;;MAGD,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS;UACpD,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;cAC7B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;WACvE;OACF,CAAC,CAAC;;MAGH,OAAOC,yBAAO,CAAC,GAAGC,0BAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAa;UAClE,OAAO,QAAQ,CAAC;OACjB,CAAC,CAAC;EACL;;ECzJA;;EAmDA;;;;;;;;;;;;;;;;;;WAkBgB,oBAAoB,CAClC,cAA6C;MAE7C,MAAM,OAAO,GAAGF,oCAAkB,CAChC,cAAc,EACd;UACE,YAAY;UACZ,iBAAiB;UACjB,mBAAmB;UACnB,wBAAwB;UACxB,gBAAgB;UAChB,MAAM;UACN,OAAO;OACR,EACD,EAAE,MAAM,oBAAO,cAAc,CAAC,MAAM,CAAE,EAAE,CACzC,CAAC;;MAGF,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE;UAClC,OAAO,OAAO,CAAC,MAAM,CACnB,gEAAgE,CACjE,CAAC;OACH;;MAGD,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS;UACzD,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;cAC7B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;WACvE;OACF,CAAC,CAAC;;MAGH,OAAOC,yBAAO,CACZ,GAAGC,0BAAQ,CACT,GAAG,cAAc,CAAC,QAAQ,IAAI,+BAA+B,SAAS,CACvE,EAAE,EACH,OAAO,CACR,CAAC,IAAI,CAAC,CAAC,QAAa;UACnB,OAAO,QAAQ,CAAC;OACjB,CAAC,CAAC;EACL;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* @preserve
|
|
2
|
+
* @esri/arcgis-rest-demographics - v4.0.0-beta.5 - Apache-2.0
|
|
3
|
+
* Copyright (c) 2017-2022 Esri, Inc.
|
|
4
|
+
* Mon Apr 18 2022 16:42:05 GMT+0000 (Coordinated Universal Time)
|
|
5
|
+
*/
|
|
6
|
+
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],a):a((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisRest=e.arcgisRest||{},e.arcgisRest)}(this,(function(e,a){"use strict";const r="https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver",t=`${r}/Geoenrichment`,s=`${r}/StandardGeographyQuery`;e.getAvailableCountries=function(e){let r={},s=`${t}/countries`;return e?(e.endpoint&&(s=`${e.endpoint}/countries`),r=a.appendCustomParams(e,[],{params:Object.assign({},e.params)}),e.countryCode&&(s=`${s}/${e.countryCode}`)):r.params={},a.request(a.cleanUrl(s),r).then((e=>e))},e.getAvailableDataCollections=function(e){let r={},s=`${t}/dataCollections`;return e?(e.endpoint&&(s=`${e.endpoint}/dataCollections`),r=a.appendCustomParams(e,["addDerivativeVariables","suppressNullValues"],{params:Object.assign({},e.params)}),r.params.addDerivativeVariables&&(r.params.addDerivativeVariables=JSON.stringify(r.params.addDerivativeVariables)),e.countryCode&&(s=`${s}/${e.countryCode}`,e.dataCollection&&(s=`${s}/${e.dataCollection}`))):r.params={},a.request(`${a.cleanUrl(s)}`,r).then((e=>e))},e.getAvailableGeographyLevels=function(e){let r={},s=`${t}/StandardGeographyLevels`;return e?(e.endpoint&&(s=`${e.endpoint}/StandardGeographyLevels`),r=a.appendCustomParams(e,[],{params:Object.assign({},e.params)})):r.params={},a.request(`${a.cleanUrl(s)}`,r).then((e=>e))},e.getGeography=function(e){const r=`${e.endpoint||s}/execute`,t=a.appendCustomParams(e,["sourceCountry","optionalCountryDataset","geographyLayers","geographyIDs","geographyQuery","returnSubGeographyLayer","subGeographyLayer","subGeographyQuery","outSR","returnGeometry","returnCentroids","generalizationLevel","useFuzzySearch","featureLimit","featureOffset","langCode"],{params:Object.assign({},e.params)});return e.authentication?(["geographyLayers","geographyIDs"].forEach((e=>{t.params[e]&&(t.params[e]=JSON.stringify(t.params[e]))})),a.request(`${a.cleanUrl(r)}`,t).then((e=>e))):Promise.reject("Geoenrichment using the ArcGIS service requires authentication")},e.queryDemographicData=function(e){const r=a.appendCustomParams(e,["studyAreas","dataCollections","analysisVariables","addDerivativeVariables","returnGeometry","inSR","outSR"],{params:Object.assign({},e.params)});return e.authentication?(["dataCollections","analysisVariables"].forEach((e=>{r.params[e]&&(r.params[e]=JSON.stringify(r.params[e]))})),a.request(`${a.cleanUrl(`${e.endpoint||t}/enrich`)}`,r).then((e=>e))):Promise.reject("Geoenrichment using the ArcGIS service requires authentication")},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
7
|
+
//# sourceMappingURL=demographics.umd.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demographics.umd.min.js","sources":["../../src/helpers.ts","../../src/getAvailableCountries.ts","../../src/getAvailableDataCollections.ts","../../src/getAvailableGeographyLevels.ts","../../src/getGeography.ts","../../src/queryDemographicData.ts"],"sourcesContent":["/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n IRequestOptions,\n IFeatureSet\n} from \"@esri/arcgis-rest-request\";\n\nconst ARCGIS_ONLINE_GEOENRICHMENTSERVER_URL = \"https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver\"\nexport const ARCGIS_ONLINE_GEOENRICHMENT_URL = `${ARCGIS_ONLINE_GEOENRICHMENTSERVER_URL}/Geoenrichment`;\nexport const ARCGIS_ONLINE_STANDARD_GEOGRAPHY_QUERY_URL = `${ARCGIS_ONLINE_GEOENRICHMENTSERVER_URL}/StandardGeographyQuery`;\n\nexport interface IEndpointOptions extends IRequestOptions {\n /**\n * Any ArcGIS Geoenrichment service (example: https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver/Geoenrichment )\n */\n endpoint?: string;\n}\n\nexport interface IGeoenrichmentResult {\n paramName: string;\n dataType: string;\n value: {\n version: string;\n FeatureSet: IFeatureSet[];\n };\n}","/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams,\n IExtent\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetAvailableCountriesOptions extends IEndpointOptions {\n /**\n * View a description for a given country. If not specified, will return a list of all countries.\n */\n countryCode?: string;\n}\n\nexport interface IGetAvailableCountriesResponse {\n messages?: string[];\n countries?: ICountry[];\n childResources?: any[];\n}\nexport interface ICountry {\n id: string;\n name: string;\n abbr3: string;\n altName: string;\n continent: string;\n distanceUnits: string;\n esriUnits: string;\n defaultExtent: IExtent;\n defaultDatasetID: string;\n datasets?: string[];\n hierarchies?: IHierarchy[];\n defaultDataCollection: string;\n dataCollections: string;\n defaultReportTemplate: string;\n currencySymbol: string;\n currencyFormat: string;\n}\nexport interface IHierarchy {\n ID: string;\n alias: string;\n shortDescription: string;\n default: boolean;\n longDescription: string;\n locales?: string[];\n datasets?: string[];\n levelsInfo: ILevelsInfo;\n variablesInfo: IVariablesInfo;\n populationToPolygonSizeRating: number;\n apportionmentConfidence: number;\n apportionmentThresholds?: IApportionmentThreshold[];\n hasMarginOfErrorData?: boolean;\n}\nexport interface ILevelsInfo {\n geographyLevels?: string[];\n}\nexport interface IVariablesInfo {\n categories?: string[];\n}\nexport interface IApportionmentThreshold {\n method: string;\n dataLayer: string;\n pointsLayer?: string;\n maximumSize?: number;\n}\n\n/**\n * Return a list of information for all countries. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/countries.htm) for more information.\n *\n * ```js\n * import { getAvailableCountries } from '@esri/arcgis-rest-demographics';\n *\n * getAvailableCountries()\n * .then((response) => {\n * response; // => { countries: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the geoenrichment service.\n * @returns A Promise that will resolve with available geography levels for the request.\n */\nexport function getAvailableCountries(\n requestOptions?: IGetAvailableCountriesOptions\n): Promise<IGetAvailableCountriesResponse> {\n let options: IEndpointOptions = {};\n let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/countries`;\n if (!requestOptions) {\n options.params = {};\n } else {\n if (requestOptions.endpoint) {\n endpoint = `${requestOptions.endpoint}/countries`;\n }\n\n options = appendCustomParams<IGetAvailableCountriesOptions>(\n requestOptions,\n [],\n { params: { ...requestOptions.params } }\n );\n if (requestOptions.countryCode) {\n endpoint = `${endpoint}/${requestOptions.countryCode}`;\n }\n }\n\n return request(cleanUrl(endpoint), options).then((response: any) => {\n return response;\n });\n}\n","/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetAvailableDataCollectionsOptions extends IEndpointOptions {\n /**\n * Optional parameter to specify an array of string values that describe what derivative variables to include in the output.\n */\n addDerivativeVariables?: string[];\n /**\n * Optional parameter to return only values that are not NULL in the output response.\n */\n suppressNullValues?: boolean;\n /**\n * View a description for a single data collection within a given country. If not specified, will return a list of data collections that can be run in any country.\n */\n countryCode?: string;\n dataCollection?: string;\n}\n\nexport interface IGetAvailableDataCollectionsResponse {\n DataCollections?: IDataCollection[] | null;\n}\nexport interface IDataCollection {\n dataCollectionID: string;\n metadata: IMetadata;\n data?: IDataInfo[] | null;\n}\nexport interface IMetadata {\n title: string;\n name: string;\n shortDescription: string;\n longDescription: string;\n url: string;\n keywords: string;\n creationDate: number;\n lastRevisionDate: number;\n webmap: string;\n author: string;\n countries?: string | null;\n IsRoyalties: boolean;\n categories?: ICategory[] | null;\n filters?: IFilter[] | null;\n datasets?: string | null;\n hierarchies: string;\n coverage?: string | null;\n mobileinfographics?: string | null;\n icon?: string | null;\n}\nexport interface ICategory {\n id: string;\n name: string;\n alias: string;\n description: string;\n displayOrder: string;\n}\nexport interface IFilter {\n id: string;\n name: string;\n aliasname: string;\n type: string;\n rangeMax?: string | null;\n rangeMin?: string | null;\n enumValues?: string | null;\n}\nexport interface IDataInfo {\n id: string;\n alias: string;\n type: string;\n precision: number;\n length?: null;\n averageBase?: null;\n averageBaseAlias?: null;\n description: string;\n fieldCategory: string;\n indexBase?: number | null;\n percentBase?: string | null;\n percentBaseAlias?: string | null;\n popularity?: number | null;\n units: string;\n vintage?: string | null;\n hideInDataBrowser: boolean;\n filteringTags?: IFilteringTag[] | null;\n derivative: boolean;\n provider: string;\n indexType?: string | null;\n}\nexport interface IFilteringTag {\n id: string;\n name: string;\n value: string;\n}\n\n/**\n * Used to determine the data collections available for usage with the Geoenrichment service. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/data-collections.htm) for more information.\n *\n * ```js\n * import { getAvailableDataCollections } from '@esri/arcgis-rest-demographics';\n *\n * getAvailableDataCollections()\n * .then((response) => {\n * response; // => { DataCollections: [ ... ] }\n * });\n *\n * getAvailableDataCollections({\n * countryCode: \"se\",\n * dataCollection: \"EducationalAttainment\"\n * })\n * .then((response) => {\n * response.; // => { DataCollections: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the geoenrichment service.\n * @returns A Promise that will resolve with data collections for the request.\n */\nexport function getAvailableDataCollections(\n requestOptions?: IGetAvailableDataCollectionsOptions\n): Promise<IGetAvailableDataCollectionsResponse> {\n let options: IGetAvailableDataCollectionsOptions = {};\n let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/dataCollections`;\n\n if (!requestOptions) {\n options.params = {};\n } else {\n if (requestOptions.endpoint) {\n endpoint = `${requestOptions.endpoint}/dataCollections`;\n }\n options = appendCustomParams<IGetAvailableDataCollectionsOptions>(\n requestOptions,\n [\"addDerivativeVariables\", \"suppressNullValues\"],\n { params: { ...requestOptions.params } }\n );\n\n if (options.params.addDerivativeVariables) {\n options.params.addDerivativeVariables = JSON.stringify(\n options.params.addDerivativeVariables\n );\n }\n\n if (requestOptions.countryCode) {\n endpoint = `${endpoint}/${requestOptions.countryCode}`;\n if (requestOptions.dataCollection) {\n endpoint = `${endpoint}/${requestOptions.dataCollection}`;\n }\n }\n }\n\n // add spatialReference property to individual matches\n return request(`${cleanUrl(endpoint)}`, options).then((response: any) => {\n return response;\n });\n}\n","/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetAvailableGeographyLevelsResponse {\n messages?: string[] | null;\n childResources?: any[] | null;\n childDatasets?: any[] | null;\n childHierarchies?: any[] | null;\n geographyLevels?: IGeographyLevel[] | null;\n}\nexport interface IGeographyLevel {\n countryID: string;\n countryName: string;\n datasets?: IDataset[] | null;\n hierarchies?: IGeographyLevelHierarchy[] | null;\n}\nexport interface IDataset {\n datasetID: string;\n branches?: IBranch[] | null;\n levels?: ILevel[] | null;\n}\nexport interface IBranch {\n id: string;\n name: string;\n levels?: string[] | null;\n}\nexport interface ILevel {\n id: string;\n name: string;\n isWholeCountry: boolean;\n adminLevel: string;\n singularName: string;\n pluralName: string;\n description?: string | null;\n}\nexport interface IGeographyLevelHierarchy {\n ID: string;\n branches?: IBranch[] | null;\n levels?: ILevel[] | null;\n}\n\n/**\n * Returns a list of available geography data layers, which can then be used in [getGeography()](). See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/standard-geography-levels.htm) for more information.\n *\n * ```js\n * import { getAvailableGeographyLevels } from '@esri/arcgis-rest-demographics';\n * //\n * getAvailableGeographyLevels()\n * .then((response) => {\n * response; // => { geographyLevels: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the geoenrichment service.\n * @returns A Promise that will resolve with available geography levels for the request.\n */\nexport function getAvailableGeographyLevels(\n requestOptions?: IEndpointOptions\n): Promise<IGetAvailableGeographyLevelsResponse> {\n let options: IEndpointOptions = {};\n let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/StandardGeographyLevels`;\n\n if (!requestOptions) {\n options.params = {};\n } else {\n if (requestOptions.endpoint) {\n endpoint = `${requestOptions.endpoint}/StandardGeographyLevels`;\n }\n options = appendCustomParams<IEndpointOptions>(requestOptions, [], {\n params: { ...requestOptions.params }\n });\n }\n\n return request(`${cleanUrl(endpoint)}`, options).then((response: any) => {\n return response;\n });\n}\n","/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_STANDARD_GEOGRAPHY_QUERY_URL,\n IGeoenrichmentResult,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetGeographyOptions extends IEndpointOptions {\n /**\n * Specify the source country for the search.\n */\n sourceCountry?: string;\n /**\n * Specify a specific dataset within a defined country.\n */\n optionalCountryDataset?: string;\n /**\n * Specify which standard geography layers are being queried or searched.\n */\n geographyLayers?: string[] | string;\n /**\n * Specify which IDs for the standard geography layers are being queried or searched.\n */\n geographyIDs?: string[];\n /**\n * Specify the text to query and search the standard geography layers specified.\n */\n geographyQuery?: string;\n /**\n * Return all the subgeographic areas that are within a parent geography.\n */\n returnSubGeographyLayer?: boolean;\n /**\n * Return all the subgeographic areas that are within a parent geography.\n */\n subGeographyLayer?: string;\n /**\n * Filter the results of the subgeography features that are returned by a search term.\n */\n subGeographyQuery?: string;\n /**\n * Request the output geometries in a specified spatial reference system.\n */\n outSR?: number;\n /**\n * Request the output geometries in the response.\n */\n returnGeometry?: boolean;\n /**\n * Request the output geometry to return the center point for each feature.\n */\n returnCentroids?: boolean;\n /**\n * Integer that specifies the level of generalization or detail in the area representations of the administrative boundary or standard geographic data layers.\n */\n generalizationLevel?: number;\n /**\n * Define if text provided in the geographyQuery parameter should utilize fuzzy search logic.\n */\n useFuzzySearch?: boolean;\n /**\n * Limits the number of features that are returned from the geographyQuery parameter.\n */\n featureLimit?: number;\n /**\n * Starts the results on the number of the records specified.\n */\n featureOffset?: number;\n /**\n * Specifies the language you wish to receive your GeoEnrichment results.\n */\n langCode?: string;\n}\n\nexport interface IGetGeographyResponse {\n results: IGeoenrichmentResult[] | null;\n messages: string[] | null;\n}\n\n/**\n * Used to get standard geography IDs and features for the supported geographic levels. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/standard-geography-query.htm) and the [best practices post](https://www.esri.com/arcgis-blog/products/arcgis-online/uncategorized/best-practices-how-to-query-standard-geographies-branches) for more information.\n *\n * ```js\n * import { getGeography } from '@esri/arcgis-rest-demographics';\n * //\n * getGeography({\n * sourceCountry: \"CA\",\n * geographyIDs: [\"35\"]\n * })\n * .then((response) => {\n * response.; // => { results: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the service. All properties are optional, but either `geographyIds` or `geographyQuery` must be sent at a minimum.\n * @returns A Promise that will resolve with return data defined and optionally geometry for the feature.\n */\nexport function getGeography(\n requestOptions?: IGetGeographyOptions\n): Promise<IGetGeographyResponse> {\n const endpoint = `${\n requestOptions.endpoint || ARCGIS_ONLINE_STANDARD_GEOGRAPHY_QUERY_URL\n }/execute`;\n\n const options = appendCustomParams<IGetGeographyOptions>(\n requestOptions,\n [\n \"sourceCountry\",\n \"optionalCountryDataset\",\n \"geographyLayers\",\n \"geographyIDs\",\n \"geographyQuery\",\n \"returnSubGeographyLayer\",\n \"subGeographyLayer\",\n \"subGeographyQuery\",\n \"outSR\",\n \"returnGeometry\",\n \"returnCentroids\",\n \"generalizationLevel\",\n \"useFuzzySearch\",\n \"featureLimit\",\n \"featureOffset\",\n \"langCode\"\n ],\n { params: { ...requestOptions.params } }\n );\n\n // the SAAS service does not support anonymous requests\n if (!requestOptions.authentication) {\n return Promise.reject(\n \"Geoenrichment using the ArcGIS service requires authentication\"\n );\n }\n\n // These parameters are passed as JSON-style strings:\n [\"geographyLayers\", \"geographyIDs\"].forEach((parameter) => {\n if (options.params[parameter]) {\n options.params[parameter] = JSON.stringify(options.params[parameter]);\n }\n });\n\n // add spatialReference property to individual matches\n return request(`${cleanUrl(endpoint)}`, options).then((response: any) => {\n return response;\n });\n}\n","/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IGeoenrichmentResult,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IQueryDemographicDataOptions extends IEndpointOptions {\n /**\n * Defines the area on a map which is being analyzed\n */\n studyAreas: any[];\n /**\n * A Data Collection is a preassembled list of attributes that will be used to enrich the input features. Enrichment attributes can describe various types of information such as demographic characteristics and geographic context of the locations or areas submitted as input features in studyAreas.\n */\n dataCollections?: string[];\n /**\n * Specify a subset of variables to be returned from one or more Data Collections\n */\n analysisVariables?: string[];\n /**\n * Specify an array of string values that describe what derivative variables to include in the output\n */\n addDerivativeVariables?: boolean;\n /**\n * Request the output geometries in the response\n */\n returnGeometry?: boolean;\n /**\n * Define the input geometries in the studyAreas parameter in a specified spatial reference system\n */\n inSR?: number;\n /**\n * Request the output geometries in a specified spatial reference system\n */\n outSR?: number;\n}\n\nexport interface IQueryDemographicDataResponse {\n results: IGeoenrichmentResult[] | null;\n messages: string[] | null;\n}\n\n/**\n * Used to get facts about a location or area. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/enrich.htm) for more information.\n *\n * ```js\n * import { queryDemographicData } from '@esri/arcgis-rest-demographics';\n * //\n * queryDemographicData({\n * studyAreas: [{\"geometry\":{\"x\":-117.1956,\"y\":34.0572}}],\n * authentication\n * })\n * .then((response) => {\n * response; // => { results: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the service.\n * @returns A Promise that will resolve with results for the request.\n */\nexport function queryDemographicData(\n requestOptions?: IQueryDemographicDataOptions\n): Promise<IQueryDemographicDataResponse> {\n const options = appendCustomParams<IQueryDemographicDataOptions>(\n requestOptions,\n [\n \"studyAreas\",\n \"dataCollections\",\n \"analysisVariables\",\n \"addDerivativeVariables\",\n \"returnGeometry\",\n \"inSR\",\n \"outSR\"\n ],\n { params: { ...requestOptions.params } }\n );\n\n // the SAAS service does not support anonymous requests\n if (!requestOptions.authentication) {\n return Promise.reject(\n \"Geoenrichment using the ArcGIS service requires authentication\"\n );\n }\n\n // These parameters are passed as JSON-style strings:\n [\"dataCollections\", \"analysisVariables\"].forEach((parameter) => {\n if (options.params[parameter]) {\n options.params[parameter] = JSON.stringify(options.params[parameter]);\n }\n });\n\n // add spatialReference property to individual matches\n return request(\n `${cleanUrl(\n `${requestOptions.endpoint || ARCGIS_ONLINE_GEOENRICHMENT_URL}/enrich`\n )}`,\n options\n ).then((response: any) => {\n return response;\n });\n}\n"],"names":["ARCGIS_ONLINE_GEOENRICHMENTSERVER_URL","ARCGIS_ONLINE_GEOENRICHMENT_URL","ARCGIS_ONLINE_STANDARD_GEOGRAPHY_QUERY_URL","requestOptions","options","endpoint","appendCustomParams","params","countryCode","request","cleanUrl","then","response","addDerivativeVariables","JSON","stringify","dataCollection","authentication","forEach","parameter","Promise","reject"],"mappings":";;;;;gVAQA,MAAMA,EAAwC,8EACjCC,EAAkC,GAAGD,kBACrCE,EAA6C,GAAGF,4DC+E3DG,GAEA,IAAIC,EAA4B,GAC5BC,EAAW,GAAGJ,cAkBlB,OAjBKE,GAGCA,EAAeE,WACjBA,EAAW,GAAGF,EAAeE,sBAG/BD,EAAUE,qBACRH,EACA,GACA,CAAEI,wBAAaJ,EAAeI,UAE5BJ,EAAeK,cACjBH,EAAW,GAAGA,KAAYF,EAAeK,gBAZ3CJ,EAAQG,OAAS,GAgBZE,UAAQC,WAASL,GAAWD,GAASO,MAAMC,GACzCA,4CCgBTT,GAEA,IAAIC,EAA+C,GAC/CC,EAAW,GAAGJ,oBA6BlB,OA3BKE,GAGCA,EAAeE,WACjBA,EAAW,GAAGF,EAAeE,4BAE/BD,EAAUE,qBACRH,EACA,CAAC,yBAA0B,sBAC3B,CAAEI,wBAAaJ,EAAeI,UAG5BH,EAAQG,OAAOM,yBACjBT,EAAQG,OAAOM,uBAAyBC,KAAKC,UAC3CX,EAAQG,OAAOM,yBAIfV,EAAeK,cACjBH,EAAW,GAAGA,KAAYF,EAAeK,cACrCL,EAAea,iBACjBX,EAAW,GAAGA,KAAYF,EAAea,oBApB7CZ,EAAQG,OAAS,GA0BZE,UAAQ,GAAGC,WAASL,KAAaD,GAASO,MAAMC,GAC9CA,4CC5FTT,GAEA,IAAIC,EAA4B,GAC5BC,EAAW,GAAGJ,4BAalB,OAXKE,GAGCA,EAAeE,WACjBA,EAAW,GAAGF,EAAeE,oCAE/BD,EAAUE,qBAAqCH,EAAgB,GAAI,CACjEI,wBAAaJ,EAAeI,WAN9BH,EAAQG,OAAS,GAUZE,UAAQ,GAAGC,WAASL,KAAaD,GAASO,MAAMC,GAC9CA,6BCqBTT,GAEA,MAAME,EAAW,GACfF,EAAeE,UAAYH,YAGvBE,EAAUE,qBACdH,EACA,CACE,gBACA,yBACA,kBACA,eACA,iBACA,0BACA,oBACA,oBACA,QACA,iBACA,kBACA,sBACA,iBACA,eACA,gBACA,YAEF,CAAEI,wBAAaJ,EAAeI,UAIhC,OAAKJ,EAAec,gBAOpB,CAAC,kBAAmB,gBAAgBC,SAASC,IACvCf,EAAQG,OAAOY,KACjBf,EAAQG,OAAOY,GAAaL,KAAKC,UAAUX,EAAQG,OAAOY,QAKvDV,UAAQ,GAAGC,WAASL,KAAaD,GAASO,MAAMC,GAC9CA,KAdAQ,QAAQC,OACb,mGCpEJlB,GAEA,MAAMC,EAAUE,qBACdH,EACA,CACE,aACA,kBACA,oBACA,yBACA,iBACA,OACA,SAEF,CAAEI,wBAAaJ,EAAeI,UAIhC,OAAKJ,EAAec,gBAOpB,CAAC,kBAAmB,qBAAqBC,SAASC,IAC5Cf,EAAQG,OAAOY,KACjBf,EAAQG,OAAOY,GAAaL,KAAKC,UAAUX,EAAQG,OAAOY,QAKvDV,UACL,GAAGC,WACD,GAAGP,EAAeE,UAAYJ,cAEhCG,GACAO,MAAMC,GACCA,KAnBAQ,QAAQC,OACb"}
|
|
@@ -3,38 +3,39 @@
|
|
|
3
3
|
* Apache-2.0 */
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.getAvailableCountries = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var helpers_1 = require("./helpers");
|
|
6
|
+
const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
|
|
7
|
+
const helpers_js_1 = require("./helpers.js");
|
|
9
8
|
/**
|
|
9
|
+
* Return a list of information for all countries. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/countries.htm) for more information.
|
|
10
|
+
*
|
|
10
11
|
* ```js
|
|
11
12
|
* import { getAvailableCountries } from '@esri/arcgis-rest-demographics';
|
|
12
|
-
*
|
|
13
|
+
*
|
|
13
14
|
* getAvailableCountries()
|
|
14
15
|
* .then((response) => {
|
|
15
16
|
* response; // => { countries: [ ... ] }
|
|
16
17
|
* });
|
|
17
18
|
* ```
|
|
18
|
-
*
|
|
19
|
+
*
|
|
19
20
|
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
20
21
|
* @returns A Promise that will resolve with available geography levels for the request.
|
|
21
22
|
*/
|
|
22
23
|
function getAvailableCountries(requestOptions) {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
let options = {};
|
|
25
|
+
let endpoint = `${helpers_js_1.ARCGIS_ONLINE_GEOENRICHMENT_URL}/countries`;
|
|
25
26
|
if (!requestOptions) {
|
|
26
27
|
options.params = {};
|
|
27
28
|
}
|
|
28
29
|
else {
|
|
29
30
|
if (requestOptions.endpoint) {
|
|
30
|
-
endpoint = requestOptions.endpoint
|
|
31
|
+
endpoint = `${requestOptions.endpoint}/countries`;
|
|
31
32
|
}
|
|
32
|
-
options = arcgis_rest_request_1.appendCustomParams(requestOptions, [], { params:
|
|
33
|
+
options = (0, arcgis_rest_request_1.appendCustomParams)(requestOptions, [], { params: Object.assign({}, requestOptions.params) });
|
|
33
34
|
if (requestOptions.countryCode) {
|
|
34
|
-
endpoint = endpoint
|
|
35
|
+
endpoint = `${endpoint}/${requestOptions.countryCode}`;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
return arcgis_rest_request_1.request(arcgis_rest_request_1.cleanUrl(endpoint), options).then(
|
|
38
|
+
return (0, arcgis_rest_request_1.request)((0, arcgis_rest_request_1.cleanUrl)(endpoint), options).then((response) => {
|
|
38
39
|
return response;
|
|
39
40
|
});
|
|
40
41
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAvailableCountries.js","sourceRoot":"","sources":["../../src/getAvailableCountries.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,mEAKmC;AAEnC,6CAGsB;AA4DtB;;;;;;;;;;;;;;GAcG;AACH,SAAgB,qBAAqB,CACnC,cAA8C;IAE9C,IAAI,OAAO,GAAqB,EAAE,CAAC;IACnC,IAAI,QAAQ,GAAG,GAAG,4CAA+B,YAAY,CAAC;IAC9D,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;KACrB;SAAM;QACL,IAAI,cAAc,CAAC,QAAQ,EAAE;YAC3B,QAAQ,GAAG,GAAG,cAAc,CAAC,QAAQ,YAAY,CAAC;SACnD;QAED,OAAO,GAAG,IAAA,wCAAkB,EAC1B,cAAc,EACd,EAAE,EACF,EAAE,MAAM,oBAAO,cAAc,CAAC,MAAM,CAAE,EAAE,CACzC,CAAC;QACF,IAAI,cAAc,CAAC,WAAW,EAAE;YAC9B,QAAQ,GAAG,GAAG,QAAQ,IAAI,cAAc,CAAC,WAAW,EAAE,CAAC;SACxD;KACF;IAED,OAAO,IAAA,6BAAO,EAAC,IAAA,8BAAQ,EAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAa,EAAE,EAAE;QACjE,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAzBD,sDAyBC","sourcesContent":["/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams,\n IExtent\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetAvailableCountriesOptions extends IEndpointOptions {\n /**\n * View a description for a given country. If not specified, will return a list of all countries.\n */\n countryCode?: string;\n}\n\nexport interface IGetAvailableCountriesResponse {\n messages?: string[];\n countries?: ICountry[];\n childResources?: any[];\n}\nexport interface ICountry {\n id: string;\n name: string;\n abbr3: string;\n altName: string;\n continent: string;\n distanceUnits: string;\n esriUnits: string;\n defaultExtent: IExtent;\n defaultDatasetID: string;\n datasets?: string[];\n hierarchies?: IHierarchy[];\n defaultDataCollection: string;\n dataCollections: string;\n defaultReportTemplate: string;\n currencySymbol: string;\n currencyFormat: string;\n}\nexport interface IHierarchy {\n ID: string;\n alias: string;\n shortDescription: string;\n default: boolean;\n longDescription: string;\n locales?: string[];\n datasets?: string[];\n levelsInfo: ILevelsInfo;\n variablesInfo: IVariablesInfo;\n populationToPolygonSizeRating: number;\n apportionmentConfidence: number;\n apportionmentThresholds?: IApportionmentThreshold[];\n hasMarginOfErrorData?: boolean;\n}\nexport interface ILevelsInfo {\n geographyLevels?: string[];\n}\nexport interface IVariablesInfo {\n categories?: string[];\n}\nexport interface IApportionmentThreshold {\n method: string;\n dataLayer: string;\n pointsLayer?: string;\n maximumSize?: number;\n}\n\n/**\n * Return a list of information for all countries. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/countries.htm) for more information.\n *\n * ```js\n * import { getAvailableCountries } from '@esri/arcgis-rest-demographics';\n *\n * getAvailableCountries()\n * .then((response) => {\n * response; // => { countries: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the geoenrichment service.\n * @returns A Promise that will resolve with available geography levels for the request.\n */\nexport function getAvailableCountries(\n requestOptions?: IGetAvailableCountriesOptions\n): Promise<IGetAvailableCountriesResponse> {\n let options: IEndpointOptions = {};\n let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/countries`;\n if (!requestOptions) {\n options.params = {};\n } else {\n if (requestOptions.endpoint) {\n endpoint = `${requestOptions.endpoint}/countries`;\n }\n\n options = appendCustomParams<IGetAvailableCountriesOptions>(\n requestOptions,\n [],\n { params: { ...requestOptions.params } }\n );\n if (requestOptions.countryCode) {\n endpoint = `${endpoint}/${requestOptions.countryCode}`;\n }\n }\n\n return request(cleanUrl(endpoint), options).then((response: any) => {\n return response;\n });\n}\n"]}
|
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
* Apache-2.0 */
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.getAvailableDataCollections = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var helpers_1 = require("./helpers");
|
|
6
|
+
const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
|
|
7
|
+
const helpers_js_1 = require("./helpers.js");
|
|
9
8
|
/**
|
|
9
|
+
* Used to determine the data collections available for usage with the Geoenrichment service. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/data-collections.htm) for more information.
|
|
10
|
+
*
|
|
10
11
|
* ```js
|
|
11
12
|
* import { getAvailableDataCollections } from '@esri/arcgis-rest-demographics';
|
|
12
|
-
*
|
|
13
|
+
*
|
|
13
14
|
* getAvailableDataCollections()
|
|
14
15
|
* .then((response) => {
|
|
15
16
|
* response; // => { DataCollections: [ ... ] }
|
|
16
17
|
* });
|
|
17
|
-
*
|
|
18
|
+
*
|
|
18
19
|
* getAvailableDataCollections({
|
|
19
20
|
* countryCode: "se",
|
|
20
21
|
* dataCollection: "EducationalAttainment"
|
|
@@ -23,36 +24,33 @@ var helpers_1 = require("./helpers");
|
|
|
23
24
|
* response.; // => { DataCollections: [ ... ] }
|
|
24
25
|
* });
|
|
25
26
|
* ```
|
|
26
|
-
*
|
|
27
|
+
*
|
|
27
28
|
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
28
29
|
* @returns A Promise that will resolve with data collections for the request.
|
|
29
30
|
*/
|
|
30
31
|
function getAvailableDataCollections(requestOptions) {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
let options = {};
|
|
33
|
+
let endpoint = `${helpers_js_1.ARCGIS_ONLINE_GEOENRICHMENT_URL}/dataCollections`;
|
|
33
34
|
if (!requestOptions) {
|
|
34
35
|
options.params = {};
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
37
38
|
if (requestOptions.endpoint) {
|
|
38
|
-
endpoint = requestOptions.endpoint
|
|
39
|
+
endpoint = `${requestOptions.endpoint}/dataCollections`;
|
|
39
40
|
}
|
|
40
|
-
options = arcgis_rest_request_1.appendCustomParams(requestOptions, [
|
|
41
|
-
"addDerivativeVariables",
|
|
42
|
-
"suppressNullValues",
|
|
43
|
-
], { params: tslib_1.__assign({}, requestOptions.params) });
|
|
41
|
+
options = (0, arcgis_rest_request_1.appendCustomParams)(requestOptions, ["addDerivativeVariables", "suppressNullValues"], { params: Object.assign({}, requestOptions.params) });
|
|
44
42
|
if (options.params.addDerivativeVariables) {
|
|
45
43
|
options.params.addDerivativeVariables = JSON.stringify(options.params.addDerivativeVariables);
|
|
46
44
|
}
|
|
47
45
|
if (requestOptions.countryCode) {
|
|
48
|
-
endpoint = endpoint
|
|
46
|
+
endpoint = `${endpoint}/${requestOptions.countryCode}`;
|
|
49
47
|
if (requestOptions.dataCollection) {
|
|
50
|
-
endpoint = endpoint
|
|
48
|
+
endpoint = `${endpoint}/${requestOptions.dataCollection}`;
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
// add spatialReference property to individual matches
|
|
55
|
-
return arcgis_rest_request_1.request(
|
|
53
|
+
return (0, arcgis_rest_request_1.request)(`${(0, arcgis_rest_request_1.cleanUrl)(endpoint)}`, options).then((response) => {
|
|
56
54
|
return response;
|
|
57
55
|
});
|
|
58
56
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAvailableDataCollections.js","sourceRoot":"","sources":["../../src/getAvailableDataCollections.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,mEAImC;AAEnC,6CAGsB;AA2FtB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,2BAA2B,CACzC,cAAoD;IAEpD,IAAI,OAAO,GAAwC,EAAE,CAAC;IACtD,IAAI,QAAQ,GAAG,GAAG,4CAA+B,kBAAkB,CAAC;IAEpE,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;KACrB;SAAM;QACL,IAAI,cAAc,CAAC,QAAQ,EAAE;YAC3B,QAAQ,GAAG,GAAG,cAAc,CAAC,QAAQ,kBAAkB,CAAC;SACzD;QACD,OAAO,GAAG,IAAA,wCAAkB,EAC1B,cAAc,EACd,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,EAChD,EAAE,MAAM,oBAAO,cAAc,CAAC,MAAM,CAAE,EAAE,CACzC,CAAC;QAEF,IAAI,OAAO,CAAC,MAAM,CAAC,sBAAsB,EAAE;YACzC,OAAO,CAAC,MAAM,CAAC,sBAAsB,GAAG,IAAI,CAAC,SAAS,CACpD,OAAO,CAAC,MAAM,CAAC,sBAAsB,CACtC,CAAC;SACH;QAED,IAAI,cAAc,CAAC,WAAW,EAAE;YAC9B,QAAQ,GAAG,GAAG,QAAQ,IAAI,cAAc,CAAC,WAAW,EAAE,CAAC;YACvD,IAAI,cAAc,CAAC,cAAc,EAAE;gBACjC,QAAQ,GAAG,GAAG,QAAQ,IAAI,cAAc,CAAC,cAAc,EAAE,CAAC;aAC3D;SACF;KACF;IAED,sDAAsD;IACtD,OAAO,IAAA,6BAAO,EAAC,GAAG,IAAA,8BAAQ,EAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAa,EAAE,EAAE;QACtE,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AApCD,kEAoCC","sourcesContent":["/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetAvailableDataCollectionsOptions extends IEndpointOptions {\n /**\n * Optional parameter to specify an array of string values that describe what derivative variables to include in the output.\n */\n addDerivativeVariables?: string[];\n /**\n * Optional parameter to return only values that are not NULL in the output response.\n */\n suppressNullValues?: boolean;\n /**\n * View a description for a single data collection within a given country. If not specified, will return a list of data collections that can be run in any country.\n */\n countryCode?: string;\n dataCollection?: string;\n}\n\nexport interface IGetAvailableDataCollectionsResponse {\n DataCollections?: IDataCollection[] | null;\n}\nexport interface IDataCollection {\n dataCollectionID: string;\n metadata: IMetadata;\n data?: IDataInfo[] | null;\n}\nexport interface IMetadata {\n title: string;\n name: string;\n shortDescription: string;\n longDescription: string;\n url: string;\n keywords: string;\n creationDate: number;\n lastRevisionDate: number;\n webmap: string;\n author: string;\n countries?: string | null;\n IsRoyalties: boolean;\n categories?: ICategory[] | null;\n filters?: IFilter[] | null;\n datasets?: string | null;\n hierarchies: string;\n coverage?: string | null;\n mobileinfographics?: string | null;\n icon?: string | null;\n}\nexport interface ICategory {\n id: string;\n name: string;\n alias: string;\n description: string;\n displayOrder: string;\n}\nexport interface IFilter {\n id: string;\n name: string;\n aliasname: string;\n type: string;\n rangeMax?: string | null;\n rangeMin?: string | null;\n enumValues?: string | null;\n}\nexport interface IDataInfo {\n id: string;\n alias: string;\n type: string;\n precision: number;\n length?: null;\n averageBase?: null;\n averageBaseAlias?: null;\n description: string;\n fieldCategory: string;\n indexBase?: number | null;\n percentBase?: string | null;\n percentBaseAlias?: string | null;\n popularity?: number | null;\n units: string;\n vintage?: string | null;\n hideInDataBrowser: boolean;\n filteringTags?: IFilteringTag[] | null;\n derivative: boolean;\n provider: string;\n indexType?: string | null;\n}\nexport interface IFilteringTag {\n id: string;\n name: string;\n value: string;\n}\n\n/**\n * Used to determine the data collections available for usage with the Geoenrichment service. See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/data-collections.htm) for more information.\n *\n * ```js\n * import { getAvailableDataCollections } from '@esri/arcgis-rest-demographics';\n *\n * getAvailableDataCollections()\n * .then((response) => {\n * response; // => { DataCollections: [ ... ] }\n * });\n *\n * getAvailableDataCollections({\n * countryCode: \"se\",\n * dataCollection: \"EducationalAttainment\"\n * })\n * .then((response) => {\n * response.; // => { DataCollections: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the geoenrichment service.\n * @returns A Promise that will resolve with data collections for the request.\n */\nexport function getAvailableDataCollections(\n requestOptions?: IGetAvailableDataCollectionsOptions\n): Promise<IGetAvailableDataCollectionsResponse> {\n let options: IGetAvailableDataCollectionsOptions = {};\n let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/dataCollections`;\n\n if (!requestOptions) {\n options.params = {};\n } else {\n if (requestOptions.endpoint) {\n endpoint = `${requestOptions.endpoint}/dataCollections`;\n }\n options = appendCustomParams<IGetAvailableDataCollectionsOptions>(\n requestOptions,\n [\"addDerivativeVariables\", \"suppressNullValues\"],\n { params: { ...requestOptions.params } }\n );\n\n if (options.params.addDerivativeVariables) {\n options.params.addDerivativeVariables = JSON.stringify(\n options.params.addDerivativeVariables\n );\n }\n\n if (requestOptions.countryCode) {\n endpoint = `${endpoint}/${requestOptions.countryCode}`;\n if (requestOptions.dataCollection) {\n endpoint = `${endpoint}/${requestOptions.dataCollection}`;\n }\n }\n }\n\n // add spatialReference property to individual matches\n return request(`${cleanUrl(endpoint)}`, options).then((response: any) => {\n return response;\n });\n}\n"]}
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* Apache-2.0 */
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.getAvailableGeographyLevels = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var helpers_1 = require("./helpers");
|
|
6
|
+
const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
|
|
7
|
+
const helpers_js_1 = require("./helpers.js");
|
|
9
8
|
/**
|
|
9
|
+
* Returns a list of available geography data layers, which can then be used in [getGeography()](). See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/standard-geography-levels.htm) for more information.
|
|
10
|
+
*
|
|
10
11
|
* ```js
|
|
11
12
|
* import { getAvailableGeographyLevels } from '@esri/arcgis-rest-demographics';
|
|
12
13
|
* //
|
|
@@ -15,23 +16,25 @@ var helpers_1 = require("./helpers");
|
|
|
15
16
|
* response; // => { geographyLevels: [ ... ] }
|
|
16
17
|
* });
|
|
17
18
|
* ```
|
|
18
|
-
*
|
|
19
|
+
*
|
|
19
20
|
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
20
21
|
* @returns A Promise that will resolve with available geography levels for the request.
|
|
21
22
|
*/
|
|
22
23
|
function getAvailableGeographyLevels(requestOptions) {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
let options = {};
|
|
25
|
+
let endpoint = `${helpers_js_1.ARCGIS_ONLINE_GEOENRICHMENT_URL}/StandardGeographyLevels`;
|
|
25
26
|
if (!requestOptions) {
|
|
26
27
|
options.params = {};
|
|
27
28
|
}
|
|
28
29
|
else {
|
|
29
30
|
if (requestOptions.endpoint) {
|
|
30
|
-
endpoint = requestOptions.endpoint
|
|
31
|
+
endpoint = `${requestOptions.endpoint}/StandardGeographyLevels`;
|
|
31
32
|
}
|
|
32
|
-
options = arcgis_rest_request_1.appendCustomParams(requestOptions, [], {
|
|
33
|
+
options = (0, arcgis_rest_request_1.appendCustomParams)(requestOptions, [], {
|
|
34
|
+
params: Object.assign({}, requestOptions.params)
|
|
35
|
+
});
|
|
33
36
|
}
|
|
34
|
-
return arcgis_rest_request_1.request(
|
|
37
|
+
return (0, arcgis_rest_request_1.request)(`${(0, arcgis_rest_request_1.cleanUrl)(endpoint)}`, options).then((response) => {
|
|
35
38
|
return response;
|
|
36
39
|
});
|
|
37
40
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAvailableGeographyLevels.js","sourceRoot":"","sources":["../../src/getAvailableGeographyLevels.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,mEAImC;AAEnC,6CAGsB;AAwCtB;;;;;;;;;;;;;;GAcG;AACH,SAAgB,2BAA2B,CACzC,cAAiC;IAEjC,IAAI,OAAO,GAAqB,EAAE,CAAC;IACnC,IAAI,QAAQ,GAAG,GAAG,4CAA+B,0BAA0B,CAAC;IAE5E,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;KACrB;SAAM;QACL,IAAI,cAAc,CAAC,QAAQ,EAAE;YAC3B,QAAQ,GAAG,GAAG,cAAc,CAAC,QAAQ,0BAA0B,CAAC;SACjE;QACD,OAAO,GAAG,IAAA,wCAAkB,EAAmB,cAAc,EAAE,EAAE,EAAE;YACjE,MAAM,oBAAO,cAAc,CAAC,MAAM,CAAE;SACrC,CAAC,CAAC;KACJ;IAED,OAAO,IAAA,6BAAO,EAAC,GAAG,IAAA,8BAAQ,EAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAa,EAAE,EAAE;QACtE,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AApBD,kEAoBC","sourcesContent":["/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_GEOENRICHMENT_URL,\n IEndpointOptions\n} from \"./helpers.js\";\n\nexport interface IGetAvailableGeographyLevelsResponse {\n messages?: string[] | null;\n childResources?: any[] | null;\n childDatasets?: any[] | null;\n childHierarchies?: any[] | null;\n geographyLevels?: IGeographyLevel[] | null;\n}\nexport interface IGeographyLevel {\n countryID: string;\n countryName: string;\n datasets?: IDataset[] | null;\n hierarchies?: IGeographyLevelHierarchy[] | null;\n}\nexport interface IDataset {\n datasetID: string;\n branches?: IBranch[] | null;\n levels?: ILevel[] | null;\n}\nexport interface IBranch {\n id: string;\n name: string;\n levels?: string[] | null;\n}\nexport interface ILevel {\n id: string;\n name: string;\n isWholeCountry: boolean;\n adminLevel: string;\n singularName: string;\n pluralName: string;\n description?: string | null;\n}\nexport interface IGeographyLevelHierarchy {\n ID: string;\n branches?: IBranch[] | null;\n levels?: ILevel[] | null;\n}\n\n/**\n * Returns a list of available geography data layers, which can then be used in [getGeography()](). See the [REST Documentation](https://developers.arcgis.com/rest/geoenrichment/api-reference/standard-geography-levels.htm) for more information.\n *\n * ```js\n * import { getAvailableGeographyLevels } from '@esri/arcgis-rest-demographics';\n * //\n * getAvailableGeographyLevels()\n * .then((response) => {\n * response; // => { geographyLevels: [ ... ] }\n * });\n * ```\n *\n * @param requestOptions Options to pass through to the geoenrichment service.\n * @returns A Promise that will resolve with available geography levels for the request.\n */\nexport function getAvailableGeographyLevels(\n requestOptions?: IEndpointOptions\n): Promise<IGetAvailableGeographyLevelsResponse> {\n let options: IEndpointOptions = {};\n let endpoint = `${ARCGIS_ONLINE_GEOENRICHMENT_URL}/StandardGeographyLevels`;\n\n if (!requestOptions) {\n options.params = {};\n } else {\n if (requestOptions.endpoint) {\n endpoint = `${requestOptions.endpoint}/StandardGeographyLevels`;\n }\n options = appendCustomParams<IEndpointOptions>(requestOptions, [], {\n params: { ...requestOptions.params }\n });\n }\n\n return request(`${cleanUrl(endpoint)}`, options).then((response: any) => {\n return response;\n });\n}\n"]}
|