query polygon with negative distance, error with geometry service buffer

846
5
05-18-2017 08:59 AM
StahlyEngineering
New Contributor III

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?

0 Kudos
5 Replies
XanderBakker
Esri Esteemed Contributor

Is line 6 correct? Should this not be a list with in this case a single element?

StahlyEngineering
New Contributor III

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.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Xander is correct that should be an array:

BP.geometries = [featureSet.features[0].geometry];
StahlyEngineering
New Contributor III

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

0 Kudos
StahlyEngineering
New Contributor III

Edit:

The output of buffer is itself an array of geometry. The correct geometry object is:

PBuffer[0]

0 Kudos