Select to view content in your preferred language

Strange behaviour with CIMPointSymbol.AddAngle()

811
1
02-13-2019 05:02 AM
RichardReinicke
Frequent Contributor

Hi,

I`m currently experiencing a strange behaviour with the SDK version 2.1.

First I need to describe shortly what I'm trying to to. Inside my application I have a GPS position of a ship marked with an CIMPointSymbol inside the map.

CIMCharacterMarker marker = SymbolFactory.Instance.ConstructMarker(
    66, 
    "Schiff_real", 
    "Regular", 
    _config.ShipIconSize, 
    ColorFactory.Instance.BlackRGB) as CIMCharacterMarker;
marker.ScaleSymbolsProportionally = false;
return SymbolFactory.Instance.ConstructPointSymbol(marker);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Later in the application I'm rotating the symbol based on the ships movement direction which is also aquired from gps information.

_gpsPositionSymbol.SetAngle(targetCourseAngle)

where targetCourseAngle is the negative value of true heading. Of course I checked the provided value is okay and GetAngle gives correct value back.

This first seemed to work fine in application but now I was adding a second feature to the app, showing the current ship heading as a short helper line in front of the ship icon. The polyline is created by two points where target point is calculated by distance and direction from current ship position

public static Polyline CreatePolyline(MapPoint startPoint, double direction, double distance)
{
    // First convert line of sight direction (heading) into angle from positive x axis to positive y axis
    double theta = 360 - direction + 90;

    // Calculate target point by direction and distance
    double new_x = startPoint.X + distance * Math.Cos(theta * Math.PI / 180);
    double new_y = startPoint.Y + distance * Math.Sin(theta * Math.PI / 180);

    // Construct target map point with input crs if available
    MapPoint targetPoint = (MapPoint)MapPointBuilder.CreateMapPoint(new_x, new_y, (startPoint.SpatialReference != null) ? startPoint.SpatialReference : null);

    return PolylineBuilder.CreatePolyline(new List<MapPoint> { startPoint, targetPoint }, startPoint.SpatialReference);
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The resulting Polyline also seems to be correct, the displayed angle looks good! I also double checked the calculation by

var angle = Math.Atan2(new_y - startPoint.Y, new_x - startPoint.X) * (180 / Math.PI);

with angle being positive degrees from positive x axis.

However, if I display both symbol and heading line in the map, I have a slight shift in the directions. Symbol orientations and line direction are identical at full main directions 0°, 90°, 180°, 270° but diverge towards the middle of each quadrant. Please see the resulting effects in the attached images from east over south east to south.

I can't see any mistake in my code and the divergence really only occures in the middle of each quadrant.

Can someone reproduce this behaviour or help me out?

0 Kudos
1 Reply
RichardReinicke
Frequent Contributor

This question has been resolved. 

Both ship icon and polyline had correct orientation but had a projection missmatch ... stupid mistake, I'm sorry. Once I transformed polyline to matching projection and then rotated it, both lined up correctly.

0 Kudos