claeis / ilivalidator

INTERLIS validator
14 stars 21 forks source link

areAreas-Function call with THIS returns wrong result #338

Closed patrickackermann closed 2 years ago

patrickackermann commented 2 years ago

Using the areAreas, areAreas2 or areAreas3 function with an object(s) argument of THIS may lead to wrong results. The result of the evaluation of the first object gets cached and is reused for all other objects.

The attached example has two instances of a class, one with geometry, that satisfies the mandatory constraint with areAreas2 and one that does not. The expected validation result would be one mandatory constraint violation error for the incorrect instance.

MANDATORY CONSTRAINT INTERLIS_ext.areAreas2(THIS, UNDEFINED, "geom_attr->geom");

If the correct instance is checked first the error with the second instance is not detected.

Info: validate mandatory constraint Test_Model.Topic.Class_A.Constraint1...
...
Info: ...validation done

If the faulty instance is checked first, a second superfluous error is logged for the correct instance:

Info: validate mandatory constraint Test_Model.Topic.Class_A.Constraint1...
Error: Test_Model.Topic.Class_A: tid 0/geom_attr[1]/geom[1]: Intersection coord1 (600000.000, 75000.000), tids 0/geom_attr[1]/geom[1], 0/geom_attr[2]/geom[1]
Error: Test_Model.Topic.Class_A: tid 0/geom_attr[1]/geom[1]: Intersection coord1 (550000.000, 80000.000), tids 0/geom_attr[1]/geom[1], 0/geom_attr[2]/geom[1]
Error: Mandatory Constraint Test_Model.Topic.Class_A.Constraint1 is not true.
Error: line 74: Test_Model.Topic.Class_A: tid 1: Mandatory Constraint Test_Model.Topic.Class_A.Constraint1 is not true.

areAreas_constraint_this_broken_caching_ili2_3.zip

claeis commented 2 years ago

m.E. korrigiert in 1.11.14

patrickackermann commented 2 years ago

Ja mit dem Entfernen des areAreas caching (https://github.com/claeis/iox-ili/commit/2185b4be1c4a918b6a71436ca286c59948d03b5d) funktioniert es wie erwartet.