android模拟器可以用gpx文件模拟海拔高度吗?

发布于 2024-10-07 01:27:12 字数 170 浏览 0 评论 0原文

我正在尝试从 ddms 角度模拟模拟器设备的运动。我正在使用包含海拔元素的 gpx 文件,但是当我的代码运行时,它只检索纬度/经度并表示海拔 = 0。

我的问题是,Android 模拟器可以用于模拟海拔、速度等吗?或者只是用于纬度和经度数据?

I am trying to simulate motion of the emulator device in the ddms perspective. I am using a gpx file which contains elevation elements, but when my code runs, it only retrieves lat/lon and says that elevation = 0.

My question is, Can the android emulator be used to simulate altitude, speed etc, or is it just for latitude and longitude data?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽清梦 2024-10-14 01:27:12

这并不是真正的答案,但它可能会给您一些有用的想法。

您使用什么类型的提供商?有 2 个选项:LocationManager.GPS_PROVIDERLocationManager.NETWORK_PROVIDER。我的猜测是,只有使用 LocationManager.GPS_PROVIDER 时,海拔高度才可用。

另外,在 Location 更新中(在 LocationListener.onLocationChanged(Location location) 中),您可以调用 location.hasAltitude()。如果此修复包含高度信息,则返回 true,否则返回 false。

更新

看来您遇到了一些模拟器问题。我记得我使用的是 Eclipse 3.4.1 + ADT 0.9.5 + Android 2.0.1 应用程序 + WinXP,为模拟器提供 GPS 修复的唯一方法是使用 Telnet。所以我刚刚为此创建了一个辅助 Ruby 脚本:

require 'net/telnet'

scenario = [
  'sleep 1', 
  'geo fix -121.45356 46.51119 0', 
  'sleep 3', 
  'geo fix -80.45356 45.51119 0'
]

simulator_connection = nil

begin
  simulator_connection = 
    Net::Telnet::new(
      'Timeout' => 5, 
      'Port'    => 5554, 
      'Prompt'  => /(OK|\AKO.*\z)/
    )
rescue Errno::EBADF
  puts '> Error: running Android Emulator not found. Exiting ...'
  exit
end

puts '> got connection to Android Emulator'

begin
  scenario.each do |action|
    if action =~ /\Asleep\s\d+\z/
      puts "> #{action} secs ..."
      eval(action)
    else
      puts "> execute \"#{action}\""
      simulator_connection.cmd(action)
    end
  end
  puts '> job is done, exiting ...'
ensure
  simulator_connection.close
end

您会看到我传递 0 作为海拔(“geo fix ...”的最后一个参数),但是您可以尝试使用非零值。如果您不熟悉 Ruby,那么您可能可以将该脚本采用您最喜欢的脚本语言。让我知道这是否对您有用。

This is not really an answer, however it may give you some useful ideas.

What type of provider do you use? There are 2 options: LocationManager.GPS_PROVIDER and LocationManager.NETWORK_PROVIDER. My guess is that altitude can only be available if LocationManager.GPS_PROVIDER is used.

Also on you Location updates (in LocationListener.onLocationChanged(Location location)) you can call location.hasAltitude(). It returns true if this fix contains altitude information, false otherwise.

UPDATE:

So it looks like you are experiencing some emulator issue. I rerember I was on Eclipse 3.4.1 + ADT 0.9.5 + Android 2.0.1 app + WinXP and the only way to feed the emulator with GPS fixes was to use Telnet. So I just created a helper Ruby script for that:

require 'net/telnet'

scenario = [
  'sleep 1', 
  'geo fix -121.45356 46.51119 0', 
  'sleep 3', 
  'geo fix -80.45356 45.51119 0'
]

simulator_connection = nil

begin
  simulator_connection = 
    Net::Telnet::new(
      'Timeout' => 5, 
      'Port'    => 5554, 
      'Prompt'  => /(OK|\AKO.*\z)/
    )
rescue Errno::EBADF
  puts '> Error: running Android Emulator not found. Exiting ...'
  exit
end

puts '> got connection to Android Emulator'

begin
  scenario.each do |action|
    if action =~ /\Asleep\s\d+\z/
      puts "> #{action} secs ..."
      eval(action)
    else
      puts "> execute \"#{action}\""
      simulator_connection.cmd(action)
    end
  end
  puts '> job is done, exiting ...'
ensure
  simulator_connection.close
end

You see I pass 0 as the altitude (the last param at 'geo fix ...'), however you may try with your non-zero values. If you are not familiar with Ruby, then you could probably adopt the script to your favorite scripting language. Let me know if this worked for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文