Select to view content in your preferred language

FeatureLayer geometry filtering

733
3
Jump to solution
02-14-2023 12:55 AM
JB19
by
Occasional Contributor

Hello everyone,

I'm working with Arcgis JS API 4.25.
I'm trying to filter a FeatureLayer based on this concept: 
Apply effects to features 

Since I'm using a SceneView, I can't use featureEffect.filter so i'm using filter directly on the featureLayerView, and it seems to work just fine.

The issue I have is with the buffer. The example works fine 

JB19_0-1676364225626.png

But when I try to replicate it, there is this strange gap between the visual of the geometry and the actual geometry used to filter the features:

gap.gif

I'm doing nothing more than the example do :

function updateFilter() {
  let featureFilter = null;
  if (filterGeometry) {
    let bufferGeometry = filterGeometry;
    if (distance > 0 && filterGeometry) {
      bufferGeometry = geometryEngine.buffer(filterGeometry, distance, unit);
      bufferLayer.graphics.getItemAt(0).geometry = bufferGeometry;
    } else {
      bufferLayer.graphics.getItemAt(0).geometry = null;
    }

    featureFilter = {
      geometry: bufferGeometry,
      spatialRelationship: spatialRel,
      distance,
      units: unit,
    };
  }
  if (featureLayerView) featureLayerView.filter = featureFilter;
}

Do you have any ideas what would be the problem ?
I'm guessing maybe something wrong about a wkid ?

 

 

0 Kudos
1 Solution

Accepted Solutions
JB19
by
Occasional Contributor

I found what was the issue. 
I was using this as a filter :

featureFilter = {
  geometry: bufferGeometry,
  spatialRelationship: spatialRel,
  distance,
  units: unit,
};

 

But the bufferGeometry was already at distance from the initial geometry (filterGeometry). 
So using a distance around the bufferGeometry was wrong. 
I should have used : 

featureFilter = {
   geometry: bufferGeometry,
};

 
Such a dumb mistake ...
Thanks for your time.

View solution in original post

0 Kudos
3 Replies
MichaelLev
Frequent Contributor

It's a guess. Please let me know if it helps:

Since it works, but not at the right area,

maybe it is worth to use - await geometryEngineAsync.geodesicBuffer

0 Kudos
ChristopheSuter
Regular Contributor

What is the spatialReference of your map/scene ? Did you try using geometryEngine.geodesicBuffer instead of geometryEngine.buffer ?

0 Kudos
JB19
by
Occasional Contributor

I found what was the issue. 
I was using this as a filter :

featureFilter = {
  geometry: bufferGeometry,
  spatialRelationship: spatialRel,
  distance,
  units: unit,
};

 

But the bufferGeometry was already at distance from the initial geometry (filterGeometry). 
So using a distance around the bufferGeometry was wrong. 
I should have used : 

featureFilter = {
   geometry: bufferGeometry,
};

 
Such a dumb mistake ...
Thanks for your time.

0 Kudos