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:

  1. Choose auto for the type property of the mobility object in your group or groups in the simulation.json file.

  2. Include the routes_id value in the mobility objects. You can also configure other parameters. See mobility.

  3. 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 for routes_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

origin

Array

Latitude and longitude of the route origin as [latitude, longitude].

destination

Array

Latitude and longitude of the route destination as [latitude, longitude].

distance

Number

Total route distance in meters.

duration

Integer

Duration of the route in seconds.

stops

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.

coordinates

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:

  1. Sign in to your Google account.

  2. Go to Google Maps, https://maps.google.com/.

  3. Click on Saved, then select Maps.

  4. Click Create Map at the bottom.

  5. Click Draw a line in the toolbar under the search bar.

  6. Choose the type of route.

  7. Find the area you want on the map and click once to set the starting point.

  8. Draw your route:

    1. Use single clicks to fix points within your route.

    2. Double click to set the ending point.

  9. 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.

  10. In the combo box, select only the route you just created instead of the Entire map option.

  11. Select the option Export as KML instead of KMZ. Does not support all icons.

  12. Click Download and use the file browser to select the location on your PC.

  13. 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:

  1. Add the user_app object to the simulation.json file. See Simulation configuration.

  2. Set custom as the value for the type property in the mobility objects of your group or groups in the simulation.json file.

  3. Define the sampling_rate value in the mobility objects.

  4. Create the required Python custom code to provide new locations. See the next step [add-custom-location-code].