I don't know if this is possible, but I am trying to take the image of a custom outdoor football field layout and have the players' GPS
coordinates correspond to the image x
and y
position. This way, it can be viewed via the app to show the players' current location on the field as a sort of live tracking.
I have also looked into this Convert GPS coordinates to coordinate plane. The problem is that I don't know if this would work and wanted to confirm beforehand. The image provided in the post was for indoor location, and it was from 11
years ago.
I used Location
and Google Maps
packages for flutter. The player's latitude
and longitude
correspond to the actual latitude
and longitude
that the simulator in the android studio shows when tested.
The layout in question and a close comparison to the result I am looking for.
Edit:
After looking more at the matter I tried the answer of this post GPS Conversion - pixel coords to GPS coords, but it wasn't working as intended. I took some points on the image and the correspond coordinates, and followed the same logic that the answer used, but reversed it to give me the actual image X
, Y
positions.
The formula that was given in the post above:
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.
The post said there would be some inaccuracy about 7.4
meters. The solution provided works only for the points or areas close to the chosen point. When a player would move a bit more, the marker for that player would jump outside of the image area or be very far off.
Edit2:
I have tried the solution from this post Convert GPS coordinates to coordinate plane with the following formula to calculate the X
position:
delta_long
to be the differences, in degrees, in the GPS of the fields corners. delta_x
is the width of the image.
horizontal_scale = delta_x/(cos(latitude)*delta_long)
and then x = ( lon - lon_origin ) * horizontal_scale
The issue that I am facing right now is that the marker moves at the opposite x-axis like this, where the black arrow is how the actual player moves and the red arrow shows how the player moves inside the app.