Add a rotation to latitude/longitude -> screen coords?

49 Views Asked by At

I found an algorithm which allows to convert latitude/longitude to (x, y) of a screen. The problem is a picture on a map is rotated. If it is not rotated then I use the following calculations:

minLat, minLong, maxLat, maxLong - coords of a rect on a map

mapWidth, mapHeight - screen (rect) width and height

x, y - coords I need

Calculations

xScale = mapWidth / (maxLong - minLong)

yScale = mapHeight / (maxLat - minLat)

x = (lon - minLong) * xScale

y = (lat - minLat) * yScale

How to fix these calculations to take into account a rotation?