B4J Question Geofence

jose luis gudino

Active Member
Licensed User
Longtime User
Hi everyone, Merry Christmas!.

how can I perform a function that allows me to know if I am within that geofence of circular termination.
Thanks for your advance.

geofence.PNG
 

Harris

Expert
Licensed User
Longtime User

Read that post for examples...
 
Upvote 0

jose luis gudino

Active Member
Licensed User
Longtime User
Hi
Thanks for answering,
I had looked at that tutorial.
the problem is that this example is calculated with 4 points (polygon)
I need to circulate
Anyway I will see if I get an idea from there
Thanks a lot
 
Upvote 0

samperizal

Active Member
Licensed User
Longtime User
Regards

If what you want is to know if a point is inside a circle, you can use

The cosine law is: d = acos (sin (φ1) ⋅sin (φ2) + cos (φ1) ⋅cos (φ2) ⋅cos (Δλ)) ⋅ R
where: φ = latitude, λ = longitude (in radians)
R = radius of earth
d = distance between the points (in same units as R)


Example
To search by kilometers instead of miles, replace 3959 with 6371.

centro del circulo ( clat ,clng)
radio_circulo = distamcia de;radio del circulo


distancia =(3959 * acos ( cos ( radians(clat) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(clng) )
+ sin ( radians(clat) )
* sin( radians( lat ) )
) )

if distacia <= radio_circulo then
'inside the circle
else
'outside the circle
endif

luck
 
Upvote 0

jose luis gudino

Active Member
Licensed User
Longtime User
Thank you for the answer helped me a lot.
Now, I need to know if the blue mark that I show in the image is inside the geofence
Thanks for your advance.

geofence1.PNG
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Are you showing 3 zones in the image (two circles and a box)?
Seems like the long zone is a rectangle - where you can use pointinpolygon...
At the bottom of the image, it seems another rectangular zone is shown. This overlaps with other where one will have difficulty determining which zone you are actually in.
One way to avoid this issue is to use layers. However, the function to determine where the point (marker) is actually at will require processing each layer(s).
 
Upvote 0

jose luis gudino

Active Member
Licensed User
Longtime User
In this case there are two circles.

Basically, it is a "geocorridor" which is constructed with circles of equal diameter for all, arranged along the length of a track at different points.

therefore I have the latitude and longitude of each point and the diameter of the circle.
 
Upvote 0
Top