Feature request / suggestion: Using this to simulate track
I made a small bash-script (with my very limited knowledge) to simulate a track based on a GEOjson object. Don't know if this belongs in this repo, but maybe it's relevant for others coming here:
Track.json (uses all elements in coordinates):
{
"track": {
"coordinates": [
[10.762656440290426, 60.00290862625803],
[10.762708634492366, 60.00293005616841],
[10.762640254374531, 60.002963109255965],
[10.762610401710422, 60.00300239554637]
]
}
}
SimulateTrack.sh (also requires jq)
#!/bin/bash
# Pass interval as parameter
interval=$1
for k in $(jq '.track.coordinates | keys | .[]' Track.json); do
lon=$(jq -r ".track.coordinates[$k][0]" Track.json);
lat=$(jq -r ".track.coordinates[$k][1]" Track.json);
set-simulator-location -c $lat $lon
sleep "$interval"
done
Usage:
Update location every second:
./SimulateTrip.sh 1
Update location every 5 seconds:
./SimulateTrip.sh 5
Are the results okay with the simulator ? I was thinking doing something similar with GPX files
IIRC we could modify this tool to provide a gpx file to the simulator.
Yes, this works fine with the Simulator @Daavidaviid . Haven't had the need to use it for a GPX file (yet), but if you modified it to this usecase i would love to see the end-result @keith ? :)
Looks like Xcode 14's new features supports some of this, you should use that instead:
% xcrun simctl location
Control a device's simulated location
Usage: simctl location <device> <action> [arguments]
list
List available simulation scenarios.
clear
Stop any running scenario and clear any simulated location.
set <lat1>,<lon1>
Set the location to a specific latitude and longitude.
run <scenario>
Run a simulated location scenario (use the list action to get a list of scenarios).
start [--speed=<meters/sec>] [--distance=<meters per second>|--interval=<seconds>] <lat1>,<lon1> <latN>,<lonN>...
Set the location to a series of waypoints specified as 'lat,lon' pairs, interpolating between them over time.
At least two waypoints are required. Use '-' to read waypoints from stdin, one waypoint per line.
Speed specifies how quickly to move between waypoints in meters per second. If not specified 20m/s is used.
The system will issue location updates along the path between each pair of waypoints. Use distance or interval to
control how often those updates are issued. Distance will issue an update every <meters> travelled without regard
for the time between updates. Interval will issue updates at fixed times without regard for how much
the location moves between updates.
If neither are specified an interval of 1.0 seconds is used. If both are specified the system picks ones.
Example simulating a direct line between San Francisco and New York City, with updates every km:
set --distance=1000 --speed=260 37.629538,-122.395733 40.628083,-73.768254
Latitude and longitude pairs must be specified using '.' as the decimal separator and ',' as the field separator.