private void Initialize() { // Create a point geometry in NYC in WGS84 MapPoint startingPoint = new MapPoint(-73.984513, 40.748469, SpatialReferences.Wgs84); // Update the UI with the initial coordinates beforeLabel.Text = $"x: {startingPoint.X}, y: {startingPoint.Y}"; // Create a geographic transformation step for transform WKID 108055, WGS_1984_To_MSK_1942 GeographicTransformationStep geoStep = new GeographicTransformationStep(108055); // Create the transformation GeographicTransformation geoTransform = new GeographicTransformation(geoStep); // Project to a coordinate system used in New York, NAD_1983_HARN_StatePlane_New_York_Central_FIPS_3102 MapPoint afterPoint = (MapPoint)GeometryEngine.Project(startingPoint, SpatialReference.Create(2829), geoTransform); // Update the UI with the projected coordinates afterLabel.Text = $"x: {afterPoint.X}, y: {afterPoint.Y}"; // Perform the same projection without specified transformation MapPoint unspecifiedTransformPoint = (MapPoint)GeometryEngine.Project(startingPoint, SpatialReference.Create(2829)); // Update the UI with the projection done without specific transform for comparison purposes nonSpecificLabel.Text = $"x: {unspecifiedTransformPoint.X}, y: {unspecifiedTransformPoint.Y}"; }
/// <summary> /// Initializes a new instance of the <see cref="ReverseGeographicStrategy" /> class. /// </summary> /// <param name="source">The source reference system.</param> /// <param name="target">The target reference system.</param> /// <param name="transformation">The geographic transformation.</param> /// <exception cref="System.ArgumentNullException"> /// The source coordinate reference system is null. /// or /// target;The target coordinate reference system is null. /// or /// transformation;The transformation is null. /// </exception> public ReverseGeographicStrategy(GeographicCoordinateReferenceSystem source, GeographicCoordinateReferenceSystem target, GeographicTransformation transformation) { if (source == null) { throw new ArgumentNullException("source", "The source coordinate reference system is null."); } if (target == null) { throw new ArgumentNullException("target", "The target coordinate reference system is null."); } if (transformation == null) { throw new ArgumentNullException("transformation", "The transformation is null."); } _source = source; _target = target; _transformation = transformation; }
protected async override void OnClick() { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { ArcGIS.Desktop.Mapping.Map mappa = ProAddInSR.funzioniVariabiliGlobali.FunzioniGlobali.RicavaMappaAttiva(); if (mappa is null) { return; } CIMMap cIMMap = funzioniVariabiliGlobali.FunzioniGlobali.RicavaInfoMappaCIMMapClass(mappa).Result; CIMDatumTransform[] trasfDatum = cIMMap.DatumTransforms; // DatumTransform fornisce un array fornisce // una matrice unidimensionale di oggetti appartenenti alla classe CIMDatumTransform. string elencoProiezioniAlVolo = String.Empty; if (trasfDatum != null) { for (int i = 0; i < trasfDatum.LongCount <CIMDatumTransform>(); i++) { CIMDatumTransform cIMDatumTransform = new CIMDatumTransform(); // Istanzio la CoClass cIMDatumTransform = trasfDatum.ElementAt(i); // Ricavo quell'elemento alla tal posizione nella matrice // Ricavo l'oggetto GeographicTransformation, che dovrebbe essere un Abtract Class. GeographicTransformation geographicTransformation = cIMDatumTransform.GeoTransformation as GeographicTransformation; elencoProiezioniAlVolo = geographicTransformation.Name + Environment.NewLine; } ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(elencoProiezioniAlVolo, String.Format("Elenco proiezioni al volo della mappa: '{0}'", mappa.Name), System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); } else { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(String.Format("Non ci sono proiezioni al volo attive per la mappa: '{0}'", mappa.Name), "Attenzione", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation); } }); }