【问题标题】:PowerApps Distance Between Coordinates in a LoopPowerApps 循环中坐标之间的距离
【发布时间】:2021-10-19 13:33:51
【问题描述】:

我是 PowerApps 的新手。我有一个共享点列表,其中包含不同位置的一组坐标。我需要弄清楚的是,当用户在手机上使用 PowerApps 应用程序时,使用 Haversine 公式在这些坐标的一定距离内。虽然 Haversine 公式使用硬编码的目标位置以测试/简单的方式工作,但我需要共享点列表中的目标位置。这是我的代码,在 Timer End 内:

ForAll(
  irfan_yard_locations,
 With(
    {
        r: 6371000,  p: (Pi() / 180),  latA: location_lat,  lonA: location_long, latB: Location.Latitude,  lonB: Location.Longitude
    },
    Round((2 * r) * Asin(Sqrt(0.5 - Cos((latA - latB) * p)/2 + Cos(latB * p) * Cos(latA * p) * (1 - Cos((lonA - lonB) * p)) / 2)), 2 ));
) ;

irfan_yard_locations 是具有location_latlocation_long 坐标的SP 列表。我在想这个示例站点中的类似内容:http://powerappsguide.com/blog/post/formula-how-to-use-the-if-and-switch-functions,因此如果来自with () 的返回(这将是一个数字)小于 5(以米为单位),则导航到另一个屏幕或执行某些操作。只是不知道语法。还是有更好的方法?

谢谢!

【问题讨论】:

    标签: loops sharepoint powerapps forall


    【解决方案1】:

    没关系。通过在With 函数周围添加一个If 子句,我可以捕捉到当前位置是否在一个坐标集的6 米范围内。

    ForAll(
      irfan_yard_locations,
    If ( With(
        {
            r: 6371000,  p: (Pi() / 180),  latA: location_lat,  lonA: location_long, latB: Location.Latitude,  lonB: Location.Longitude
        },
        Round((2 * r) * Asin(Sqrt(0.5 - Cos((latA - latB) * p)/2 + Cos(latB * p) * Cos(latA * p) * (1 - Cos((lonA - lonB) * p)) / 2)), 2 )) < 6, Navigate(Screen2));
    ) ;
    

    【讨论】:

      猜你喜欢
      • 2021-10-11
      • 1970-01-01
      • 1970-01-01
      • 2021-09-08
      • 2010-11-23
      • 1970-01-01
      • 1970-01-01
      • 2016-01-23
      • 2016-10-31
      相关资源
      最近更新 更多