@wsdot/arcgis-buffer-ui
Advanced tools
Comparing version 1.1.1-2.0.0-beta.1.0 to 2.0.0-beta.2
@@ -62,3 +62,3 @@ /** | ||
*/ | ||
getDistances(): number | number[] | null; | ||
readonly distances: number | number[] | null; | ||
/** | ||
@@ -72,4 +72,12 @@ * Adds a feature to the UI's list. | ||
*/ | ||
getGeometries(): Geometry | Geometry[] | null; | ||
readonly geometries: Geometry | Geometry[] | null; | ||
/** | ||
* Returns an integer representing a measurement unit. | ||
*/ | ||
readonly unit: number; | ||
/** | ||
* Returns a boolean value indicating if the union checkbox is currently checked. | ||
*/ | ||
readonly unionResults: boolean; | ||
/** | ||
* Clears the list of geometries in the UI. | ||
@@ -76,0 +84,0 @@ */ |
@@ -40,2 +40,20 @@ "use strict"; | ||
/** | ||
* If given a graphic object, returns its geometry property. | ||
* If given a geometry object, simply returns the input object. | ||
* @param featureOrGeometry A graphic or geometry object. | ||
* @throws {TypeError} Thrown if the input object is neither a geometry nor contains a geometry. | ||
*/ | ||
function getGeometry(featureOrGeometry) { | ||
if (featureOrGeometry.geometry) { | ||
return featureOrGeometry.geometry; | ||
} | ||
else if (featureOrGeometry.hasOwnProperty("x") || | ||
featureOrGeometry.hasOwnProperty("points") || | ||
featureOrGeometry.hasOwnProperty("rings") || | ||
featureOrGeometry.hasOwnProperty("paths")) { | ||
return featureOrGeometry; | ||
} | ||
throw new TypeError("Input must be a Graphic or Geometry"); | ||
} | ||
/** | ||
* UI for the Buffer operation on an ArcGIS Server Geometry service. | ||
@@ -56,10 +74,10 @@ * @class | ||
form.onsubmit = function () { | ||
var geometries = self.getGeometries(); | ||
var geometries = { self: self }; | ||
if (geometries) { | ||
var evt = new CustomEvent("buffer", { | ||
detail: { | ||
geometry: self.getGeometries(), | ||
distance: self.getDistances(), | ||
unit: parseInt(self.form.unit.value, 10), | ||
unionResults: Boolean(self.form.querySelector("[name=union]:checked")) | ||
geometry: self.geometries, | ||
distance: self.distances, | ||
unit: self.unit, | ||
unionResults: self.unionResults | ||
} | ||
@@ -83,19 +101,23 @@ }); | ||
} | ||
Object.defineProperty(BufferUI.prototype, "distances", { | ||
/** | ||
* Gets the distances entered in the distances box. | ||
*/ | ||
get: function () { | ||
var distances = null; | ||
var s = this.form.distances.value; | ||
if (s) { | ||
distances = s.split(/[,\s]+/).map(function (st) { | ||
return parseFloat(st); | ||
}); | ||
} | ||
if (distances && distances.length === 1) { | ||
return distances[0]; | ||
} | ||
return distances; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* Gets the distances entered in the distances box. | ||
*/ | ||
BufferUI.prototype.getDistances = function () { | ||
var distances = null; | ||
var s = this.form.distances.value; | ||
if (s) { | ||
distances = s.split(/[,\s]+/).map(function (st) { | ||
return parseFloat(st); | ||
}); | ||
} | ||
if (distances && distances.length === 1) { | ||
return distances[0]; | ||
} | ||
return distances; | ||
}; | ||
/** | ||
* Adds a feature to the UI's list. | ||
@@ -107,14 +129,2 @@ * @param feature A feature | ||
var li = document.createElement("li"); | ||
function getGeometry(featureOrGeometry) { | ||
if (featureOrGeometry.geometry) { | ||
return featureOrGeometry.geometry; | ||
} | ||
else if (featureOrGeometry.hasOwnProperty("x") || | ||
featureOrGeometry.hasOwnProperty("points") || | ||
featureOrGeometry.hasOwnProperty("rings") || | ||
featureOrGeometry.hasOwnProperty("paths")) { | ||
return featureOrGeometry; | ||
} | ||
throw new TypeError("Input must be a Graphic or Geometry"); | ||
} | ||
var geometry = getGeometry(feature); | ||
@@ -129,32 +139,56 @@ if (geometry.toJson) { | ||
}; | ||
/** | ||
* Gets all of the geometries stored in the list items' data-geometry attributes | ||
*/ | ||
BufferUI.prototype.getGeometries = function () { | ||
var geometries = new Array(); | ||
var listItems = this.root.querySelectorAll(".geometry-list > li"); | ||
try { | ||
for (var _a = __values(listItems.values()), _b = _a.next(); !_b.done; _b = _a.next()) { | ||
var li = _b.value; | ||
var gJson = li.dataset.geometry; | ||
var g = JSON.parse(gJson); | ||
geometries.push(g); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
Object.defineProperty(BufferUI.prototype, "geometries", { | ||
/** | ||
* Gets all of the geometries stored in the list items' data-geometry attributes | ||
*/ | ||
get: function () { | ||
var geometries = new Array(); | ||
var listItems = this.root.querySelectorAll(".geometry-list > li"); | ||
try { | ||
if (_b && !_b.done && (_c = _a.return)) _c.call(_a); | ||
for (var _a = __values(listItems.values()), _b = _a.next(); !_b.done; _b = _a.next()) { | ||
var li = _b.value; | ||
var gJson = li.dataset.geometry; | ||
var g = JSON.parse(gJson); | ||
geometries.push(g); | ||
} | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
if (geometries.length < 1) { | ||
return null; | ||
} | ||
else if (geometries.length === 1) { | ||
return geometries[0]; | ||
} | ||
return geometries; | ||
var e_1, _c; | ||
}; | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_b && !_b.done && (_c = _a.return)) _c.call(_a); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
if (geometries.length < 1) { | ||
return null; | ||
} | ||
else if (geometries.length === 1) { | ||
return geometries[0]; | ||
} | ||
return geometries; | ||
var e_1, _c; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(BufferUI.prototype, "unit", { | ||
/** | ||
* Returns an integer representing a measurement unit. | ||
*/ | ||
get: function () { | ||
return parseInt(this.form.unit.value, 10); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(BufferUI.prototype, "unionResults", { | ||
/** | ||
* Returns a boolean value indicating if the union checkbox is currently checked. | ||
*/ | ||
get: function () { | ||
return Boolean(this.form.querySelector("[name=union]:checked")); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
@@ -161,0 +195,0 @@ * Clears the list of geometries in the UI. |
{ | ||
"name": "@wsdot/arcgis-buffer-ui", | ||
"version": "1.1.1-2.0.0-beta.1.0", | ||
"version": "2.0.0-beta.2", | ||
"description": "Buffer UI for ArcGIS API for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25712
573
0