I need help calculating new coordinates after an imageview translation.
I am working on an android app that will plot points on a map.
The map is downloaded from a backed service.
The points I need to plot come from the backend, and their positions are relative to the map size (8000w x 4450h).
The app (using glide) sets the image in a custom imageview. When that happens, the map is scaled down to fit the screen.
viewH = 735.
viewW = 1080.
I then need to plot the locations; however, the plotted coordinates need to be translated to match the new scale.
Here is how I am calculating it now...which gets the points in the correct area...but they are not precise (plotting to low on y axis):
newX = oldX / (originalMapHeight / imageviewHeight).
newY = oldY / (originalMapWidth / imageviewWidth).
Can someone help me get a more accurate translation of the x,y coordinates? I cannot find anything regarding this, but it may be due to me not knowing what exactly to search.
Thanks!
You can use min-max normalization for this. The formula is
For your case, the formula reduces to
NewX = (oldX * imageViewWidth) / originalMapWidth
NewY = (oldY * imageViewHeight) / originalMapHeight