You are here: > ESRI Forums > arcgis explorer discussion forums > Thread Replies

ArcGIS Explorer Discussion Forums

ArcGIS Explorer: SDK Developers forum

ConvertToMapPoint not working in 3D mode   Jeff Frith Mar 31, 2010
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject ConvertToMapPoint not working in 3D mode 
Author Jeff Frith 
Date Mar 31, 2010 
Message The MapDisplay.ConvertToMapPoint() method is returning some odd results when in AGX 900 3D mode. I am creating a trackpoint and then converting the coordinates to a screenpoint using MapDisplay.ConvertToScreenPoint(). I then take the resulting microsoft screen point and convert it back to a ESRI point.

While in 2D mode, the point converts to screen coordinates and back to map coordinates with no loss of accuracy. If I then switch to 3D mode, the initial point coordinates and translated screen coordinates look correct. however the resulting conversion back to a point returns coordinates that are way off.

For example clicking the top left corner of the map display I get in 2D mode:
Point: 32.788, -79.904
Point to ScreenPoint: 0, 0
ScreenPoint to Point: 32.788, -79.904

Same test in 3D mode:
Point: 32.788, -79.904
Point to ScreenPoint: 0, 0
ScreenPoint to Point: 6.756, 157.689

Does anybody have any idea if this is a bug or am I missing a step? Attached is sample code and a compiled eaz of the test addin. 
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using ESRI.ArcGISExplorer;
using ESRI.ArcGISExplorer.Application;
using ESRI.ArcGISExplorer.Mapping;
using ESRI.ArcGISExplorer.Geometry;
using ESRI.ArcGISExplorer.Data;
using ESRI.ArcGISExplorer.Threading;

namespace ScreenToCoordTest
{
  public partial class CoordTest : ESRI.ArcGISExplorer.Application.DockWindow
  {
    public CoordTest()
    {
      InitializeComponent();
    }

    private void btnTrackPoint_Click(object sender, EventArgs e)
    {
      MapDisplay md = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay;
      
      //Capture Track Point and add to display as graphic
      ESRI.ArcGISExplorer.Geometry.Point trackedPoint = md.TrackPoint();
      Graphic trackedGraphic = new Graphic(trackedPoint, Symbol.Marker.Pushpin.Red);
      md.Graphics.Add(trackedGraphic);
      
      //Display clicked on track point coordinates
      txtBxLat.Text = trackedPoint.GetLatitude().ToString();
      txtBxLon.Text = trackedPoint.GetLongitude().ToString();

      //Show the active map display display mode 
      if (md.DisplayMode == DisplayMode.Display3D)
      {
        txtBxMode.Text = md.CurrentCoordinateSystem.ToString() + " (3D)";
      }
      else
      {
        txtBxMode.Text = md.CurrentCoordinateSystem.ToString() + " (2D)";
      }

      //Convert Trackpoint coordinates to screen coordinates and show results
      System.Drawing.Point screenPoint = md.ConvertToScreenPoint(trackedPoint);
      txtBxCoodX.Text = screenPoint.X.ToString();
      txtBxCoodY.Text = screenPoint.Y.ToString();

      //Convert Screen coordinates back to geometry points and show results
      ESRI.ArcGISExplorer.Geometry.Point convertedPt = new ESRI.ArcGISExplorer.Geometry.Point();
      convertedPt = md.ConvertToMapPoint(screenPoint);
      convertedPt.CoordinateSystem = md.CurrentCoordinateSystem;

      txtBxCLat.Text = convertedPt.GetLatitude().ToString();
      txtBxCLon.Text = convertedPt.GetLongitude().ToString();

    }
  }
}
 
  ScreenToCoordTest.eaz (opens in new window)