- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不知道这是否可能,但我正在尝试拍摄自定义户外足球场布局的图像并让球员的GPS
坐标对应图像x
和 y
位置。这样,可以通过应用程序查看球员在球场上的当前位置,作为一种实时跟踪。
我也看过这个Convert GPS coordinates to coordinate plane .问题是我不知道这是否可行并且想事先确认。帖子中提供的图片用于室内定位,来自 11
几年前。
我用了Location
和 Google Maps
flutter 的包。玩家的latitude
和 longitude
对应实际latitude
和 longitude
android studio中的模拟器在测试时显示。
有问题的布局以及与我正在寻找的结果的密切比较。
对此问题的任何帮助将不胜感激,并提前感谢所有帮助。
编辑:
在查看了更多内容后,我尝试了这篇文章的答案 GPS Conversion - pixel coords to GPS coords ,但它没有按预期工作。我在图像和对应的坐标上取了一些点,并遵循与答案相同的逻辑,但将其反转以给我实际图像 X
, Y
职位。
上面帖子中给出的公式:
screenY0 //Screen origin (pixel corresponding to zero degrees latitude)
worldY0 //World origin (zero degrees latitude)
screenYscale //Screen scale (distance between 2 pixels)
worldYscale //World scale (distance between two latitude lines)
screenYpoint //Screen point (pixel y location)
worldYpoint //World point (latitude on the ground)
screenY0 + screenYscale * screenYpoint = worldY0 + worldYscale * worldYpoint.
帖子说
7.4
会有一些不准确的地方。米。提供的解决方案仅适用于靠近所选点的点或区域。当玩家移动一点时,该玩家的标记会跳出图像区域或离得很远。
X
位置:
delta_long
以度数表示田野角落的 GPS 差异。
delta_x
是图像的宽度。
horizontal_scale = delta_x/(cos(latitude)*delta_long)
然后
x = ( lon - lon_origin ) * horizontal_scale
我现在面临的问题是标记像这样在相反的 x 轴上移动,黑色箭头是实际玩家的移动方式,红色箭头显示玩家在应用程序内的移动方式。
最佳答案
首先,是 如果 GPS 坐标准确,您可以高精度地执行此操作。
其次,主要问题是旋转,如果 field 是直的,有 lat lng 线,这将很容易和直接(没有包子的意思)。
简单的方法是将坐标转换为类似于真实场的旋转图像,然后将每个 X、Y 点旋转到新的直线图像。 (见下图)
这是知道天使如何旋转 x,y 的方法:
double x,y;
double newX,newY;
double angle;
//Test values:
x=1;
y=1;
angle = 45;
double rad = angle*M_PI/180;
newX = x * cos(rad) - y * sin(rad);
newY = y * cos(rad) + x * sin(rad);
更新
long double lat1,lat2,lng1,lng2; //fill these with GPS coordinates
double x1,x2,y1,y2;//fill these of rectangle coordinate in the image
long double realWidth = distance(lat1, long1,lat2,long1);// distance btween the upper left corner & the upper right corner
long double realHieght = distance(lat1, long1,lat1,long2);// distance btween the upper left corner & the lower left corner
double image1Width = abs(x2-x1);
double image1Hieght = abs(y2-y1);
long double playerLat,playerLng;//fill the player lat lng GPS coordiantes
POINT imagePlayerXY = convertGPS2xy(lat1, lng1, playerLat, playerLng, realWidth, realHieght, image1Width, image1Hieght);
//NOW rotate imagePlayerXY.x & imagePlayerXY.y to the final image
POINT convertGPS2xy(long double latOrigin, long double lngOrigin,long double playerLat, long double playerLng,long double realWidth,long double realHieght, double image1Width,double image1Hieght)
{
double lngRatio2Width = distance(playerLat,playerLng, playerLat,lngOrigin ) / realWidth; //horizantal distance from the player place to rectangle origin (then compute the width ratio)
double lngRatio2Hieght = distance(playerLat,playerLng, latOrigin,playerLng ) / realHieght; //virtical distance from the player place to rectangle origin (then compute the Hieght ratio)
POINT imageXY;
imageXY.x = image1Width * lngRatio2Width;
imageXY.y = image1Hieght * lngRatio2Hieght;
return imageXY;
}
long double distance(long double lat1, long double long1,
long double lat2, long double long2)
{
// Convert the latitudes
// and longitudes
// from degree to radians.
lat1 = toRadians(lat1);
long1 = toRadians(long1);
lat2 = toRadians(lat2);
long2 = toRadians(long2);
// Haversine Formula
long double dlong = long2 - long1;
long double dlat = lat2 - lat1;
long double ans = pow(sin(dlat / 2), 2) +
cos(lat1) * cos(lat2) *
pow(sin(dlong / 2), 2);
ans = 2 * asin(sqrt(ans));
// Radius of Earth in
// Kilometers, R = 6371
// Use R = 3956 for miles
long double R = 6371;
// Calculate the result
ans = ans * R;
return ans;
}
关于android - 转换 GPS 坐标以匹配自定义 2d 户外布局图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70603285/
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我试图用这种形式简单地获取数字 28 integer+space+integer+integer+space+integer我试过这个正则表达式 \\s\\d\\d\\s 但我得到了两个数字11 和
最近一直在学习D语言。我一直对运行时感到困惑。 从我能收集到的关于它的信息中,(这不是很多)我知道它是一种有助于 D 的一些特性的运行时。像垃圾收集一样,它与您自己的程序一起运行。但是既然 D 是编译
想问一下这两个正则表达式有区别吗? \d\d\d 与 \d{3} 我已经在我的本地机器上使用 Java 和 Windows 操作系统对此进行了测试,两者都工作正常并且结果相同。但是,当在 linux
我正在学习 Go,而且我坚持使用 Go 之旅(exercise-stringer.go:https://tour.golang.org/methods/7)。 这是一些代码: type IPAddr
我在Java正则表达式中发现了一段令我困惑的代码: Pattern.compile( "J.*\\d[0-35-9]-\\d\\d-\\d\\d" ); 要编译的字符串是: String string
我在 ruby 代码上偶然发现了这个。我知道\d{4})\/(\d\d)\/(\d\d)\/(.*)/是什么意思,但是\1-\2-\3-\4 是什么意思? 最佳答案 \1-\2-\3-\4 是 b
我一直在努力解决这个问题,这让我很恼火。我了解 D 运行时库。它是什么,它做什么。我也明白你可以在没有它的情况下编译 D 应用程序。就像 XoMB 所做的那样。好吧,XoMB 定义了自己的运行时,但是
我有两个列表列表,子列表代表路径。我想找到所有路径。 List> pathList1 List> pathList2 当然是天真的解决方案: List> result = new ArrayList>
我需要使用 Regex 格式化一个字符串,该字符串包含数字、字母 a-z 和 A-Z,同时还包含破折号和空格。 从用户输入我有02-219 8 53 24 输出应该是022 198 53 24 我正在
目标是达到与this C++ example相同的效果: 避免创建临时文件。我曾尝试将 C++ 示例翻译为 D,但没有成功。我也尝试过不同的方法。 import std.datetime : benc
tl;dr:你好吗perfect forwarding在 D? 该链接有一个很好的解释,但例如,假设我有这个方法: void foo(T)(in int a, out int b, ref int c
有什么方法可以在 D 中使用abstract auto 函数吗? 如果我声明一个类如下: class MyClass { abstract auto foo(); } 我收到以下错误: mai
有没有人为内存中重叠的数组切片实现交集?算法在没有重叠时返回 []。 当 pretty-print (使用重叠缩进)内存中重叠的数组切片时,我想要这个。 最佳答案 如果您确定它们是数组,那么只需取 p
我已经开始学习 D,但我在使用 Andrei Alexandrescu 所著的 The D Programming Language 一书中提供的示例时遇到了一些麻烦。由于 int 和 ulong 类
如何创建一个不可变的类? 我的目标是创建一个实例始终不可变的类。现在我只是用不可变的方法和构造函数创建了一个“可变”类。我将其称为 mData,m 表示可变。然后我创建一个别名 alias immut
不久前我买了《The D Programming Language》。好书,很有教育意义。但是,我在尝试编译书中列出的语言功能时遇到了麻烦:扩展函数。 在这本书中,Andrei 写了任何可以像这样调用
我在 D http://www.digitalmars.com/d/2.0/lazy-evaluation.html 中找到了函数参数的惰性求值示例 我想知道如何在 D 中实现可能的无限数据结构,就像
这个问题在这里已经有了答案: 12 年前关闭。 Possible Duplicate: Could anyone explain these undefined behaviors (i = i++
当前是否可以跨模块扫描/查询/迭代具有某些属性的所有函数(或类)? 例如: source/packageA/something.d: @sillyWalk(10) void doSomething()
我是一名优秀的程序员,十分优秀!