@esri/arcgis-rest-geocoding 3.4.2 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-geocoding - v3.
|
|
3
|
-
* Copyright (c) 2017-
|
|
4
|
-
*
|
|
2
|
+
* @esri/arcgis-rest-geocoding - v3.5.0 - Apache-2.0
|
|
3
|
+
* Copyright (c) 2017-2022 Esri, Inc.
|
|
4
|
+
* Thu Sep 22 2022 10:37:31 GMT-0600 (Mountain Daylight Time)
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
7
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/arcgis-rest-request')) :
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-geocoding - v3.
|
|
3
|
-
* Copyright (c) 2017-
|
|
4
|
-
*
|
|
2
|
+
* @esri/arcgis-rest-geocoding - v3.5.0 - Apache-2.0
|
|
3
|
+
* Copyright (c) 2017-2022 Esri, Inc.
|
|
4
|
+
* Thu Sep 22 2022 10:37:34 GMT-0600 (Mountain Daylight Time)
|
|
5
5
|
*/
|
|
6
6
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisRest=e.arcgisRest||{},e.arcgisRest)}(this,function(e,o){"use strict";var i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},a="https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/",t="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/";function g(e,t){for(var r=0;r<e.length-1;r++)for(var n=0;n<t.length-1;n++)if(function(e,t,r,n){var o=(n[0]-r[0])*(e[1]-r[1])-(n[1]-r[1])*(e[0]-r[0]),i=(t[0]-e[0])*(e[1]-r[1])-(t[1]-e[1])*(e[0]-r[0]),e=(n[1]-r[1])*(t[0]-e[0])-(n[0]-r[0])*(t[1]-e[1]);if(0!=e){o=o/e,e=i/e;if(0<=o&&o<=1&&0<=e&&e<=1)return!0}return!1}(e[r],e[r+1],t[n],t[n+1]))return!0;return!1}function s(e){for(var t,r,n=[],o=[],i=0;i<e.length;i++){var a=(function(e,t){for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}((a=e[i].slice(0))[0],a[a.length-1])||a.push(a[0]),a);a.length<4||(!function(e){for(var t,r=0,n=0,o=e.length,i=e[n];n<o-1;n++)r+=((t=e[n+1])[0]-i[0])*(t[1]+i[1]),i=t;return 0<=r}(a)?o.push(a.slice().reverse()):(a=[a.slice().reverse()],n.push(a)))}for(var s,u,c,p=[];o.length;){r=o.pop();for(var l=!1,f=n.length-1;0<=f;f--)if(t=n[f][0],c=void 0,c=g(s=t,u=r),u=function(e,t){for(var r=!1,n=-1,o=e.length,i=o-1;++n<o;i=n)(e[n][1]<=t[1]&&t[1]<e[i][1]||e[i][1]<=t[1]&&t[1]<e[n][1])&&t[0]<(e[i][0]-e[n][0])*(t[1]-e[n][1])/(e[i][1]-e[n][1])+e[n][0]&&(r=!r);return r}(s,u[0]),!(c||!u)){n[f].push(r),l=!0;break}l||p.push(r)}for(;p.length;){r=p.pop();var d=!1;for(f=n.length-1;0<=f;f--)if(t=n[f][0],g(t,r)){n[f].push(r),d=!0;break}d||n.push([r.reverse()])}return 1===n.length?{type:"Polygon",coordinates:n[0]}:{type:"MultiPolygon",coordinates:n}}function u(e,t){var r={};if(e.features){r.type="FeatureCollection",r.features=[];for(var n=0;n<e.features.length;n++)r.features.push(u(e.features[n],t))}if("number"==typeof e.x&&"number"==typeof e.y&&(r.type="Point",r.coordinates=[e.x,e.y],"number"==typeof e.z&&r.coordinates.push(e.z)),e.points&&(r.type="MultiPoint",r.coordinates=e.points.slice(0)),e.paths&&(1===e.paths.length?(r.type="LineString",r.coordinates=e.paths[0].slice(0)):(r.type="MultiLineString",r.coordinates=e.paths.slice(0))),e.rings&&(r=s(e.rings.slice(0))),"number"==typeof e.xmin&&"number"==typeof e.ymin&&"number"==typeof e.xmax&&"number"==typeof e.ymax&&(r.type="Polygon",r.coordinates=[[[e.xmax,e.ymax],[e.xmin,e.ymax],[e.xmin,e.ymin],[e.xmax,e.ymin],[e.xmax,e.ymax]]]),(e.geometry||e.attributes)&&(r.type="Feature",r.geometry=e.geometry?u(e.geometry):null,r.properties=e.attributes?function(e){var t,r={};for(t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}(e.attributes):null,e.attributes))try{r.id=function(e,t){for(var r=t?[t,"OBJECTID","FID"]:["OBJECTID","FID"],n=0;n<r.length;n++){var o=r[n];if(o in e&&("string"==typeof e[o]||"number"==typeof e[o]))return e[o]}throw Error("No valid id attribute found")}(e.attributes,t)}catch(e){}return JSON.stringify(r.geometry)===JSON.stringify({})&&(r.geometry=null),e.spatialReference&&e.spatialReference.wkid&&4326!==e.spatialReference.wkid&&console.warn("Object converted in non-standard crs - "+JSON.stringify(e.spatialReference)),r}e.ARCGIS_ONLINE_BULK_GEOCODING_URL=t,e.ARCGIS_ONLINE_GEOCODING_URL=a,e.bulkGeocode=function(e){var r=i({endpoint:t,params:{}},e);return r.params.addresses={records:e.addresses.map(function(e){return{attributes:e}})},e.authentication||r.endpoint!==t?o.request(o.cleanUrl(r.endpoint)+"/geocodeAddresses",r).then(function(e){if(r.rawResponse)return e;var t=e.spatialReference;return e.locations.forEach(function(e){e.location&&(e.location.spatialReference=t)}),e}):Promise.reject("bulk geocoding using the ArcGIS service requires authentication")},e.geocode=function(n){var e,t={};return"string"==typeof n?(t.params={singleLine:n},e=a):(e=n.endpoint||a,t=o.appendCustomParams(n,["singleLine","address","address2","address3","neighborhood","city","subregion","region","postal","postalExt","countryCode","outFields","magicKey"],{params:i({},n.params)})),o.request(o.cleanUrl(e)+"/findAddressCandidates",t).then(function(e){if("string"!=typeof n&&n.rawResponse)return e;var t,r=e.spatialReference;return e.candidates.forEach(function(e){e.location.spatialReference=r,e.extent&&(e.extent.spatialReference=r)}),4326===r.wkid&&(t=e.candidates.map(function(e){return{type:"Feature",geometry:u(e.location),properties:Object.assign({address:e.address,score:e.score},e.attributes)}}),e.geoJson={type:"FeatureCollection",features:t}),e})},e.getGeocodeService=function(e){var t=e&&e.endpoint||a,e=i({httpMethod:"GET",maxUrlLength:2e3},e);return o.request(t,e)}
|
|
7
7
|
/* @preserve
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/arcgis-rest-geocoding",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Geocoding helpers for @esri/arcgis-rest-js",
|
|
5
5
|
"main": "dist/node/index.js",
|
|
6
6
|
"unpkg": "dist/umd/geocoding.umd.js",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"dist/**"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@esri/arcgis-rest-types": "^3.
|
|
16
|
+
"@esri/arcgis-rest-types": "^3.5.0",
|
|
17
17
|
"@terraformer/arcgis": "^2.0.7",
|
|
18
18
|
"@types/terraformer__arcgis": "^2.0.0",
|
|
19
19
|
"tslib": "^1.13.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@esri/arcgis-rest-auth": "^3.
|
|
23
|
-
"@esri/arcgis-rest-request": "^3.
|
|
22
|
+
"@esri/arcgis-rest-auth": "^3.5.0",
|
|
23
|
+
"@esri/arcgis-rest-request": "^3.5.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@esri/arcgis-rest-auth": "^3.0.0",
|