Select to view content in your preferred language

Use SimulatedLocationDataSource to simulate a track

301
1
Jump to solution
02-02-2025 09:31 AM
KarenRobine1
Regular Contributor

Hello:

I'm using a SimulatedLocationDataSource to simulate a Track that was previously generated.  I would like to change the following while the simulation is running:

1. I would like to adjust the SimulatedVelocity:  This is a property of SimulationParameters which is used with the SetLocationsWithPolyline method.  Therefore, the only way I know how to do this is by restarting the simulation from the beginning, or stopping the current simulation and reworking the geometry to start at the current location. All of these solutions would lead to a bad user experience.  Ideas?

2. I would like my simulation to stop at the End Node.  Instead, it goes back to the Start Node when it gets near the end node.

3. I would like to see the simulation follow all of the vertices.  My current simulation skips vertices.  I think I might be able to do something more elegant by using a RouteTracker with a SimulatedLocationDataSource (this sample demonstrates this:  

https://developers.arcgis.com/net/maui/sample-code/navigate-route/  )  However, I need to avoid credit usage for this application (although, maybe credits aren't being used since I'm not having the code figure out a route???).

Thoughts?

0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

The SimulatedLocationDataSource  is pretty basic and is mainly for quick testing scenarios.

Your best option if you want full control is to create a subclass of LocationDatasource and call base.UpdateLocation with the updated location on an interval. You can use the GeometryEngine operations to calculate positions along a predefined line and calculate whatever speed and pauses you want. It would be a little bit of math and stuff to make work, but totally doable. The GeometryEngine.CreatePointAlong method is quite useful for this, as you'd just update the distance down the line based on the speed you want and get the new location.

View solution in original post

1 Reply
dotMorten_esri
Esri Notable Contributor

The SimulatedLocationDataSource  is pretty basic and is mainly for quick testing scenarios.

Your best option if you want full control is to create a subclass of LocationDatasource and call base.UpdateLocation with the updated location on an interval. You can use the GeometryEngine operations to calculate positions along a predefined line and calculate whatever speed and pauses you want. It would be a little bit of math and stuff to make work, but totally doable. The GeometryEngine.CreatePointAlong method is quite useful for this, as you'd just update the distance down the line based on the speed you want and get the new location.