You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use RulerZ in a tracker system of the IoT.
I would alias an operator to an inlineOperator for a clearer view: :point ∈ :shape" instead of include(:point, :shape)
public function initRulerz()
{
$ƒinside = function ($geoLocation, $shapeCode) {
if (null === $geoLocation) {
return false;
}
return $this->geoFencing
->setShapeByCode($shapeCode)
->isInside(
$geoLocation['latitude'],
$geoLocation['longitude']
);
};
$ƒoutside = function ($geoLocation, $shapeCode) use ($ƒinside) {
return !$ƒinside($geoLocation, $shapeCode);
};
$visitor = new ArrayVisitor();
$visitor->setOperator('inside', $ƒinside);
$visitor->setOperator('outside', $ƒoutside);
// <-- insert
$compiler = new FileCompiler(new HoaParser());
$this->rulerz = new RulerZ($compiler, [ $visitor ]);
return $this;
}
There are two issues that prevent you from doing what you want.
The first is a misunderstanding of what "inline operators" are for RulerZ compilation targets.
For RulerZ, an operator is a callback that will be used at runtime to determine if a location is inside a shapeCode (for instance). On the other hand, an inline operator is a callback that is used at compile-time to generate code.
In your example, the ∈ and ∉ operators can NOT be defined as inline as their implementation rely on the $this->geoFencing attribute.
I guess that there is still plenty of room for improvements in the documentation.
If the thing that you really want to do is simplify the usage of your operator (ie: using :point ∈ :shape instead of ∈(:point, :shape), there isn't anything you can do at the moment. I don't think that grammar of the DSL will recognize it as a valid rule. This is something on which I'm willing to work though :)
If the thing that you really want to do is simplify the usage of your operator (ie: using :point ∈ :shape instead of ∈(:point, :shape), there isn't anything you can do at the moment. I don't think that grammar of the DSL will recognize it as a valid rule. This is something on which I'm willing to work though :)
I'm just wrong. It's already how built-in operators like =, >, … work. The grammar already supports this kind of simplification.
Hi,
I use RulerZ in a tracker system of the IoT.
I would alias an operator to an inlineOperator for a clearer view:
:point ∈ :shape"
instead ofinclude(:point, :shape)
I would like to write:
How is it possible?
The text was updated successfully, but these errors were encountered: