I’d like to have a grid of “square” zones for my home area. Just like the old school maps, where you have A1-N26 or some such. Is this possible? If not, how about a grid of overlapping circles? I’d like to be able to track users across the map and have automations based upon which grids they trigger.

# Is there a way of creating a grid of zones based upon a map area?

Zones can only be defined by a centre location and radius. So you would have to use a grid of circles with either overlap or gaps.

Is there a reason why zones are circles, other than it just being easier to implement? I’m assuming the circle implementation takes a x,y point and runs that through each zone to see if it falls within the area of the circle defined by the zone and returns true or false. Is this correct?

I was thinking about this for a while and my Swokowski Calculus came back to me and if the above is true it should be simple to use an integral to see if the x,y point falls under the area of a curve defined by a definite integral, which would allow you to create zones of *any* shape by adding the definite integral tests together.

But if *that’s* possible, then you could define a square zone by a *single* point x1, and x2 = 2x1, y1=x, y2=2y1 and then check to see if x,y is within the borders.

It’s an interesting problem. For now I’ll see if I can write a function to create a zone file with overlapping circles or circles with gaps and use a smaller circle to fill the gaps and keep track of which circle was “last entered”.

I’m guessing yes, ease of implementation. Rather than having to perform a complex operation to determine if you are within a bounding box all you have to do is measure your location’s (x2, y2) distance from the centre (x1, y1), an easy calculation , sqrt( (x1-x2)^2 + (y1-y2)^2 ) and see if it is smaller than the zone radius.

I looked up a method for determining if a point was in a box. While it still relies on plain (plane) geometry it is far more complicated.

Acceptably this approach needs substantial amount of computation. This approach can be employed to any irregular polygon, too.

Yes, the irregular polygon algorithms simply use the rectangle function for a shape composed of many rectangles. But it also has to use a function for triangles as well. While the resources required for the computations are higher than circles, it’s not *that* much higher that it burdens a modern CPU. IIRC in my CS course we developed the algorithms that had little problem running on an 8088 processor.

Of for sure. It’s the lack of developer resources that cause the simple solution.

You may find useful the Geofences, in node-red, where you can specify areas like retangles.