Dra*_*mon 9 math gps android google-maps flutter
我不知道这是否可能,但我正在尝试拍摄自定义室外足球场布局的图像,并使球员的GPS坐标与图像x和y位置相对应。这样,就可以通过应用程序查看,以显示球员在球场上的当前位置,作为一种实时跟踪。
我还研究了将 GPS 坐标转换为坐标平面。问题是我不知道这是否有效并且想提前确认。帖子中提供的图像是室内位置的,而且是11几年前的。
我使用了flutter 的LocationandGoogle Maps包。播放器的latitude和与测试时 Android Studio 中的模拟器显示的longitude实际latitude和相对应。longitude
有问题的布局以及与我正在寻找的结果的密切比较。
编辑:
在详细研究了这个问题之后,我尝试了这篇文章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.
Run Code Online (Sandbox Code Playgroud)
该帖子称,米数会有一些不准确的地方7.4。提供的解决方案仅适用于靠近所选点的点或区域。当玩家移动得更多时,该玩家的标记会跳到图像区域之外或非常远。
编辑2:
我已经尝试了这篇文章将 GPS 坐标转换为坐标平面的解决方案,使用以下公式计算X位置:
delta_long是田野角落 GPS 的差异(以度为单位)。delta_x是图像的宽度。
horizontal_scale = delta_x/(cos(latitude)*delta_long)然后x = ( lon - lon_origin ) * horizontal_scale我现在面临的问题是标记在相反的 x 轴上移动,如下所示,其中黑色箭头是实际玩家的移动方式,红色箭头显示玩家在应用程序内的移动方式。
首先,是的,如果GPS 坐标准确,您可以高精度地完成此操作。
其次,主要问题是旋转,如果场地是直的,有经纬线,这将是简单而直接的(没有意图)。
简单的方法是将坐标转换为类似于真实场的旋转图像,然后将每个 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);
Run Code Online (Sandbox Code Playgroud)
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);
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1247 次 |
| 最近记录: |