繁体   English   中英

使用 iOS 模拟器在 expo 应用程序上使用 gpx 文件模拟位置

[英]SImulating location with gpx file on expo app using iOS simulator

我想在 iOS 模拟器中输入一个 gpx 文件来模拟沿路线行驶。 但是,为了做到这一点,我需要将一个 gpx 文件添加到我的 xcode 项目中。 我正在使用的项目是使用 expo 制作的,所以我无法在 xcode 中打开它。是否有任何解决方法可以在不打开 xcode 的情况下模拟路由?

模拟位置可以通过set-simulator-location等工具在模拟器级别完成

只需使用brew install lyft/formulae/set-simulator-location安装它

然后设置模拟器位置: set-simulator-location -q Expo 624 University Ave Palo Alto CA (设置到 Expo 办公室)。

我最终通过使用set-simulator-location-trip-simulator解决了我的问题,这是一个使用set-simulator-location构建的工具。 它允许您为 select 一个起点和终点目的地,并模拟从起点到终点的旅程。 但是,它不允许使用 gpx 文件。

由于 Xcode 14 simctl提供了设置模拟器位置的可能性:

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

要将它与 gpx 文件一起使用,您需要某种包装器来生成这样的命令(注意 N 坐标是可能的):

xcrun simctl location "iPhone 14 Pro" start 37.629538,-122.395733 40.628083,-73.768254

根据我的研究,这提供了比我发现的所有其他工具更多的功能,并且优于lyft/formulae/set-simulator-location

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM