I think it depends a lot on perspective and usage to tell when the functions are equal, and that is why the user needs to define equality. Some may say that functions are equal if they share the (exact) same geometry (1) . Others may say that functions must have the same properties (2) or even both (3) .
To test the equality property , I would recommend defining attributes that are relevant to your definition of equality. Then you can use code like this to check if 2 ol.Featureobjects are equal :
var mySelectedProperties = ["importantProperty", "anotherImportantProperty", "propertyX"];
function areEqual(featureA, featureB){
var equal = true;
for(let property of mySelectedProperties){
if(featureA.get(property) != featureB.get(property)){
equal = false;
return equal ;
}
}
return equal;
}
For equality of geometry, you can check if the coordinates (x and y) coincide. Here are some more considerations:
: lineA: pointA-pointB lineB: pointB-pointA
: polygonA: pointA-pointB-pointC-pointA polygonB: pointB-pointC-pointA-pointB