In support of Blocking invalid (self-intersecting) polygons in Collect, we propose adding the following function to the spec:
The intersects function takes in a geotrace or geoshape and returns true if the geometry self-intersects (any line between two vertices in the shape crosses another one), false otherwise. If the parameter type is not geotrace, geoshape, or a string with that formatting, an error is thrown.
An example constraint for a geoshape question that must not have self-intersections would be:
not(intersects(.))
This leaves open the possibility of eventually extending the function to take in multiple trace/shape parameters and computing whether there are intersections between any of them.
The only related prior art we found was the EXPath geo package which defined a very similar intersects function. This function fits in well with other geo functions in the ODK XPath spec: area, distance, geofence.
Please let us know if you have any questions or comments!