Checking if an area contains a location

Detect if an area contains or does not contain a location.

Use the following operators to check if some geometries contain or are contained in other geometries:
  • <a geometry> contains <a geometry>
  • all <geometries> contained in <a geometry>
  • all <geometries> containing <a geometry>

In the following examples, the parking area is defined as a polygon in the business model.

The following rule sends an alert if the car is parked outside its assigned parking lot.

when a car returned event occurs
definitions
    set 'assigned parking area' to the parking area of the parking lot of this car returned event;
if
    it is not true that 'assigned parking area' contains the location of this car returned event
then
    print "The car is parked outside the assigned parking lot.";

The following rule warns the employee that too many cars are parked in a parking lot.

when a car returned event occurs
definitions
    set 'parking lot area' to the parking area of the parking lot of this car returned event;
    set 'cars in parking lot' to all cars in the cars of 'the organization'
        where 'parking lot area' contains the location of each car;
if
    the number of elements in 'cars in parking lot' is more than the available places of the parking lot
then
    print "Too many cars are parked in " + the name of the parking lot of this car returned event;