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
rotationAngle = angle
_Proj4.Open()
RotationVertex = _Proj4.ConvertToExternalProjection(RotationPointX, RotationPointY)
feature = New Feature(item)
Shape = feature.GetShape()
'rotate cant handle negatives, it rotates in a counterclockwise direction
If rotationAngle < 0 Then
rotationAngle = Math.Abs(rotationAngle)
Else
rotationAngle = 360 - rotationAngle
End If
Shape.Rotate(New PointShape(RotationVertex.X, RotationVertex.Y), rotationAngle)
Return Shape.GetWellKnownBinary
End Function
End Class