Select to view content in your preferred language

Query to get all features from route geometry

735
0
03-10-2021 08:47 AM
AndyWhitaker1
Occasional Contributor

I am trying to choose the correct spatial relationship for getting all of the features that lie at least partially within a given polyline geometry. 

I've referenced this ESRI documentation on spatial relationships, but I am still confused how to achieve what I need: https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialR...

I would like to query the Feature Layer and get back the 3 polyline segments which make up the route seen below (the blue highlighted line). The route is created from the Directions widget:

Route w/ 3 segments (features)Route w/ 3 segments (features)

#1 and #2 are full segments.  #3 is a partial segment; that is, only part of the feature is contained in the route. 

  • When I use the spatial relationship "Contains", the query returns 2 features.  These are the two that are wholly contained in the route geometry.  So, it doesn't pick up segment #3.  UPDATE: I had to add returnGeometry=false to the query so it would return results when using Contains.
  • Using "Intersects" returns all 3 features, but it also picks up the route segments which intersect the route, which are unwanted.  This means, it returns features on adjacent routes.  I'm only after the features which are part of the route.

Here's my query:

 

const query = new Query();
query.geometry = routeGeometry; // this is the route geometry
query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
query.outFields = ["*"];
query.distance = 10;
query.units = "feet";
query.returnGeometry = false;

 

What spatial relationship do I use to get all segments that are part of the route geometry?  This includes both full and partial segments.  Perhaps this could be accomplished in multiple queries?  One "Contains" query and another ____ query?

Thank you.

0 Kudos
0 Replies