In the real world, IoT devices are not always in a static location; sometimes, devices are in motion. For example, in a bike-renting business, the owner may need to know the location of all bikes at all times, or users may need to locate the closest bike on a map.
Digi Remote Manager allows your devices to upload their current location as coordinates. To do so, you can:
-
Define as many routes as required for your simulated devices and assign them to each group of devices. See Define route files.
-
Implement custom code to provide new simulated device location coordinates. See Generate location by code.
Define route files
Routes associated with a group must be in an independent directory inside the routes
folder of your simulation.
These routes must be configured in the routes_id
property of the mobility
object in the simulation.json
file.
To automatically generate simulated device locations based on a set of predefined routes, you must:
-
Choose
auto
for thetype
property of themobility
object in your group or groups in thesimulation.json
file. -
Include the
routes_id
value in themobility
objects. You can also configure other parameters. Seemobility
. -
Create different sets of routes inside independent directories in the
routes
folder of your simulation. The names of these directories must match the values configured forroutes_id
.
The following is an example of a valid route:
{
"origin": [44.835366,-93.404133],
"destination": [44.836655,-93.408601],
"distance": 541.1,
"duration": 66,
"stops": [
[44.836112,-93.405509]
],
"coordinates": [
[44.835367,-93.404153],
[44.835405,-93.404148],
[44.835542,-93.404107],
[44.83581,-93.403948],
[44.83593,-93.403904],
[44.836053,-93.403895],
[44.836354,-93.403984],
[44.83648,-93.404037],
[44.836349,-93.404613],
[44.836112,-93.405509],
[44.83599,-93.40587],
[44.835973,-93.40615],
[44.835985,-93.406445],
[44.836022,-93.406776],
[44.836072,-93.407058],
[44.836176,-93.407396],
[44.836301,-93.407673],
[44.836444,-93.407928],
[44.836717,-93.408291],
[44.836831,-93.408408],
[44.836715,-93.408587],
[44.836671,-93.408632]
]
}
Each route requires the following information:
Property | Required | Type | Description |
---|---|---|---|
Array |
Latitude and longitude of the route origin as |
||
Array |
Latitude and longitude of the route destination as |
||
Number |
Total route distance in meters. |
||
Integer |
Duration of the route in seconds. |
||
Array |
List of stop points along the route. Each item is an array with two elements representing the latitude and longitude of the stop point. |
||
Array |
List of all points along the route. Each item is an array with two elements representing the latitude and longitude of the route point. |
Generate a route with Google Maps
Route coordinates can be obtained from external applications. Use these applications to get the points of the routes. Not all points are required, just enough for a valid simulation.
Here is a guide to obtaining them from Google Maps:
-
Sign in to your Google account.
-
Go to Google Maps, https://maps.google.com/.
-
Click on Saved, then select Maps.
-
Click Create Map at the bottom.
-
Click Draw a line in the toolbar under the search bar.
-
Choose the type of route.
-
Find the area you want on the map and click once to set the starting point.
-
Draw your route:
-
Use single clicks to fix points within your route.
-
Double click to set the ending point.
-
-
Once you are done adding route points, click the 3-dot menu on the right of the map’s name and select Export to KML/KMZ. The Export to KML/KMZ dialog opens.
-
In the combo box, select only the route you just created instead of the Entire map option.
-
Select the option Export as KML instead of KMZ. Does not support all icons.
-
Click Download and use the file browser to select the location on your PC.
-
Once downloaded, open the KML file in your favorite text editor (e.g., Kate, Gedit, Notepad++) and find the
<coordinates>
tag inside the<LineString>
tag, which contains all the coordinates of your route.
Generate location by code
To generate simulated device locations using custom code, you must:
-
Add the
user_app
object to thesimulation.json
file. See Simulation configuration. -
Set
custom
as the value for thetype
property in themobility
objects of your group or groups in thesimulation.json
file. -
Define the
sampling_rate
value in themobility
objects. -
Create the required Python custom code to provide new locations. See the next step [add-custom-location-code].