I'm trying to add map rotation to our custom .NET windows application. Following the sample 'CenteringAndRotatingOnMovingFeature', I've added code to implement map rotation. However, my data displays somewhere out in left field now when I set rotateProjection.Angle to 45, and when I find the data through panning and zooming out to left field the map/data is not being rotated. I assume my code is not correct and could use help identifying the problem. Without pasting to much code, here are some snippets pertaining to the map rotation. I'd be much apprecitive if someone can help spot the problem or give me some hints for debugging.
private RotationProjection rotateProjection = new RotationProjection();
void LayoutMapGeoView_Loaded(object sender, RoutedEventArgs e)
{
rotateProjection.Angle = (float)LayoutMapGeoViewModel.MapAngle; // value = 45, I'm assuming units are degrees
lineSegmentLayer = new LineSegmentFeatureLayer(LayoutMapGeoViewModel, this);
lineSegmentLayer.FeatureSource.Projection = rotateProjection;
pointsOverlay.Layers.Add(SEGMENTS_LAYER_NAME, lineSegmentLayer);
pfLayer = new PointsFeatureLayer(LayoutMapGeoViewModel, this);
pfLayer.FeatureSource.Projection = rotateProjection;
pointsOverlay.Layers.Add(POINTS_LAYER_NAME, pfLayer);
ResetExtents();
...
}
private void ResetExtents()
{
log.DebugFormat("LayoutMapGeoView.ResetExtents");
pfLayer.Open();
rotateProjection.Angle = (float)LayoutMapGeoViewModel.MapAngle;
wpfMap1.CurrentExtent = rotateProjection.GetUpdatedExtent(pfLayer.FeatureSource.GetBoundingBox());
wpfMap1.CenterAt(pfLayer.GetBoundingBox().GetCenterPoint());
pfLayer.Close();
}
class LineSegmentFeatureLayer : InMemoryFeatureLayer
{
private static ILog log = LogManager.GetLogger(typeof(LineSegmentFeatureLayer));
private Feature DEFAULT_FEATURE = new Feature(-1, -1);
SpreadManagerMapViewModel viewModel = null;
LayoutMapGeoView view = null;
LineSegmentLineStyle lineStyle = null;
public LineSegmentFeatureLayer(SpreadManagerMapViewModel viewModel, LayoutMapGeoView view)
{
this.viewModel = viewModel;
this.view = view;
((INotifyCollectionChanged)viewModel.LineSegments).CollectionChanged += new NotifyCollectionChangedEventHandler(LineSegments_CollectionChanged);
ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
DrawingQuality = DrawingQuality.HighSpeed;
lineStyle = new LineSegmentLineStyle();
ZoomLevelSet.ZoomLevel01.CustomStyles.Add(lineStyle);
AddFeatures(viewModel.LineSegments);
}