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 <SPAN class="operator token">=</SPAN> SymbolFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ConstructMarker</SPAN><SPAN class="punctuation token">(</SPAN>
<SPAN class="number token">66</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"Schiff_real"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"Regular"</SPAN><SPAN class="punctuation token">,</SPAN>
_config<SPAN class="punctuation token">.</SPAN>ShipIconSize<SPAN class="punctuation token">,</SPAN>
ColorFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN>BlackRGB<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> CIMCharacterMarker<SPAN class="punctuation token">;</SPAN>
marker<SPAN class="punctuation token">.</SPAN>ScaleSymbolsProportionally <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> SymbolFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ConstructPointSymbol</SPAN><SPAN class="punctuation token">(</SPAN>marker<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Later in the application I'm rotating the symbol based on the ships movement direction which is also aquired from gps information.
_gpsPositionSymbol<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetAngle</SPAN><SPAN class="punctuation token">(</SPAN>targetCourseAngle<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
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
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">static</SPAN> Polyline <SPAN class="token function">CreatePolyline</SPAN><SPAN class="punctuation token">(</SPAN>MapPoint startPoint<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">double</SPAN> direction<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">double</SPAN> distance<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// First convert line of sight direction (heading) into angle from positive x axis to positive y axis</SPAN>
<SPAN class="keyword token">double</SPAN> theta <SPAN class="operator token">=</SPAN> <SPAN class="number token">360</SPAN> <SPAN class="operator token">-</SPAN> direction <SPAN class="operator token">+</SPAN> <SPAN class="number token">90</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Calculate target point by direction and distance</SPAN>
<SPAN class="keyword token">double</SPAN> new_x <SPAN class="operator token">=</SPAN> startPoint<SPAN class="punctuation token">.</SPAN>X <SPAN class="operator token">+</SPAN> distance <SPAN class="operator token">*</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Cos</SPAN><SPAN class="punctuation token">(</SPAN>theta <SPAN class="operator token">*</SPAN> Math<SPAN class="punctuation token">.</SPAN>PI <SPAN class="operator token">/</SPAN> <SPAN class="number token">180</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">double</SPAN> new_y <SPAN class="operator token">=</SPAN> startPoint<SPAN class="punctuation token">.</SPAN>Y <SPAN class="operator token">+</SPAN> distance <SPAN class="operator token">*</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Sin</SPAN><SPAN class="punctuation token">(</SPAN>theta <SPAN class="operator token">*</SPAN> Math<SPAN class="punctuation token">.</SPAN>PI <SPAN class="operator token">/</SPAN> <SPAN class="number token">180</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Construct target map point with input crs if available</SPAN>
MapPoint targetPoint <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>MapPoint<SPAN class="punctuation token">)</SPAN>MapPointBuilder<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateMapPoint</SPAN><SPAN class="punctuation token">(</SPAN>new_x<SPAN class="punctuation token">,</SPAN> new_y<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN>startPoint<SPAN class="punctuation token">.</SPAN>SpatialReference <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">?</SPAN> startPoint<SPAN class="punctuation token">.</SPAN>SpatialReference <SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> PolylineBuilder<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreatePolyline</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">List</SPAN><SPAN class="operator token"><</SPAN>MapPoint<SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN> startPoint<SPAN class="punctuation token">,</SPAN> targetPoint <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> startPoint<SPAN class="punctuation token">.</SPAN>SpatialReference<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>The resulting Polyline also seems to be correct, the displayed angle looks good! I also double checked the calculation by
<SPAN class="keyword token">var</SPAN> angle <SPAN class="operator token">=</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Atan2</SPAN><SPAN class="punctuation token">(</SPAN>new_y <SPAN class="operator token">-</SPAN> startPoint<SPAN class="punctuation token">.</SPAN>Y<SPAN class="punctuation token">,</SPAN> new_x <SPAN class="operator token">-</SPAN> startPoint<SPAN class="punctuation token">.</SPAN>X<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="number token">180</SPAN> <SPAN class="operator token">/</SPAN> Math<SPAN class="punctuation token">.</SPAN>PI<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
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?