Skip to content

Commit

Permalink
Add geometry attribute parameter to IsInside
Browse files Browse the repository at this point in the history
  • Loading branch information
domi-b committed Jan 18, 2024
1 parent f359fd0 commit 035d14f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ public String getQualifiedIliName() {

@Override
protected Value evaluateInternal(String validationKind, String usageScope, IomObject mainObj, Value[] arguments) {
Value argReferenceGeometry = arguments[0]; // MULTIAREA
Value argTestObject = arguments[1]; // OBJECT OF ANYCLASS
Value argTestObjectgeometry = arguments[2]; // TEXT
Value argReferenceObject = arguments[0]; // ANYSTRUCTURE
Value argReferenceGeometryPath = arguments[1]; // TEXT
Value argTestObject = arguments[2]; // OBJECT OF ANYCLASS
Value argTestObjectgeometry = arguments[3]; // TEXT

if (argTestObject.isUndefined() || argTestObjectgeometry.isUndefined()) {
return Value.createSkipEvaluation();
}
if (argReferenceGeometry.isUndefined()) {
if (argReferenceObject.isUndefined()) {
writeLogErrorMessage(usageScope, "Missing reference geometry.");
return Value.createUndefined();
}

Collection<IomObject> referenceGeometryObjects = argReferenceGeometry.getComplexObjects();
Collection<IomObject> referenceGeometryObjects = EvaluationHelper.evaluateObjectPath(td, validator, argReferenceObject, argReferenceGeometryPath, mainObj, usageScope);
if (referenceGeometryObjects.size() != 1) {
writeLogErrorMessage(usageScope, "Expected exactly one reference geometry.");
return Value.createUndefined();
Expand Down
4 changes: 2 additions & 2 deletions src/model/GeoW_FunctionsExt.ili
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ MODEL GeoW_FunctionsExt
FUNCTION IsInsideExternalDatasetResource (TransferFile: TEXT; DatasetName: TEXT; Objects: TEXT; TestObject: OBJECT OF ANYCLASS; TestObjectgeometry: TEXT): BOOLEAN;

!!@ fn.description = "Prüft, ob ein Objekt innerhalb der Geometrie eines anderen Objektes liegt.";
!!@ fn.param = "ReferenceGeometry: Referenzgeometrie, innerhalb welcher das TestObject liegen muss. TestObject: Objekt, welches zu prüfen ist. TestObjectgeometry: Geometriefeld, bezogen auf das unter Testobject übergebene Objekt";
!!@ fn.param = "ReferenceObject: Referenzobjekt oder -geometrie, innerhalb welcher das TestObject liegen muss. ReferenceGeometryAttr: Pfad zum Geometrieattribut vom Referenzobjekt oder UNDEFINED. TestObject: Objekt, welches zu prüfen ist. TestObjectgeometry: Geometriefeld, bezogen auf das unter Testobject übergebene Objekt";
!!@ fn.return = "Boolean";
!!@ fn.since = "2023-12-21";
FUNCTION IsInside (ReferenceGeometry: MULTIAREA; TestObject: OBJECT OF ANYCLASS; TestObjectgeometry: TEXT): BOOLEAN;
FUNCTION IsInside (ReferenceObject: ANYSTRUCTURE; ReferenceGeometryAttr: TEXT; TestObject: OBJECT OF ANYCLASS; TestObjectgeometry: TEXT): BOOLEAN;

!!@ fn.description = "Fasst die Flächen-Geometrien aus der Eingabemenge zu einer Flächen-Geometrie zusammen. Für 'Objects' können Objekte oder Geometrien angegeben werden. Für 'GeometryAttr' soll der Pfad zur Flächen-Geometrie in INTERLIS 2 Syntax angegeben werden. Falls 'Objects' bereits die Geometrien enthält, soll für 'GeometryAttr' 'UNDEFINED' übergeben werden.";
!!@ fn.param = "Objects: Objekte, deren Geometrien zusammengefasst werden sollen. GeometryAttr: Pfad zum Geometrieattribut oder UNDEFINED";
Expand Down
5 changes: 3 additions & 2 deletions src/test/data/IsInside/MandatoryConstraintThis.ili
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ MODEL TestSuite
CLASS IsInsideKantonsgrenze EXTENDS ConstraintTestClass =
testAttributeIsInsideKantonsgrenze : CHKoord;
testAttributeKantonsgrenze : CHMultiArea;
MANDATORY CONSTRAINT IsInsideKantonsgrenze: GeoW_FunctionsExt.IsInside(THIS->testAttributeKantonsgrenze, THIS, "testAttributeIsInsideKantonsgrenze") == expected;
MANDATORY CONSTRAINT IsInsideKantonsgrenzePath: GeoW_FunctionsExt.IsInside(THIS, "testAttributeKantonsgrenze", THIS, "testAttributeIsInsideKantonsgrenze") == expected;
MANDATORY CONSTRAINT IsInsideKantonsgrenzeUndefinedPath: GeoW_FunctionsExt.IsInside(THIS->testAttributeKantonsgrenze, UNDEFINED, THIS->testAttributeIsInsideKantonsgrenze, UNDEFINED) == expected;
END IsInsideKantonsgrenze;

CLASS InvalidConstraints =
geometryAttribute : CHKoord;
area : CHMultiArea;
MANDATORY CONSTRAINT IsInsideMissingArea: GeoW_FunctionsExt.IsInside(THIS->area, THIS, "geometryAttribute");
MANDATORY CONSTRAINT IsInsideMissingArea: GeoW_FunctionsExt.IsInside(THIS->area, UNDEFINED, THIS, "geometryAttribute");
END InvalidConstraints;

END FunctionTestTopic;
Expand Down

0 comments on commit 035d14f

Please sign in to comment.