Hello all,
In a widget routine I want to perform a spatial query (intersect) with a negative distance buffer: create an effective search geometry that is smaller than the selected input.
Currently I am attempting to create a buffer using a geometry service with a negative distance:
var BP = new BufferParameters();
var gsvc = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
BP.bufferSpatialReference = featureSet.features[0].spatialReference;
BP.unit = GeometryService.UNIT_METER;
BP.distances = -5;
BP.geometries = featureSet.features[0].geometry;
gsvc.buffer(BP,function(PBuffer){
//Define a Query: get all features from the target feature layer that intersect the geometry of the input featureset.feature[0]
Q = new Query();
//Q.geometry = featureSet.features[0].geometry;
Q.geometry = PBuffer.geometry;
Q.outFields = [ "*" ];
Q.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
Q.returnGeometry = true;
//Q.distance = -5;
//Q.units = "meters";
In the browser console this throws the following error (line 39 is line 7 above):
TypeError: a.join is not a function
at Object.toJson (BufferParameters.js:5)
at Object.buffer (init.js:2274)
at SelectParcelsAction.js?wab_dv=2.3:39
I've previously attempted to simply define a query distance, commented out in the code block, but that did not appear to have an affect.
What am I doing wrong and how to best achieve what I'm trying to do?
Is line 6 correct? Should this not be a list with in this case a single element?
I copied that from line 10, where that worked correctly
As I understand the widget function passes a featureset with contains an array of features of length 1.
Xander is correct that should be an array:
BP.geometries = [featureSet.features[0].geometry];
I've changed the buffer parameters to lists as needed (geometry and distance).
It appears that the buffer does not return a valid geometry. In:
gsvc.buffer(BP,function(PBuffer){
-code-
});
PBuffer appears to be undefined. There are no errors reported relating to the buffer
Edit:
The output of buffer is itself an array of geometry. The correct geometry object is:
PBuffer[0]