Geofence Creation API

jaimzj7 years ago

Dear All,

If I want to create a geo-fence using traccar API.

What is the format to be used for the area ?

Anton Tananaev7 years ago
jaimzj7 years ago

Thank You Anton, can this also be published on the site? API-Reference guide? the new one thats up?

Anton Tananaev7 years ago

It's generated from the swagger file. Feel free to send a pull request for it.

brenthmiras7 years ago

Area uses wkt, but it is said that a circle with radius is not supported by wkt. How do we draw a circle in the map?

brenthmiras7 years ago
Anton Tananaev7 years ago

For circle we use some non-standard, but commonly used WKT format:

https://github.com/tananaev/traccar/blob/master/test/org/traccar/geofence/GeofenceCircleTest.java

abyss7 years ago

Also, want to note that polygons with hole not supported, just simple polygon https://github.com/tananaev/traccar/blob/master/test/org/traccar/geofence/GeofencePolygonTest.java

ginppian7 years ago

Documentation:

Geofence: object
id: integer
name: string
description: string
area: string
calendarId: integer
attributes: object

Area? is my adress ?

Anton Tananaev7 years ago

Have you actually tried reading this thread before posting your question?

ginppian7 years ago

In this case:

    public void testContainsCircle() throws ParseException {
        String test = "CIRCLE (55.75414 37.6204, 100)";
        GeofenceGeometry geofenceGeometry = new GeofenceCircle();
        geofenceGeometry.fromWkt(test);
        Assert.assertTrue(geofenceGeometry.containsPoint(55.75477, 37.62025));
        Assert.assertTrue(!geofenceGeometry.containsPoint(55.75545, 37.61921));
    }

containsPoint Refers to latitude and longitude ?

and

CIRCLE (55.75414 37.6204, 100) Refers to circle view?

Anton Tananaev7 years ago

Circle is a circle obviously. containsPoint is a Java method.

ginppian7 years ago

Bro you are so pro, but we need an example. My thesis is about "location" and i love your job, if you could be more flexible.

Anton Tananaev7 years ago

Example of circle area:

CIRCLE (55.75414 37.6204, 100)

Example of polygon area:

POLYGON ((66.9494 179.838, 66.9508 -179.8496, 66.8406 -180.0014))
ginppian7 years ago

Thanks, now when i try to link a Geofence with a Device i can't send my array geofenceIds integer[], how can i make my body for make my insercion ?

https://github.com/ginppian/borrar/blob/master/Screenshot_2.png