1

How to obtain the number of units in a geofence

Topic: How to obtain the number of units in a geofence

Hello,

I am trying to obtain the number of units in each geofence, I have tried with this code github.com/ashmigelski/units-inside however when calculating the units in the geofence with the position of the unit it generates a type 5 error.

I am doing it with the javascript api, I would really appreciate if you can help me.

2

How to obtain the number of units in a geofence

Re: How to obtain the number of units in a geofence

nmdl hello, the code example from GitHub uses old authorization method.
Login request with username and password was deprecated, so the following function will not work:

wialon.core.Session.getInstance().login(uname, pass, "", loginCallback);

The login request should be performed with token only and following request:

wialon.core.Session.getInstance().loginToken(token, loginCallBack)

The error 5 usually means - Error performing request
So the issue might be related to the network connection.

If the issue persists, please, send your request with the detailed task description to support@wialon.com

Anton Zinovyev
Technical Care Engineer (L2)
Wialon
3

How to obtain the number of units in a geofence

(edited by nmdl 04/09/2024 16:38:06)

Re: How to obtain the number of units in a geofence

Hello zant,

Thanks for the response, I was managing the login with the new method, however it always gave me error 5, I discovered that in order to obtain the number of units in each geofence I must make a call to the wialon.util.Helper method. getZonesInPoint for each unit passing all geofences, here is the code

if (pos && pos.x && pos.y) {
        wialon.util.Helper.getZonesInPoint(
          {
            zoneId: zoneId,
            lat: pos.y,
            lon: pos.x
          },
          function (code, data) {}
        )

The zoneId is a json with all resources. But this method is very heavy and slow, I would like to know if there is any way to make it more agile and faster.

4

How to obtain the number of units in a geofence

Re: How to obtain the number of units in a geofence

nmdl hello,if you don't need online data, you may try to use reports. You may create a report with Geofences table type, and generate it via API.
If you need any additional details, feel free to write to support@wialon.com and provide details about the task.

Anton Zinovyev
Technical Care Engineer (L2)
Wialon
5

How to obtain the number of units in a geofence

Re: How to obtain the number of units in a geofence

zant hello, i'm trying to replicate the dashboard of wialon, this one

  • How to obtain the number of units in a geofence