@esri/arcgis-rest-demographics 4.0.0-beta.3 → 4.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled/demographics.esm.js +20 -10
- package/dist/bundled/demographics.esm.js.map +1 -1
- package/dist/bundled/demographics.esm.min.js +2 -2
- package/dist/bundled/demographics.esm.min.js.map +1 -1
- package/dist/bundled/demographics.umd.js +20 -10
- package/dist/bundled/demographics.umd.js.map +1 -1
- package/dist/bundled/demographics.umd.min.js +2 -2
- package/dist/bundled/demographics.umd.min.js.map +1 -1
- package/dist/cjs/getAvailableCountries.js +4 -2
- package/dist/cjs/getAvailableCountries.js.map +1 -1
- package/dist/cjs/getAvailableDataCollections.js +5 -3
- package/dist/cjs/getAvailableDataCollections.js.map +1 -1
- package/dist/cjs/getAvailableGeographyLevels.js +3 -1
- package/dist/cjs/getAvailableGeographyLevels.js.map +1 -1
- package/dist/cjs/getGeography.js +3 -1
- package/dist/cjs/getGeography.js.map +1 -1
- package/dist/cjs/queryDemographicData.js +3 -1
- package/dist/cjs/queryDemographicData.js.map +1 -1
- package/dist/esm/getAvailableCountries.d.ts +4 -2
- package/dist/esm/getAvailableCountries.js +4 -2
- package/dist/esm/getAvailableCountries.js.map +1 -1
- package/dist/esm/getAvailableDataCollections.d.ts +5 -3
- package/dist/esm/getAvailableDataCollections.js +5 -3
- package/dist/esm/getAvailableDataCollections.js.map +1 -1
- package/dist/esm/getAvailableGeographyLevels.d.ts +3 -1
- package/dist/esm/getAvailableGeographyLevels.js +3 -1
- package/dist/esm/getAvailableGeographyLevels.js.map +1 -1
- package/dist/esm/getGeography.d.ts +3 -1
- package/dist/esm/getGeography.js +3 -1
- package/dist/esm/getGeography.js.map +1 -1
- package/dist/esm/queryDemographicData.d.ts +3 -1
- package/dist/esm/queryDemographicData.js +3 -1
- package/dist/esm/queryDemographicData.js.map +1 -1
- package/package.json +8 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-demographics - v4.0.0-beta.
|
|
2
|
+
* @esri/arcgis-rest-demographics - v4.0.0-beta.5 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2022 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Tue May 10 2022 02:53:26 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
6
|
import { appendCustomParams, request, cleanUrl } from '@esri/arcgis-rest-request';
|
|
7
7
|
|
|
@@ -14,15 +14,17 @@ const ARCGIS_ONLINE_STANDARD_GEOGRAPHY_QUERY_URL = `${ARCGIS_ONLINE_GEOENRICHMEN
|
|
|
14
14
|
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
15
15
|
* Apache-2.0 */
|
|
16
16
|
/**
|
|
17
|
+
* 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.
|
|
18
|
+
*
|
|
17
19
|
* ```js
|
|
18
20
|
* import { getAvailableCountries } from '@esri/arcgis-rest-demographics';
|
|
19
|
-
*
|
|
21
|
+
*
|
|
20
22
|
* getAvailableCountries()
|
|
21
23
|
* .then((response) => {
|
|
22
24
|
* response; // => { countries: [ ... ] }
|
|
23
25
|
* });
|
|
24
26
|
* ```
|
|
25
|
-
*
|
|
27
|
+
*
|
|
26
28
|
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
27
29
|
* @returns A Promise that will resolve with available geography levels for the request.
|
|
28
30
|
*/
|
|
@@ -49,14 +51,16 @@ function getAvailableCountries(requestOptions) {
|
|
|
49
51
|
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
50
52
|
* Apache-2.0 */
|
|
51
53
|
/**
|
|
54
|
+
* 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.
|
|
55
|
+
*
|
|
52
56
|
* ```js
|
|
53
57
|
* import { getAvailableDataCollections } from '@esri/arcgis-rest-demographics';
|
|
54
|
-
*
|
|
58
|
+
*
|
|
55
59
|
* getAvailableDataCollections()
|
|
56
60
|
* .then((response) => {
|
|
57
61
|
* response; // => { DataCollections: [ ... ] }
|
|
58
62
|
* });
|
|
59
|
-
*
|
|
63
|
+
*
|
|
60
64
|
* getAvailableDataCollections({
|
|
61
65
|
* countryCode: "se",
|
|
62
66
|
* dataCollection: "EducationalAttainment"
|
|
@@ -65,7 +69,7 @@ function getAvailableCountries(requestOptions) {
|
|
|
65
69
|
* response.; // => { DataCollections: [ ... ] }
|
|
66
70
|
* });
|
|
67
71
|
* ```
|
|
68
|
-
*
|
|
72
|
+
*
|
|
69
73
|
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
70
74
|
* @returns A Promise that will resolve with data collections for the request.
|
|
71
75
|
*/
|
|
@@ -99,6 +103,8 @@ function getAvailableDataCollections(requestOptions) {
|
|
|
99
103
|
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
100
104
|
* Apache-2.0 */
|
|
101
105
|
/**
|
|
106
|
+
* 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.
|
|
107
|
+
*
|
|
102
108
|
* ```js
|
|
103
109
|
* import { getAvailableGeographyLevels } from '@esri/arcgis-rest-demographics';
|
|
104
110
|
* //
|
|
@@ -107,7 +113,7 @@ function getAvailableDataCollections(requestOptions) {
|
|
|
107
113
|
* response; // => { geographyLevels: [ ... ] }
|
|
108
114
|
* });
|
|
109
115
|
* ```
|
|
110
|
-
*
|
|
116
|
+
*
|
|
111
117
|
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
112
118
|
* @returns A Promise that will resolve with available geography levels for the request.
|
|
113
119
|
*/
|
|
@@ -133,6 +139,8 @@ function getAvailableGeographyLevels(requestOptions) {
|
|
|
133
139
|
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
134
140
|
* Apache-2.0 */
|
|
135
141
|
/**
|
|
142
|
+
* 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.
|
|
143
|
+
*
|
|
136
144
|
* ```js
|
|
137
145
|
* import { getGeography } from '@esri/arcgis-rest-demographics';
|
|
138
146
|
* //
|
|
@@ -144,7 +152,7 @@ function getAvailableGeographyLevels(requestOptions) {
|
|
|
144
152
|
* response.; // => { results: [ ... ] }
|
|
145
153
|
* });
|
|
146
154
|
* ```
|
|
147
|
-
*
|
|
155
|
+
*
|
|
148
156
|
* @param requestOptions Options to pass through to the service. All properties are optional, but either `geographyIds` or `geographyQuery` must be sent at a minimum.
|
|
149
157
|
* @returns A Promise that will resolve with return data defined and optionally geometry for the feature.
|
|
150
158
|
*/
|
|
@@ -187,6 +195,8 @@ function getGeography(requestOptions) {
|
|
|
187
195
|
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
188
196
|
* Apache-2.0 */
|
|
189
197
|
/**
|
|
198
|
+
* 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.
|
|
199
|
+
*
|
|
190
200
|
* ```js
|
|
191
201
|
* import { queryDemographicData } from '@esri/arcgis-rest-demographics';
|
|
192
202
|
* //
|
|
@@ -198,7 +208,7 @@ function getGeography(requestOptions) {
|
|
|
198
208
|
* response; // => { results: [ ... ] }
|
|
199
209
|
* });
|
|
200
210
|
* ```
|
|
201
|
-
*
|
|
211
|
+
*
|
|
202
212
|
* @param requestOptions Options to pass through to the service.
|
|
203
213
|
* @returns A Promise that will resolve with results for the request.
|
|
204
214
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"demographics.esm.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\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 * ```js\n * import { getAvailableCountries } from '@esri/arcgis-rest-demographics';\n * //\n * getAvailableCountries()\n * .then((response) => {\n * response; // => { countries: [ ... ] }\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 * @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 * ```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 * 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 * @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 * ```js\n * import { getAvailableGeographyLevels } from '@esri/arcgis-rest-demographics';\n * //\n * getAvailableGeographyLevels()\n * .then((response) => {\n * response; // => { geographyLevels: [ ... ] }\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 * @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 * ```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 * 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 * @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 * ```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 * 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 * @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_GEOENRICH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AAO,GAAG,kBAAkB,CAChC,cAAc,EACd;QACE,YAAY;QACZ,iBAAiB;QACjB,mBAAmB;QACnB,wBAAwB;QACxB,gBAAgB;QAChB,MAAM;QACN,OAAO;KACR,EACD,EAAE,MAAM,oBAAO,cAAc,CAAC,MAAM,CAAE,EAAE,CACzC,CAAC;;IAGF,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE;QAClC,OAAO,OAAO,CAAC,MAAM,CACnB,gEAAgE,CACjE,CAAC;KACH;;IAGD,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS;QACzD,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YAC7B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;SACvE;KACF,CAAC,CAAC;;IAGH,OAAO,OAAO,CACZ,GAAG,QAAQ,CACT,GAAG,cAAc,CAAC,QAAQ,IAAI,+BAA+B,SAAS,CACvE,EAAE,EACH,OAAO,CACR,CAAC,IAAI,CAAC,CAAC,QAAa;QACnB,OAAO,QAAQ,CAAC;KACjB,CAAC,CAAC;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"demographics.esm.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":[],"mappings":";;;;;;;AAAA;;AAQA,MAAM,qCAAqC,GAAG,6EAA6E,CAAA;AACpH,MAAM,+BAA+B,GAAG,GAAG,qCAAqC,gBAAgB,CAAC;AACjG,MAAM,0CAA0C,GAAG,GAAG,qCAAqC,yBAAyB;;ACV3H;;AAyEA;;;;;;;;;;;;;;;SAegB,qBAAqB,CACnC,cAA8C;IAE9C,IAAI,OAAO,GAAqB,EAAE,CAAC;IACnC,IAAI,QAAQ,GAAG,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C,CAAC,OAAO,CAAC,CAAC,SAAS;QACzD,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YAC7B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;SACvE;KACF,CAAC,CAAC;;IAGH,OAAO,OAAO,CACZ,GAAG,QAAQ,CACT,GAAG,cAAc,CAAC,QAAQ,IAAI,+BAA+B,SAAS,CACvE,EAAE,EACH,OAAO,CACR,CAAC,IAAI,CAAC,CAAC,QAAa;QACnB,OAAO,QAAQ,CAAC;KACjB,CAAC,CAAC;AACL;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-demographics - v4.0.0-beta.
|
|
2
|
+
* @esri/arcgis-rest-demographics - v4.0.0-beta.5 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2022 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Tue May 10 2022 02:53:26 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
6
|
import{appendCustomParams as e,request as r,cleanUrl as a}from"@esri/arcgis-rest-request";const t="https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver/Geoenrichment";function s(s){let n={},i=`${t}/countries`;return s?(s.endpoint&&(i=`${s.endpoint}/countries`),n=e(s,[],{params:Object.assign({},s.params)}),s.countryCode&&(i=`${i}/${s.countryCode}`)):n.params={},r(a(i),n).then((e=>e))}function n(s){let n={},i=`${t}/dataCollections`;return s?(s.endpoint&&(i=`${s.endpoint}/dataCollections`),n=e(s,["addDerivativeVariables","suppressNullValues"],{params:Object.assign({},s.params)}),n.params.addDerivativeVariables&&(n.params.addDerivativeVariables=JSON.stringify(n.params.addDerivativeVariables)),s.countryCode&&(i=`${i}/${s.countryCode}`,s.dataCollection&&(i=`${i}/${s.dataCollection}`))):n.params={},r(`${a(i)}`,n).then((e=>e))}function i(s){let n={},i=`${t}/StandardGeographyLevels`;return s?(s.endpoint&&(i=`${s.endpoint}/StandardGeographyLevels`),n=e(s,[],{params:Object.assign({},s.params)})):n.params={},r(`${a(i)}`,n).then((e=>e))}function o(t){const s=`${t.endpoint||"https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver/StandardGeographyQuery"}/execute`,n=e(t,["sourceCountry","optionalCountryDataset","geographyLayers","geographyIDs","geographyQuery","returnSubGeographyLayer","subGeographyLayer","subGeographyQuery","outSR","returnGeometry","returnCentroids","generalizationLevel","useFuzzySearch","featureLimit","featureOffset","langCode"],{params:Object.assign({},t.params)});return t.authentication?(["geographyLayers","geographyIDs"].forEach((e=>{n.params[e]&&(n.params[e]=JSON.stringify(n.params[e]))})),r(`${a(s)}`,n).then((e=>e))):Promise.reject("Geoenrichment using the ArcGIS service requires authentication")}function c(s){const n=e(s,["studyAreas","dataCollections","analysisVariables","addDerivativeVariables","returnGeometry","inSR","outSR"],{params:Object.assign({},s.params)});return s.authentication?(["dataCollections","analysisVariables"].forEach((e=>{n.params[e]&&(n.params[e]=JSON.stringify(n.params[e]))})),r(`${a(`${s.endpoint||t}/enrich`)}`,n).then((e=>e))):Promise.reject("Geoenrichment using the ArcGIS service requires authentication")}export{s as getAvailableCountries,n as getAvailableDataCollections,i as getAvailableGeographyLevels,o as getGeography,c as queryDemographicData};
|
|
7
7
|
//# sourceMappingURL=demographics.esm.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"demographics.esm.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\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 * ```js\n * import { getAvailableCountries } from '@esri/arcgis-rest-demographics';\n * //\n * getAvailableCountries()\n * .then((response) => {\n * response; // => { countries: [ ... ] }\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 * @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 * ```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 * 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 * @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 * ```js\n * import { getAvailableGeographyLevels } from '@esri/arcgis-rest-demographics';\n * //\n * getAvailableGeographyLevels()\n * .then((response) => {\n * response; // => { geographyLevels: [ ... ] }\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 * @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 * ```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 * 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 * @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 * ```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 * 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 * @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_GEOENRICHMENT_URL","getAvailableCountries","requestOptions","options","endpoint","appendCustomParams","params","countryCode","request","cleanUrl","then","response","getAvailableDataCollections","addDerivativeVariables","JSON","stringify","dataCollection","getAvailableGeographyLevels","getGeography","authentication","for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ACA,iBACA,eACA,gBACA,YAEF,CAAEI,wBAAaJ,EAAeI,UAIhC,OAAKJ,EAAeiB,gBAOpB,CAAC,kBAAmB,gBAAgBC,SAASC,IACvClB,EAAQG,OAAOe,KACjBlB,EAAQG,OAAOe,GAAaP,KAAKC,UAAUZ,EAAQG,OAAOe,QAKvDb,EAAQ,GAAGC,EAASL,KAAaD,GAASO,MAAMC,GAC9CA,KAdAW,QAAQC,OACb,2ECrEUC,EACdtB,GAEA,MAAMC,EAAUE,EACdH,EACA,CACE,aACA,kBACA,oBACA,yBACA,iBACA,OACA,SAEF,CAAEI,wBAAaJ,EAAeI,UAIhC,OAAKJ,EAAeiB,gBAOpB,CAAC,kBAAmB,qBAAqBC,SAASC,IAC5ClB,EAAQG,OAAOe,KACjBlB,EAAQG,OAAOe,GAAaP,KAAKC,UAAUZ,EAAQG,OAAOe,QAKvDb,EACL,GAAGC,EACD,GAAGP,EAAeE,UAAYJ,cAEhCG,GACAO,MAAMC,GACCA,KAnBAW,QAAQC,OACb"}
|
|
1
|
+
{"version":3,"file":"demographics.esm.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_GEOENRICHMENT_URL","getAvailableCountries","requestOptions","options","endpoint","appendCustomParams","params","countryCode","request","cleanUrl","then","response","getAvailableDataCollections","addDerivativeVariables","JSON","stringify","dataCollection","getAvailableGeographyLevels","getGeography","authentication","forEach","parameter","Promise","reject","queryDemographicData"],"mappings":";;;;;0FAQA,MACaA,EAAkC,qGC+E/BC,EACdC,GAEA,IAAIC,EAA4B,GAC5BC,EAAW,GAAGJ,cAkBlB,OAjBKE,GAGCA,EAAeE,WACjBA,EAAW,GAAGF,EAAeE,sBAG/BD,EAAUE,EACRH,EACA,GACA,CAAEI,wBAAaJ,EAAeI,UAE5BJ,EAAeK,cACjBH,EAAW,GAAG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,2ECrEUC,EACdtB,GAEA,MAAMC,EAAUE,EACdH,EACA,CACE,aACA,kBACA,oBACA,yBACA,iBACA,OACA,SAEF,CAAEI,wBAAaJ,EAAeI,UAIhC,OAAKJ,EAAeiB,gBAOpB,CAAC,kBAAmB,qBAAqBC,SAASC,IAC5ClB,EAAQG,OAAOe,KACjBlB,EAAQG,OAAOe,GAAaP,KAAKC,UAAUZ,EAAQG,OAAOe,QAKvDb,EACL,GAAGC,EACD,GAAGP,EAAeE,UAAYJ,cAEhCG,GACAO,MAAMC,GACCA,KAnBAW,QAAQC,OACb"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-demographics - v4.0.0-beta.
|
|
2
|
+
* @esri/arcgis-rest-demographics - v4.0.0-beta.5 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2022 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Tue May 10 2022 02:53:26 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
7
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/arcgis-rest-request')) :
|
|
@@ -18,15 +18,17 @@
|
|
|
18
18
|
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
19
19
|
* Apache-2.0 */
|
|
20
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
|
+
*
|
|
21
23
|
* ```js
|
|
22
24
|
* import { getAvailableCountries } from '@esri/arcgis-rest-demographics';
|
|
23
|
-
*
|
|
25
|
+
*
|
|
24
26
|
* getAvailableCountries()
|
|
25
27
|
* .then((response) => {
|
|
26
28
|
* response; // => { countries: [ ... ] }
|
|
27
29
|
* });
|
|
28
30
|
* ```
|
|
29
|
-
*
|
|
31
|
+
*
|
|
30
32
|
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
31
33
|
* @returns A Promise that will resolve with available geography levels for the request.
|
|
32
34
|
*/
|
|
@@ -53,14 +55,16 @@
|
|
|
53
55
|
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
54
56
|
* Apache-2.0 */
|
|
55
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
|
+
*
|
|
56
60
|
* ```js
|
|
57
61
|
* import { getAvailableDataCollections } from '@esri/arcgis-rest-demographics';
|
|
58
|
-
*
|
|
62
|
+
*
|
|
59
63
|
* getAvailableDataCollections()
|
|
60
64
|
* .then((response) => {
|
|
61
65
|
* response; // => { DataCollections: [ ... ] }
|
|
62
66
|
* });
|
|
63
|
-
*
|
|
67
|
+
*
|
|
64
68
|
* getAvailableDataCollections({
|
|
65
69
|
* countryCode: "se",
|
|
66
70
|
* dataCollection: "EducationalAttainment"
|
|
@@ -69,7 +73,7 @@
|
|
|
69
73
|
* response.; // => { DataCollections: [ ... ] }
|
|
70
74
|
* });
|
|
71
75
|
* ```
|
|
72
|
-
*
|
|
76
|
+
*
|
|
73
77
|
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
74
78
|
* @returns A Promise that will resolve with data collections for the request.
|
|
75
79
|
*/
|
|
@@ -103,6 +107,8 @@
|
|
|
103
107
|
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
104
108
|
* Apache-2.0 */
|
|
105
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
|
+
*
|
|
106
112
|
* ```js
|
|
107
113
|
* import { getAvailableGeographyLevels } from '@esri/arcgis-rest-demographics';
|
|
108
114
|
* //
|
|
@@ -111,7 +117,7 @@
|
|
|
111
117
|
* response; // => { geographyLevels: [ ... ] }
|
|
112
118
|
* });
|
|
113
119
|
* ```
|
|
114
|
-
*
|
|
120
|
+
*
|
|
115
121
|
* @param requestOptions Options to pass through to the geoenrichment service.
|
|
116
122
|
* @returns A Promise that will resolve with available geography levels for the request.
|
|
117
123
|
*/
|
|
@@ -137,6 +143,8 @@
|
|
|
137
143
|
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
138
144
|
* Apache-2.0 */
|
|
139
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
|
+
*
|
|
140
148
|
* ```js
|
|
141
149
|
* import { getGeography } from '@esri/arcgis-rest-demographics';
|
|
142
150
|
* //
|
|
@@ -148,7 +156,7 @@
|
|
|
148
156
|
* response.; // => { results: [ ... ] }
|
|
149
157
|
* });
|
|
150
158
|
* ```
|
|
151
|
-
*
|
|
159
|
+
*
|
|
152
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.
|
|
153
161
|
* @returns A Promise that will resolve with return data defined and optionally geometry for the feature.
|
|
154
162
|
*/
|
|
@@ -191,6 +199,8 @@
|
|
|
191
199
|
/* Copyright (c) 2020 Environmental Systems Research Institute, Inc.
|
|
192
200
|
* Apache-2.0 */
|
|
193
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
|
+
*
|
|
194
204
|
* ```js
|
|
195
205
|
* import { queryDemographicData } from '@esri/arcgis-rest-demographics';
|
|
196
206
|
* //
|
|
@@ -202,7 +212,7 @@
|
|
|
202
212
|
* response; // => { results: [ ... ] }
|
|
203
213
|
* });
|
|
204
214
|
* ```
|
|
205
|
-
*
|
|
215
|
+
*
|
|
206
216
|
* @param requestOptions Options to pass through to the service.
|
|
207
217
|
* @returns A Promise that will resolve with results for the request.
|
|
208
218
|
*/
|
|
@@ -1 +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\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 * ```js\n * import { getAvailableCountries } from '@esri/arcgis-rest-demographics';\n * //\n * getAvailableCountries()\n * .then((response) => {\n * response; // => { countries: [ ... ] }\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 * @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 * ```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 * 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 * @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 * ```js\n * import { getAvailableGeographyLevels } from '@esri/arcgis-rest-demographics';\n * //\n * getAvailableGeographyLevels()\n * .then((response) => {\n * response; // => { geographyLevels: [ ... ] }\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 * @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 * ```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 * 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 * @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 * ```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 * 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 * @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;;EA0EA;;;;;;;;;;;;;WAagB,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;;EChHA;;EAuGA;;;;;;;;;;;;;;;;;;;;;WAqBgB,2BAA2B,CACzC,cAAoD;MAEpD,IAAI,OAAO,GAAwC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C,0BAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,QAAa;UAClE,OAAO,QAAQ,CAAC;OACjB,CAAC,CAAC;EACL;;ECvJA;;EAmDA;;;;;;;;;;;;;;;;WAgBgB,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;;;;;;;;;;;;;;"}
|
|
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,qCA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jB,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;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-demographics - v4.0.0-beta.
|
|
2
|
+
* @esri/arcgis-rest-demographics - v4.0.0-beta.5 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2022 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Tue May 10 2022 02:53:26 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
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
7
|
//# sourceMappingURL=demographics.umd.min.js.map
|