Select to view content in your preferred language

Arcade - How to use Overlaps() function?

437
0
07-12-2023 02:43 AM
Woodpeckerus
New Contributor III

I have an app where the user is digitising the lines and want to display a message when the line they are digitising (at least partially) overlaps with the existing lines. 

I have to display a message when the feature the user is digitising intersects with other features as well - and the Intesects() script works ok. The intersects script looks something like this: 

 

// Define a feature service I want to test the edits agains
var layer = FeatureLayer("https://xxxxxxx")

// Use intersects() which will return featureSet as I am using a FeatureSet as an input geometry
var intersectsLayer = Intersects($drawingShape, layer)

// Check if intersects returned an empty featureSet or not
var intersectionTestLayer = IsEmpty(First(intersectsLayer))

// If featureSet is not empty, it means the features are intersecting, so the message has to be dispayed
if(intersectionTestLayer == false)
  console("Show message")

 

 

The above work exactly how I want it to. As the syntax for Overlaps() is pretty much the same as with Intersects() I thought I would simply just replace the function and get the desired result. Like below: 

 

// Define a feature service I want to test the edits agains
var layer = FeatureLayer("https://xxxxxxx")

// Use Overlaps() which will return featureSet as I am using a FeatureSet as an input geometry
var overlapsLayer = Overlaps($drawingShape, layer)

// Check if overlaps returned an empty featureSet or not
var overlapsTestLayer = IsEmpty(First(overlapsLayer))

// If featureSet is not empty, it means the features are overlapping, so the message has to be dispayed
if(overlapsTestLayer == false)
  console("Show message")

 

The issue with this script is that overlapsTestLayer is always empty - meaning it doesn't recognise the overlaps when digitising. 

And yes, the features are overlaping as I am using the snapping tool to make sure the lines are exactly on top of one another. 

Any idea what I'm doing wrong?

Tags (2)
0 Kudos
0 Replies