I have a situation where i have rotated all of the layers on my map. As is my understanding when i rotate the layers the x and y coordinates remain the same.
When i Use the map click event and get the e.worldx and e.worldy values it's returning the x and y coordinates without taking the rotation into consideration.
Can anyone help me understand how i can get the map coordinates whilst taking into consideration that the projection has been rotated about a single point?
I thnk i fugured it out in the end, i just took the coordinates that the map was returning and reversed them in order to match the coordinate systems.
I use shape rotate rather than applying the projection to the actual layers as i’ve never been able to get the to function as i wanted.
Friend ReadOnly Property ClickedPosition As PointShape Get Dim dtem As New PointShape(SelectedPointOnMapX, SelectedPointOnMapY)
If RotationTracker.isMapRotated = True Then
'We do a reverse rotate on the clicked point because the coordinates coming back from the map are in a non rotated state 'The layer the shape exists on is rotated. 'when we rotate the shape layer we move the coordinate system as well as the shape. 'when we click the map it provides coordinates that ignore the rotation 'If we reverse the coordinates back by the angle the shape layer is rotated by then we are ultimately matching the two coordinate systems
dtem = New PointShape(RotationTracker.ReverseRotate(dtem.GetWellKnownBinary)) End If
Return dtem
End Get End Property
Public Class RotationTracker
Public Shared Property isMapRotated As Boolean Public Shared Property Angle As Double Public Shared Property Proj4 As New ProjectionWithRotation Public Shared Property RotationPointX As Double = 8.31589444444444 Public Shared Property RotationPointY As Double = 49.0127777777778
Public Shared Function Rotate(item As Byte()) As Byte()
Return RotateMapLayer(item, Angle)
End Function
Public Shared Function ReverseRotate(item As Byte()) As Byte()
Return RotateMapLayer(item, -Angle)
End Function
Private Shared Function RotateMapLayer(item As Byte(), angle As Double) As Byte()
Dim Shape As BaseShape Dim feature As Feature Dim RotationVertex As New Vertex Dim rotationAngle As Double
I’m glad it’s working for you now, for the coordinates rotate problem, if you apply the same projection which your map is using to the layer which contains the points, it will taking the rotation into consideration.