Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the shape of a Geofence

The new Location API in Google allows for creating and monitoring a Geofence that's a circular region with the Geofence.Builder class. This class only has methods defined for creating a geofence with a circular shape. I was wondering if it was possible to extend the Geofence.Builder class and create a custom shape. What I wanted to do was have a triangular shape defined instead of a circular one.

If that's not possible does the Geofence class provide for a way to monitor only a certain segment of the circle?

Update: What I want to do is extend a triangle from the users position with one of the vertices being the users location. I want the height of the triangle to be 50 meters and the base of the triangle to be 10 meters. What I want to do afterwards is to detect whenever another user enters this triangle extended from the current users position.

like image 800
Vishal Disawar Avatar asked Nov 03 '22 17:11

Vishal Disawar


1 Answers

Good question. Alas, you probably won't be pleased with the answer.

Location Services doesn't support non-circular geofences, nor can you monitor only a segment of the circle. Since Geofence.Builder doesn't have a method for creating a non-circular Geofence, there's no way to provide your own extension.

If you post a description of your use case, perhaps someone can figure out an answer.

like image 86
Joe Malin Avatar answered Nov 08 '22 16:11

Joe Malin